]> git.karo-electronics.de Git - linux-beck.git/commitdiff
net: SOCKWQ_ASYNC_NOSPACE optimizations
authorEric Dumazet <edumazet@google.com>
Mon, 25 Apr 2016 17:39:32 +0000 (10:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Apr 2016 03:08:40 +0000 (23:08 -0400)
SOCKWQ_ASYNC_NOSPACE is tested in sock_wake_async()
so that a SIGIO signal is sent when needed.

tcp_sendmsg() clears the bit.
tcp_poll() sets the bit when stream is not writeable.

We can avoid two atomic operations by first checking if socket
is actually interested in the FASYNC business (most sockets in
real applications do not use AIO, but select()/poll()/epoll())

This also removes one cache line miss to access sk->sk_wq->flags
in tcp_sendmsg()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h

index d63b8494124ec40ebc515a80064977da5b114973..0f48aad9f8e883036eba1fa8855b34bed0ccc591 100644 (file)
@@ -1940,11 +1940,17 @@ static inline unsigned long sock_wspace(struct sock *sk)
  */
 static inline void sk_set_bit(int nr, struct sock *sk)
 {
+       if (nr == SOCKWQ_ASYNC_NOSPACE && !sock_flag(sk, SOCK_FASYNC))
+               return;
+
        set_bit(nr, &sk->sk_wq_raw->flags);
 }
 
 static inline void sk_clear_bit(int nr, struct sock *sk)
 {
+       if (nr == SOCKWQ_ASYNC_NOSPACE && !sock_flag(sk, SOCK_FASYNC))
+               return;
+
        clear_bit(nr, &sk->sk_wq_raw->flags);
 }