Skip to contentSkip to conversation

net: avoid some atomic ops when FASYNC is not used

PATCH In review Eric Dumazet 4 participants 16 messages Apr 25, 2016 – May 13, 2016

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover net: avoid some atomic ops when FASYNC is not used

We can avoid some atomic operations on sockets not using FASYNC

Eric Dumazet (2):
net: SOCKWQ_ASYNC_NOSPACE optimizations
net: SOCKWQ_ASYNC_WAITDATA optimizations

 include/net/sock.h | 8 ++++++++
 1 file changed, 8 insertions(+)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH 1/2 net: SOCKWQ_ASYNC_NOSPACE optimizations

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()

---
 include/net/sock.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/net/sock.h +6 -0
index d63b8494124e..0f48aad9f8e8 100644
@@ -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);
 }
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 6 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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.

Quoted 8 lines

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()

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

Thanks.

#3 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 11 lines · Jiri Pirko
Quoted 10 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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())

Quoted 8 lines
Quoted 4 lines

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

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

What do you mean by 'when nfs mount becomes stuck' ?

Is this patch making nfs not functional , or does it make recovery from some nfs error bad ?

Thanks.

#4 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 17 lines · Mon, May 02, 2016 at 06:22:18PM CEST, [email protected] wrote:
Quoted 16 lines · Jiri Pirko
Quoted 14 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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()

Quoted 8 lines
Quoted 3 lines

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

What do you mean by 'when nfs mount becomes stuck' ?

Is this patch making nfs not functional , or does it make recovery from some nfs error bad ?

I can mount nfs on the host. But when I do something (compile a kernel module in my case), it gets stuck. Then I cannot even ssh to the machine. No messages in dmesg. I didn't debug it any further. I just bisected and verified that this patch caused this behaviour.

#5 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 24 lines · Jiri Pirko
Quoted 23 lines · Mon, May 02, 2016 at 06:22:18PM CEST, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 10 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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())

Quoted 8 lines
Quoted 4 lines

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

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

What do you mean by 'when nfs mount becomes stuck' ?

Quoted 7 lines
Quoted 2 lines

Is this patch making nfs not functional , or does it make recovery from some nfs error bad ?

I can mount nfs on the host. But when I do something (compile a kernel module in my case), it gets stuck. Then I cannot even ssh to the machine. No messages in dmesg. I didn't debug it any further. I just bisected and verified that this patch caused this behaviour.

Interesting.

It looks like net/sunrpc/xprtsock.c should set SOCK_FASYNC even if it is not actually using fasync_list

Could you try this quick hack to check if this is the right way ?

Thanks !

net/sunrpc/xprtsock.c +3 -0
index a6c68dc086af83233ee315642638f4a1990ee622..b90c5397b5e137c6cc8accad6eebe2b876363d4e 100644
@@ -1950,6 +1950,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
@@ -2136,6 +2137,7 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_allocation = GFP_NOIO;
 
 		xprt_set_connected(xprt);
@@ -2237,6 +2239,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_data_ready = xs_tcp_data_ready;
 		sk->sk_state_change = xs_tcp_state_change;
 		sk->sk_write_space = xs_tcp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
maintainer
#6 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

From: Eric Dumazet <[email protected]>
Date: Mon, 02 May 2016 13:23:27 -0700

Quoted 4 lines

It looks like net/sunrpc/xprtsock.c should set SOCK_FASYNC even if it is not actually using fasync_list

Could you try this quick hack to check if this is the right way ?

Indeed, it tests the ASYNC bit without enabling FASYNC.

There are three other places that do this: macvtap, tun, dlm lowcomms.

#7 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 11 lines · David Miller

From: Eric Dumazet <[email protected]>
Date: Mon, 02 May 2016 13:23:27 -0700

Quoted 4 lines

It looks like net/sunrpc/xprtsock.c should set SOCK_FASYNC even if it is not actually using fasync_list

Could you try this quick hack to check if this is the right way ?

Indeed, it tests the ASYNC bit without enabling FASYNC.

There are three other places that do this: macvtap, tun, dlm lowcomms.

