diff options
author | Eric Dumazet <edumazet@google.com> | 2015-09-29 07:42:52 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-29 16:53:10 -0700 |
commit | 0536fcc039a8926ec12ec587f41a83f7acafeb82 (patch) | |
tree | 335da15ef581d750ada2ba11e6ca6900ba82ae86 /include/linux/tcp.h | |
parent | 2985aaac010ebd5e562ce1a22cc61acbb0e40cf2 (diff) | |
download | linux-0536fcc039a8926ec12ec587f41a83f7acafeb82.tar.gz linux-0536fcc039a8926ec12ec587f41a83f7acafeb82.tar.bz2 linux-0536fcc039a8926ec12ec587f41a83f7acafeb82.zip |
tcp: prepare fastopen code for upcoming listener changes
While auditing TCP stack for upcoming 'lockless' listener changes,
I found I had to change fastopen_init_queue() to properly init the object
before publishing it.
Otherwise an other cpu could try to lock the spinlock before it gets
properly initialized.
Instead of adding appropriate barriers, just remove dynamic memory
allocations :
- Structure is 28 bytes on 64bit arches. Using additional 8 bytes
for holding a pointer seems overkill.
- Two listeners can share same cache line and performance would suffer.
If we really want to save few bytes, we would instead dynamically allocate
whole struct request_sock_queue in the future.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/tcp.h')
-rw-r--r-- | include/linux/tcp.h | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h index fcb573be75d9..e442e6e9a365 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -382,25 +382,11 @@ static inline bool tcp_passive_fastopen(const struct sock *sk) tcp_sk(sk)->fastopen_rsk != NULL); } -extern void tcp_sock_destruct(struct sock *sk); - -static inline int fastopen_init_queue(struct sock *sk, int backlog) +static inline void fastopen_queue_tune(struct sock *sk, int backlog) { - struct request_sock_queue *queue = - &inet_csk(sk)->icsk_accept_queue; - - if (queue->fastopenq == NULL) { - queue->fastopenq = kzalloc( - sizeof(struct fastopen_queue), - sk->sk_allocation); - if (queue->fastopenq == NULL) - return -ENOMEM; - - sk->sk_destruct = tcp_sock_destruct; - spin_lock_init(&queue->fastopenq->lock); - } - queue->fastopenq->max_qlen = backlog; - return 0; + struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue; + + queue->fastopenq.max_qlen = backlog; } static inline void tcp_saved_syn_free(struct tcp_sock *tp) |