summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-10-02 11:43:24 -0700
committerDavid S. Miller <davem@davemloft.net>2015-10-03 04:32:36 -0700
commitaac065c50aba0c534a929aeb687eb68c58e523b8 (patch)
treeb8817f56e96322e7c855653fe63eced1256c8356 /include/net
parentfff1f3001cc58b5064a0f1154a7ac09b76f29c44 (diff)
downloadlinux-stable-aac065c50aba0c534a929aeb687eb68c58e523b8.tar.gz
linux-stable-aac065c50aba0c534a929aeb687eb68c58e523b8.tar.bz2
linux-stable-aac065c50aba0c534a929aeb687eb68c58e523b8.zip
tcp: move qlen/young out of struct listen_sock
qlen_inc & young_inc were protected by listener lock, while qlen_dec & young_dec were atomic fields. Everything needs to be atomic for upcoming lockless listener. Also move qlen/young in request_sock_queue as we'll get rid of struct listen_sock eventually. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/request_sock.h40
1 files changed, 10 insertions, 30 deletions
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 202e36163ae3..d128e7f89042 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -122,14 +122,7 @@ extern int sysctl_max_syn_backlog;
* @max_qlen_log - log_2 of maximal queued SYNs/REQUESTs
*/
struct listen_sock {
- int qlen_inc; /* protected by listener lock */
- int young_inc;/* protected by listener lock */
-
- /* following fields can be updated by timer */
- atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
- atomic_t young_dec;
-
- u32 max_qlen_log ____cacheline_aligned_in_smp;
+ u32 max_qlen_log;
u32 synflood_warned;
u32 hash_rnd;
u32 nr_table_entries;
@@ -179,6 +172,9 @@ struct request_sock_queue {
spinlock_t rskq_lock;
u8 rskq_defer_accept;
+ atomic_t qlen;
+ atomic_t young;
+
struct request_sock *rskq_accept_head;
struct request_sock *rskq_accept_tail;
struct listen_sock *listen_opt;
@@ -242,41 +238,25 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
static inline void reqsk_queue_removed(struct request_sock_queue *queue,
const struct request_sock *req)
{
- struct listen_sock *lopt = queue->listen_opt;
-
if (req->num_timeout == 0)
- atomic_inc(&lopt->young_dec);
- atomic_inc(&lopt->qlen_dec);
+ atomic_dec(&queue->young);
+ atomic_dec(&queue->qlen);
}
static inline void reqsk_queue_added(struct request_sock_queue *queue)
{
- struct listen_sock *lopt = queue->listen_opt;
-
- lopt->young_inc++;
- lopt->qlen_inc++;
-}
-
-static inline int listen_sock_qlen(const struct listen_sock *lopt)
-{
- return lopt->qlen_inc - atomic_read(&lopt->qlen_dec);
-}
-
-static inline int listen_sock_young(const struct listen_sock *lopt)
-{
- return lopt->young_inc - atomic_read(&lopt->young_dec);
+ atomic_inc(&queue->young);
+ atomic_inc(&queue->qlen);
}
static inline int reqsk_queue_len(const struct request_sock_queue *queue)
{
- const struct listen_sock *lopt = queue->listen_opt;
-
- return lopt ? listen_sock_qlen(lopt) : 0;
+ return atomic_read(&queue->qlen);
}
static inline int reqsk_queue_len_young(const struct request_sock_queue *queue)
{
- return listen_sock_young(queue->listen_opt);
+ return atomic_read(&queue->young);
}
static inline int reqsk_queue_is_full(const struct request_sock_queue *queue)