Yes, although macvtap and tun have a private usage of this bit.

When the flag was moved (commit ceb5d58b217098a657f3850b7a2640f995032e62 "net: fix sock_wake_async() rcu protection"), I did not change the code in these drivers. And apparently nobody complained (linux-4.4)

drivers/net/macvtap.c:501: !test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags))
drivers/net/macvtap.c:588: (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags) &&
drivers/net/tun.c:1111: (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) &&
drivers/net/tun.c:1576: if (!test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags))

fs/dlm/lowcomms.c probably needs a fix.

#8 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

In reply to Eric Dumazet
Quoted 33 lines · Mon, May 02, 2016 at 10:23:27PM CEST, [email protected] wrote:
Quoted 24 lines · Jiri Pirko
Quoted 23 lines · Mon, May 02, 2016 at 06:22:18PM CEST, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 10 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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())

Quoted 8 lines
Quoted 4 lines

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

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

What do you mean by 'when nfs mount becomes stuck' ?

Quoted 7 lines
Quoted 2 lines

Is this patch making nfs not functional , or does it make recovery from some nfs error bad ?

I can mount nfs on the host. But when I do something (compile a kernel module in my case), it gets stuck. Then I cannot even ssh to the machine. No messages in dmesg. I didn't debug it any further. I just bisected and verified that this patch caused this behaviour.

Quoted 6 lines

Interesting.

It looks like net/sunrpc/xprtsock.c should set SOCK_FASYNC even if it is not actually using fasync_list

Could you try this quick hack to check if this is the right way ?

Yep, works, I do not see the issue with this patch anymore. Thanks.

Quoted 33 lines

Thanks !

net/sunrpc/xprtsock.c +3 -0
index a6c68dc086af83233ee315642638f4a1990ee622..b90c5397b5e137c6cc8accad6eebe2b876363d4e 100644
@@ -1950,6 +1950,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
@@ -2136,6 +2137,7 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_allocation = GFP_NOIO;
 
 		xprt_set_connected(xprt);
@@ -2237,6 +2239,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_data_ready = xs_tcp_data_ready;
 		sk->sk_state_change = xs_tcp_state_change;
 		sk->sk_write_space = xs_tcp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
#9 lore raw

Re: [PATCH net-next 1/2] net: SOCKWQ_ASYNC_NOSPACE optimizations

Quoted 34 lines · Mon, May 02, 2016 at 10:45:44PM CEST, [email protected] wrote:
Quoted 33 lines · Mon, May 02, 2016 at 10:23:27PM CEST, [email protected] wrote:
Quoted 31 lines · Jiri Pirko
Quoted 17 lines · Mon, May 02, 2016 at 06:22:18PM CEST, [email protected] wrote:
Quoted 16 lines · Jiri Pirko
Quoted 14 lines · Mon, Apr 25, 2016 at 07:39:32PM CEST, [email protected] wrote:

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()

Quoted 8 lines
Quoted 3 lines

I just bisected down to this. This is causing a regression for me when my nfs mount becomes stuck. I can easily reproduce this if you need to test the fix.

What do you mean by 'when nfs mount becomes stuck' ?

Is this patch making nfs not functional , or does it make recovery from some nfs error bad ?

I can mount nfs on the host. But when I do something (compile a kernel module in my case), it gets stuck. Then I cannot even ssh to the machine. No messages in dmesg. I didn't debug it any further. I just bisected and verified that this patch caused this behaviour.

Quoted 8 lines
Quoted 6 lines

Interesting.

It looks like net/sunrpc/xprtsock.c should set SOCK_FASYNC even if it is not actually using fasync_list

Could you try this quick hack to check if this is the right way ?

Yep, works, I do not see the issue with this patch anymore. Thanks.

Eric, any news with this issue?

Thanks.

#10 lore raw

PATCH 1/1 sunrpc: set SOCK_FASYNC

In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>

sunrpc is using SOCKWQ_ASYNC_NOSPACE without setting SOCK_FASYNC, so the recent optimizations done in sk_set_bit() and sk_clear_bit() broke it.

