aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/request_sock.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-10-02 14:43:24 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-03 07:32:36 -0400
commitaac065c50aba0c534a929aeb687eb68c58e523b8 (patch)
treeb8817f56e96322e7c855653fe63eced1256c8356 /include/net/request_sock.h
parentfff1f3001cc58b5064a0f1154a7ac09b76f29c44 (diff)
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/request_sock.h')
-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;
122 * @max_qlen_log - log_2 of maximal queued SYNs/REQUESTs 122 * @max_qlen_log - log_2 of maximal queued SYNs/REQUESTs
123 */ 123 */
124struct listen_sock { 124struct listen_sock {
125 int qlen_inc; /* protected by listener lock */ 125 u32 max_qlen_log;
126 int young_inc;/* protected by listener lock */
127
128 /* following fields can be updated by timer */
129 atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
130 atomic_t young_dec;
131
132 u32 max_qlen_log ____cacheline_aligned_in_smp;
133 u32 synflood_warned; 126 u32 synflood_warned;
134 u32 hash_rnd; 127 u32 hash_rnd;
135 u32 nr_table_entries; 128 u32 nr_table_entries;
@@ -179,6 +172,9 @@ struct request_sock_queue {
179 spinlock_t rskq_lock; 172 spinlock_t rskq_lock;
180 u8 rskq_defer_accept; 173 u8 rskq_defer_accept;
181 174
175 atomic_t qlen;
176 atomic_t young;
177
182 struct request_sock *rskq_accept_head; 178 struct request_sock *rskq_accept_head;
183 struct request_sock *rskq_accept_tail; 179 struct request_sock *rskq_accept_tail;
184 struct listen_sock *listen_opt; 180 struct listen_sock *listen_opt;
@@ -242,41 +238,25 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
242static inline void reqsk_queue_removed(struct request_sock_queue *queue, 238static inline void reqsk_queue_removed(struct request_sock_queue *queue,
243 const struct request_sock *req) 239 const struct request_sock *req)
244{ 240{
245 struct listen_sock *lopt = queue->listen_opt;
246
247 if (req->num_timeout == 0) 241 if (req->num_timeout == 0)
248 atomic_inc(&lopt->young_dec); 242 atomic_dec(&queue->young);
249 atomic_inc(&lopt->qlen_dec); 243 atomic_dec(&queue->qlen);
250} 244}
251 245
252static inline void reqsk_queue_added(struct request_sock_queue *queue) 246static inline void reqsk_queue_added(struct request_sock_queue *queue)
253{ 247{
254 struct listen_sock *lopt = queue->listen_opt; 248 atomic_inc(&queue->young);
255 249 atomic_inc(&queue->qlen);
256 lopt->young_inc++;
257 lopt->qlen_inc++;
258}
259
260static inline int listen_sock_qlen(const struct listen_sock *lopt)
261{
262 return lopt->qlen_inc - atomic_read(&lopt->qlen_dec);
263}
264
265static inline int listen_sock_young(const struct listen_sock *lopt)
266{
267 return lopt->young_inc - atomic_read(&lopt->young_dec);
268} 250}
269 251
270static inline int reqsk_queue_len(const struct request_sock_queue *queue) 252static inline int reqsk_queue_len(const struct request_sock_queue *queue)
271{ 253{
272 const struct listen_sock *lopt = queue->listen_opt; 254 return atomic_read(&queue->qlen);
273
274 return lopt ? listen_sock_qlen(lopt) : 0;
275} 255}
276 256
277static inline int reqsk_queue_len_young(const struct request_sock_queue *queue) 257static inline int reqsk_queue_len_young(const struct request_sock_queue *queue)
278{ 258{
279 return listen_sock_young(queue->listen_opt); 259 return atomic_read(&queue->young);
280} 260}
281 261
282static inline int reqsk_queue_is_full(const struct request_sock_queue *queue) 262static inline int reqsk_queue_is_full(const struct request_sock_queue *queue)