There is still the risk that a subsequent sock_fasync() call would clear SOCK_FASYNC, but sunrpc does not use this yet.

Fixes 9317bb69824e ("net: SOCKWQ_ASYNC_NOSPACE optimizations")
---
 net/sunrpc/xprtsock.c |    3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/xprtsock.c +3 -0
index a6c68dc086af83233ee315642638f4a1990ee622..b90c5397b5e137c6cc8accad6eebe2b876363d4e 100644
@@ -1950,6 +1950,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
@@ -2136,6 +2137,7 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_user_data = xprt;
 		sk->sk_data_ready = xs_data_ready;
 		sk->sk_write_space = xs_udp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_allocation = GFP_NOIO;
 
 		xprt_set_connected(xprt);
@@ -2237,6 +2239,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
 		sk->sk_data_ready = xs_tcp_data_ready;
 		sk->sk_state_change = xs_tcp_state_change;
 		sk->sk_write_space = xs_tcp_write_space;
+		sock_set_flag(sk, SOCK_FASYNC);
 		sk->sk_error_report = xs_error_report;
 		sk->sk_allocation = GFP_NOIO;
 
maintainer Applied
#11 lore raw

Re: [PATCH net-next] sunrpc: set SOCK_FASYNC

From: Eric Dumazet <[email protected]>
Date: Thu, 12 May 2016 21:41:39 -0700

Quoted 9 lines

From: Eric Dumazet <[email protected]>

sunrpc is using SOCKWQ_ASYNC_NOSPACE without setting SOCK_FASYNC, so the recent optimizations done in sk_set_bit() and sk_clear_bit() broke it.

There is still the risk that a subsequent sock_fasync() call would clear SOCK_FASYNC, but sunrpc does not use this yet.

Quoted 6 lines
Fixes 9317bb69824e ("net: SOCKWQ_ASYNC_NOSPACE optimizations")

Applied, thanks.

#12 lore raw

PATCH v2 1/1 tcp-tso: do not split TSO packets at retransmit time

In reply to Eric Dumazet

Linux TCP stack painfully segments all TSO/GSO packets before retransmits.

This was fine back in the days when TSO/GSO were emerging, with their bugs, but we believe the dark age is over.

Keeping big packets in write queues, but also in stack traversal has a lot of benefits.
- Less memory overhead, because write queues have less skbs
- Less cpu overhead at ACK processing.
- Better SACK processing, as lot of studies mentioned how awful linux was at this ;)
- Less cpu overhead to send the rtx packets
(IP stack traversal, netfilter traversal, drivers...)
- Better latencies in presence of losses.
- Smaller spikes in fq like packet schedulers, as retransmits are not constrained by TCP Small Queues.

1 % packet losses are common today, and at 100Gbit speeds, this translates to ~80,000 losses per second.
Losses are often correlated, and we see many retransmit events leading to 1-MSS train of packets, at the time hosts are already under stress.

---
 include/net/tcp.h     |  4 ++--
 net/ipv4/tcp_input.c  |  2 +-
 net/ipv4/tcp_output.c | 64 +++++++++++++++++++++++----------------------------
 net/ipv4/tcp_timer.c  |  4 ++--
 4 files changed, 34 insertions(+), 40 deletions(-)
include/net/tcp.h +2 -2
index fd40f8c64d5f..0dc272dcd772 100644
@@ -538,8 +538,8 @@ __u32 cookie_v6_init_sequence(const struct sk_buff *skb, __u16 *mss);
 void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
 			       int nonagle);
 bool tcp_may_send_now(struct sock *sk);
-int __tcp_retransmit_skb(struct sock *, struct sk_buff *);
-int tcp_retransmit_skb(struct sock *, struct sk_buff *);
+int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);
+int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs);
 void tcp_retransmit_timer(struct sock *sk);
 void tcp_xmit_retransmit_queue(struct sock *);
 void tcp_simple_retransmit(struct sock *);
net/ipv4/tcp_input.c +1 -1
index 90e0d9256b74..729e489b5608 100644
@@ -5543,7 +5543,7 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
 	if (data) { /* Retransmit unacked data in SYN */
 		tcp_for_write_queue_from(data, sk) {
 			if (data == tcp_send_head(sk) ||
-			    __tcp_retransmit_skb(sk, data))
+			    __tcp_retransmit_skb(sk, data, 1))
 				break;
 		}
 		tcp_rearm_rto(sk);
net/ipv4/tcp_output.c +29 -35

130 lines not on this page · raw message

net/ipv4/tcp_timer.c +2 -2
index 49bc474f8e35..373b03e78aaa 100644
@@ -404,7 +404,7 @@ void tcp_retransmit_timer(struct sock *sk)
 			goto out;
 		}
 		tcp_enter_loss(sk);
-		tcp_retransmit_skb(sk, tcp_write_queue_head(sk));
+		tcp_retransmit_skb(sk, tcp_write_queue_head(sk), 1);
 		__sk_dst_reset(sk);
 		goto out_reset_timer;
 	}
@@ -436,7 +436,7 @@ void tcp_retransmit_timer(struct sock *sk)
 
 	tcp_enter_loss(sk);
 
-	if (tcp_retransmit_skb(sk, tcp_write_queue_head(sk)) > 0) {
+	if (tcp_retransmit_skb(sk, tcp_write_queue_head(sk), 1) > 0) {
 		/* Retransmission failed because of local congestion,
 		 * do not backoff.
 		 */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#13 lore raw

Re: [PATCH v2 net-next] tcp-tso: do not split TSO packets at retransmit time

Quoted 2 lines · Eric Dumazet

Linux TCP stack painfully segments all TSO/GSO packets before retransmits.

humpf.

Quoted 8 lines
---
 include/net/tcp.h     |  4 ++--
 net/ipv4/tcp_input.c  |  2 +-
 net/ipv4/tcp_output.c | 64 +++++++++++++++++++++++----------------------------
 net/ipv4/tcp_timer.c  |  4 ++--
 4 files changed, 34 insertions(+), 40 deletions(-)

Please ignore, I forgot to clean this one, it was already merged.

Sorry for the noise.

#14 lore raw

PATCH 2/2 net: SOCKWQ_ASYNC_WAITDATA optimizations

In reply to Eric Dumazet

SOCKWQ_ASYNC_WAITDATA is set/cleared in sk_wait_data() and equivalent functions, so that sock_wake_async() can send a SIGIO only when necessary.

Since these atomic operations are really not needed unless socket expressed interest in FASYNC, we can omit them in most cases.

---
 include/net/sock.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/net/sock.h +4 -2
index 0f48aad9f8e8..3df778ccaa82 100644
@@ -1940,7 +1940,8 @@ 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))
+	if ((nr == SOCKWQ_ASYNC_NOSPACE || nr == SOCKWQ_ASYNC_WAITDATA) &&
+	    !sock_flag(sk, SOCK_FASYNC))
 		return;
 
 	set_bit(nr, &sk->sk_wq_raw->flags);
@@ -1948,7 +1949,8 @@ static inline void sk_set_bit(int nr, struct sock *sk)
 
 static inline void sk_clear_bit(int nr, struct sock *sk)
 {
-	if (nr == SOCKWQ_ASYNC_NOSPACE && !sock_flag(sk, SOCK_FASYNC))
+	if ((nr == SOCKWQ_ASYNC_NOSPACE || nr == SOCKWQ_ASYNC_WAITDATA) &&
+	    !sock_flag(sk, SOCK_FASYNC))
 		return;
 
 	clear_bit(nr, &sk->sk_wq_raw->flags);
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer
#15 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Mon, 25 Apr 2016 10:39:31 -0700

Quoted 1 line

We can avoid some atomic operations on sockets not using FASYNC

I guess a user can do weird things and set/clear the FASYNC bit in the middle of the SOCKWQ_ASYNC_ bit being set, and reset the FASYNC bit later and the SOCKWQ_* state is stale.

However, that's probably not worth handling explicitly.

Series applied, thanks.