udp: small changes on receive path
Subsystems (11)
cover udp: small changes on receive path
This series is based on an observation I made in UDP receive path.
The sock_def_readable() costs are pretty high, especially when epoll is used to generate EPOLLIN events.
First patch annotates races on sk->sk_rcvbuf reads.
Second patch replaces an atomic_add_return()
with a less expensive atomic_add()
Third patch avoids calling sock_def_readable() when possible.
Fourth patch adds sk_wake_async_rcu() to get better inlining and code generation.
Eric Dumazet (4):
udp: annotate data-race in __udp_enqueue_schedule_skb()
udp: relax atomic operation on sk->sk_rmem_alloc
udp: avoid calling sock_def_readable() if possible
net: add sk_wake_async_rcu() helper
crypto/af_alg.c | 4 ++-- include/net/sock.h | 6 ++++++ net/atm/common.c | 2 +- net/core/sock.c | 8 ++++---- net/dccp/output.c | 2 +- net/ipv4/udp.c | 32 ++++++++++++++++++-------------- net/iucv/af_iucv.c | 2 +- net/rxrpc/af_rxrpc.c | 2 +- net/sctp/socket.c | 2 +- net/smc/smc_rx.c | 4 ++-- net/unix/af_unix.c | 2 +- 11 files changed, 38 insertions(+), 28 deletions(-)
Signature · 1 line
2.44.0.396.g6e790dbe36-goog
PATCH 1/4 udp: annotate data-race in __udp_enqueue_schedule_skb()
sk->sk_rcvbuf is read locklessly twice, while other threads could change its value.
Use a READ_ONCE() to annotate the race.
--- net/ipv4/udp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/ipv4/udp.c +6 -5
@@ -1492,13 +1492,14 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; -int size; +int size, rcvbuf; -/* try to avoid the costly atomic add/sub pair when the receive -* queue is full; always allow at least a packet +/* Immediately drop when the receive queue is full. +* Always allow at least one packet. */ rmem =atomic_read (&sk->sk_rmem_alloc); -if (rmem > sk->sk_rcvbuf) + rcvbuf =READ_ONCE (sk->sk_rcvbuf); +if (rmem > rcvbuf) goto drop;/* Under mem pressure, it might be helpful to help udp_recvmsg()
@@ -1507,7 +1508,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)* - Less cache line misses at copyout() time * - Less work at consume_skb() (less alien page frag freeing) */ -if (rmem > (sk->sk_rcvbuf >>1 )) { +if (rmem > (rcvbuf >>1 )) {skb_condense (skb); busy =busylock_acquire (sk);
Signature · 1 line
2.44.0.396.g6e790dbe36-goog
Willem de Bruijn
maintainerRe: [PATCH net-next 1/4] udp: annotate data-race in __udp_enqueue_schedule_skb()
Quoted 34 lines · Eric Dumazet
sk->sk_rcvbufis read locklessly twice, while other threads could change its value.Use a
READ_ONCE()to annotate the race.Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/udp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)net/ipv4/udp.c +5
-4@@ -1492,13 +1492,14 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; -int size; +int size, rcvbuf; -/* try to avoid the costly atomic add/sub pair when the receive -* queue is full; always allow at least a packet +/* Immediately drop when the receive queue is full. +* Always allow at least one packet. */ rmem =atomic_read (&sk->sk_rmem_alloc); -if (rmem > sk->sk_rcvbuf) + rcvbuf =READ_ONCE (sk->sk_rcvbuf); +if (rmem > rcvbuf) goto drop;/* Under mem pressure, it might be helpful to help udp_recvmsg()
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1514
Quoted 8 lines
net/ipv4/udp.c +1
-1@@ -1507,7 +1508,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)* - Less cache line misses at copyout() time * - Less work at consume_skb() (less alien page frag freeing) */ -if (rmem > (sk->sk_rcvbuf >>1 )) { +if (rmem > (rcvbuf >>1 )) {skb_condense (skb); busy =busylock_acquire (sk);
There's a third read in this function:
/* we drop only if the receive buf is full and the receive
* queue contains some other skb
*/
rmem = atomic_add_return(size, &sk->sk_rmem_alloc);
if (rmem > (size + (unsigned int)sk->sk_rcvbuf))
goto uncharge_drop;Another READ_ONCE if intent is to not use the locally cached copy?
Willem de Bruijn
maintainerRe: [PATCH net-next 1/4] udp: annotate data-race in __udp_enqueue_schedule_skb()
Quoted 42 lines · Willem de Bruijn
Quoted 41 lines · Eric Dumazet
sk->sk_rcvbufis read locklessly twice, while other threads could change its value.Use a
READ_ONCE()to annotate the race.Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/udp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)net/ipv4/udp.c +6
-5@@ -1492,13 +1492,14 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; -int size; +int size, rcvbuf; -/* try to avoid the costly atomic add/sub pair when the receive -* queue is full; always allow at least a packet +/* Immediately drop when the receive queue is full. +* Always allow at least one packet. */ rmem =atomic_read (&sk->sk_rmem_alloc); -if (rmem > sk->sk_rcvbuf) + rcvbuf =READ_ONCE (sk->sk_rcvbuf); +if (rmem > rcvbuf) goto drop;/* Under mem pressure, it might be helpful to help udp_recvmsg() @@ -1507,7 +1508,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)* - Less cache line misses at copyout() time * - Less work at consume_skb() (less alien page frag freeing) */ -if (rmem > (sk->sk_rcvbuf >>1 )) { +if (rmem > (rcvbuf >>1 )) {skb_condense (skb);
Quoted 3 lines
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1514
Quoted 1 line
net/ipv4/udp.c +0
-0busy =busylock_acquire (sk);There's a third read in this function:
But you remove that in the next patch. Ok.
PATCH 2/4 udp: relax atomic operation on sk->sk_rmem_alloc
In reply to Eric Dumazetatomic_add_return() is more expensive than atomic_add() and seems overkill in UDP rx fast path.
--- net/ipv4/udp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/ipv4/udp.c +1 -6
@@ -1516,12 +1516,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) size = skb->truesize;udp_set_dev_scratch (skb); -/* we drop only if the receive buf is full and the receive -* queue contains some other skb -*/ - rmem =atomic_add_return (size, &sk->sk_rmem_alloc); -if (rmem > (size + (unsigned int )sk->sk_rcvbuf)) - goto uncharge_drop; +atomic_add (size, &sk->sk_rmem_alloc);spin_lock (&list->lock); err =udp_rmem_schedule (sk, size);
Signature · 1 line
2.44.0.396.g6e790dbe36-goog
PATCH 3/4 udp: avoid calling sock_def_readable() if possible
In reply to Eric Dumazetsock_def_readable() is quite expensive (particularly when ep_poll_callback() is in the picture).
We must call sk->sk_data_ready() when :
- receive queue was empty, or
- SO_PEEK_OFF is enabled on the socket, or
- sk->sk_data_ready is not sock_def_readable.
We still need to call sk_wake_async().
--- net/ipv4/udp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/ipv4/udp.c +11 -3
@@ -1492,6 +1492,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; +bool becomes_readable;int size, rcvbuf;/* Immediately drop when the receive queue is full.
@@ -1532,12 +1533,19 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)*/ sock_skb_set_dropcount (sk, skb); + becomes_readable =skb_queue_empty (list);__skb_queue_tail (list, skb);spin_unlock (&list->lock); -if (!sock_flag (sk,SOCK_DEAD )) -INDIRECT_CALL_1 (sk->sk_data_ready, sock_def_readable, sk); - +if (!sock_flag (sk,SOCK_DEAD )) { +if (becomes_readable || + sk->sk_data_ready != sock_def_readable || +READ_ONCE (sk->sk_peek_off) >=0 ) +INDIRECT_CALL_1 (sk->sk_data_ready, + sock_def_readable, sk); +else +sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); + }busylock_release (busy);return 0 ;
Signature · 1 line
2.44.0.396.g6e790dbe36-goog
Re: [PATCH net-next 3/4] udp: avoid calling sock_def_readable() if possible
Quoted 5 lines · Eric Dumazet
sock_def_readable()is quite expensive (particularly whenep_poll_callback()is in the picture).We must call
sk->sk_data_ready()when :
Quoted 7 lines
- receive queue was empty, or
-SO_PEEK_OFFis enabled on the socket, or
-sk->sk_data_readyis notsock_def_readable.We still need to call
sk_wake_async().Signed-off-by Eric Dumazet <[email protected]>
Paolo Abeni
maintainerRe: [PATCH net-next 3/4] udp: avoid calling sock_def_readable() if possible
In reply to Eric DumazetQuoted 38 lines · Eric Dumazet
sock_def_readable()is quite expensive (particularly whenep_poll_callback()is in the picture).We must call
sk->sk_data_ready()when :- receive queue was empty, or
-SO_PEEK_OFFis enabled on the socket, or
-sk->sk_data_readyis notsock_def_readable.We still need to call
sk_wake_async().Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/udp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/ipv4/udp.c +2
-2@@ -1492,6 +1492,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; +bool becomes_readable;int size, rcvbuf;/* Immediately drop when the receive queue is full. @@ -1532,12 +1533,19 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)*/ sock_skb_set_dropcount (sk, skb); + becomes_readable =skb_queue_empty (list);__skb_queue_tail (list, skb);spin_unlock (&list->lock); -if (!sock_flag (sk,SOCK_DEAD )) -INDIRECT_CALL_1 (sk->sk_data_ready, sock_def_readable, sk);
net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1548
Quoted 10 lines
net/ipv4/udp.c +9
-1- +if (!sock_flag (sk,SOCK_DEAD )) { +if (becomes_readable || + sk->sk_data_ready != sock_def_readable || +READ_ONCE (sk->sk_peek_off) >=0 ) +INDIRECT_CALL_1 (sk->sk_data_ready, + sock_def_readable, sk); +else +sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); + }
I understood this change showed no performances benefit???
I guess the atomic_add_return() MB was hiding some/most of sock_def_readable() cost?
Thanks!
Paolo
Re: [PATCH net-next 3/4] udp: avoid calling sock_def_readable() if possible
Quoted 53 lines · Paolo Abeni
Quoted 38 lines · Eric Dumazet
sock_def_readable()is quite expensive (particularly whenep_poll_callback()is in the picture).We must call
sk->sk_data_ready()when :- receive queue was empty, or
-SO_PEEK_OFFis enabled on the socket, or
-sk->sk_data_readyis notsock_def_readable.We still need to call
sk_wake_async().Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/udp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/ipv4/udp.c +2
-2@@ -1492,6 +1492,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; +bool becomes_readable;int size, rcvbuf;/* Immediately drop when the receive queue is full. @@ -1532,12 +1533,19 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)*/ sock_skb_set_dropcount (sk, skb); + becomes_readable =skb_queue_empty (list);__skb_queue_tail (list, skb);spin_unlock (&list->lock); -if (!sock_flag (sk,SOCK_DEAD )) -INDIRECT_CALL_1 (sk->sk_data_ready, sock_def_readable, sk);net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1548
Quoted 10 lines
net/ipv4/udp.c +9
-1- +if (!sock_flag (sk,SOCK_DEAD )) { +if (becomes_readable || + sk->sk_data_ready != sock_def_readable || +READ_ONCE (sk->sk_peek_off) >=0 ) +INDIRECT_CALL_1 (sk->sk_data_ready, + sock_def_readable, sk); +else +sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); + }I understood this change showed no performances benefit???
Quoted 2 lines
I guess the
atomic_add_return()MB was hiding some/most ofsock_def_readable()cost?
It did show benefits in the epoll case, because ep_poll_callback() is very expensive.
I think you are referring to a prior discussion we had while still using netperf tests, which do not use epoll.
Eliminating sock_def_readable() was avoiding the smp_mb() we have in wq_has_sleeper()
and this was not a convincing win : The apparent cost of this smp_mb() was high in moderate traffic,
but gradually became small if the cpu was fully utilized.
The atomic_add_return() cost is orthogonal (I see it mostly on ARM64 platforms)
Re: [PATCH net-next 3/4] udp: avoid calling sock_def_readable() if possible
Quoted 54 lines · Eric Dumazet
Quoted 53 lines · Paolo Abeni
Quoted 38 lines · Eric Dumazet
sock_def_readable()is quite expensive (particularly whenep_poll_callback()is in the picture).We must call
sk->sk_data_ready()when :- receive queue was empty, or
-SO_PEEK_OFFis enabled on the socket, or
-sk->sk_data_readyis notsock_def_readable.We still need to call
sk_wake_async().Signed-off-by Eric Dumazet <[email protected]>--- net/ipv4/udp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)net/ipv4/udp.c +2
-2@@ -1492,6 +1492,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)struct sk_buff_head *list = &sk->sk_receive_queue;int rmem, err = -ENOMEM ;spinlock_t *busy =NULL ; +bool becomes_readable;int size, rcvbuf;/* Immediately drop when the receive queue is full. @@ -1532,12 +1533,19 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)*/ sock_skb_set_dropcount (sk, skb); + becomes_readable =skb_queue_empty (list);__skb_queue_tail (list, skb);spin_unlock (&list->lock); -if (!sock_flag (sk,SOCK_DEAD )) -INDIRECT_CALL_1 (sk->sk_data_ready, sock_def_readable, sk);net/ipv4/udp.c int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb) · line 1548
Quoted 10 lines
net/ipv4/udp.c +9
-1- +if (!sock_flag (sk,SOCK_DEAD )) { +if (becomes_readable || + sk->sk_data_ready != sock_def_readable || +READ_ONCE (sk->sk_peek_off) >=0 ) +INDIRECT_CALL_1 (sk->sk_data_ready, + sock_def_readable, sk); +else +sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); + }I understood this change showed no performances benefit???
Quoted 8 lines
Quoted 2 lines
I guess the
atomic_add_return()MB was hiding some/most ofsock_def_readable()cost?It did show benefits in the epoll case, because
ep_poll_callback()is very expensive.I think you are referring to a prior discussion we had while still using netperf tests, which do not use epoll.
Indeed.
Quoted 7 lines
Eliminating
sock_def_readable()was avoiding thesmp_mb()we have inwq_has_sleeper()
and this was not a convincing win : The apparent cost of thissmp_mb()was high in moderate traffic,
but gradually became small if the cpu was fully utilized.The
atomic_add_return()cost is orthogonal (I see it mostly on ARM64 platforms)
Thanks for the additional details.
FTR, I guessed that (part of) atomic_add_return() cost comes from the implied additional barrier (compared to plain adomic_add()) and the barrier in sock_def_readable() was relatively cheap in the presence of the previous one and become more visible after moving to adomic_add().
In any case LGTM, thanks!
PATCH 4/4 net: add sk_wake_async_rcu() helper
In reply to Eric DumazetWhile looking at UDP receive performance, I saw sk_wake_async() was no longer inlined.
This matters at least on AMD Zen1-4 platforms (see SRSO)
This might be because rcu_read_lock() and rcu_read_unlock() are no longer nops in recent kernels ?
Add sk_wake_async_rcu() variant, which must be called from contexts already holding rcu lock.
As SOCK_FASYNC is deprecated in modern days, use unlikely() to give a hint to the compiler.
sk_wake_async_rcu() is properly inlined from __udp_enqueue_schedule_skb() and sock_def_readable().
--- crypto/af_alg.c | 4 ++-- include/net/sock.h | 6 ++++++ net/atm/common.c | 2 +- net/core/sock.c | 8 ++++---- net/dccp/output.c | 2 +- net/ipv4/udp.c | 2 +- net/iucv/af_iucv.c | 2 +- net/rxrpc/af_rxrpc.c | 2 +- net/sctp/socket.c | 2 +- net/smc/smc_rx.c | 4 ++-- net/unix/af_unix.c | 2 +- 11 files changed, 21 insertions(+), 15 deletions(-)
crypto/af_alg.c +2 -2
@@ -847,7 +847,7 @@ void af_alg_wmem_wakeup(struct sock *sk)wake_up_interruptible_sync_poll (&wq->wait,EPOLLIN |EPOLLRDNORM |EPOLLRDBAND ); -sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); +sk_wake_async_rcu (sk,SOCK_WAKE_WAITD ,POLL_IN );rcu_read_unlock (); }EXPORT_SYMBOL_GPL (af_alg_wmem_wakeup);
@@ -914,7 +914,7 @@ static void af_alg_data_wakeup(struct sock *sk)wake_up_interruptible_sync_poll (&wq->wait,EPOLLOUT |EPOLLRDNORM |EPOLLRDBAND ); -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT );rcu_read_unlock (); }
include/net/sock.h +6 -0
@@ -2506,6 +2506,12 @@ static inline void sk_wake_async(const struct sock *sk, int how, int band) } } +static inline void sk_wake_async_rcu (const struct sock *sk,int how,int band) +{ +if (unlikely (sock_flag (sk,SOCK_FASYNC ))) +sock_wake_async (rcu_dereference (sk->sk_wq), how, band); +} +/* Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might * need sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak. * Note: for send buffers, TCP works better if we can build two skbs at
net/atm/common.c +1 -1
@@ -116,7 +116,7 @@ static void vcc_write_space(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible (&wq->wait); -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT ); }rcu_read_unlock ();
net/core/sock.c +4 -4
@@ -3338,7 +3338,7 @@ static void sock_def_error_report(struct sock *sk) wq =rcu_dereference (sk->sk_wq);if (skwq_has_sleeper (wq))wake_up_interruptible_poll (&wq->wait,EPOLLERR ); -sk_wake_async (sk,SOCK_WAKE_IO ,POLL_ERR ); +sk_wake_async_rcu (sk,SOCK_WAKE_IO ,POLL_ERR );rcu_read_unlock (); }
@@ -3353,7 +3353,7 @@ void sock_def_readable(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible_sync_poll (&wq->wait,EPOLLIN |EPOLLPRI |EPOLLRDNORM |EPOLLRDBAND ); -sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); +sk_wake_async_rcu (sk,SOCK_WAKE_WAITD ,POLL_IN );rcu_read_unlock (); }
@@ -3373,7 +3373,7 @@ static void sock_def_write_space(struct sock *sk) EPOLLWRNORM | EPOLLWRBAND);/* Should agree with poll, otherwise some programs break */ -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT ); }rcu_read_unlock ();
@@ -3398,7 +3398,7 @@ static void sock_def_write_space_wfree(struct sock *sk) EPOLLWRNORM | EPOLLWRBAND);/* Should agree with poll, otherwise some programs break */ -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT ); } }
net/dccp/output.c +1 -1
@@ -204,7 +204,7 @@ void dccp_write_space(struct sock *sk)wake_up_interruptible (&wq->wait);/* Should agree with poll, otherwise some programs break */ if (sock_writeable (sk)) -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT );rcu_read_unlock (); }
net/ipv4/udp.c +1 -1
@@ -1544,7 +1544,7 @@ int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)INDIRECT_CALL_1 (sk->sk_data_ready, sock_def_readable, sk); else -sk_wake_async (sk ,SOCK_WAKE_WAITD ,POLL_IN ); +sk_wake_async_rcu (sk ,SOCK_WAKE_WAITD ,POLL_IN ); }busylock_release (busy);return 0 ;
net/iucv/af_iucv.c +1 -1
@@ -184,7 +184,7 @@ static void iucv_sock_wake_msglim(struct sock *sk) wq =rcu_dereference (sk->sk_wq);if (skwq_has_sleeper (wq))wake_up_interruptible_all (&wq->wait); -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT );rcu_read_unlock (); }
net/rxrpc/af_rxrpc.c +1 -1
@@ -65,7 +65,7 @@ static void rxrpc_write_space(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible (&wq->wait); -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT ); }rcu_read_unlock (); }
net/sctp/socket.c +1 -1
@@ -9276,7 +9276,7 @@ void sctp_data_ready(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible_sync_poll (&wq->wait,EPOLLIN |EPOLLRDNORM |EPOLLRDBAND ); -sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); +sk_wake_async_rcu (sk,SOCK_WAKE_WAITD ,POLL_IN );rcu_read_unlock (); }
net/smc/smc_rx.c +2 -2
@@ -42,10 +42,10 @@ static void smc_rx_wake_up(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible_sync_poll (&wq->wait,EPOLLIN |EPOLLPRI |EPOLLRDNORM |EPOLLRDBAND ); -sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_IN ); +sk_wake_async_rcu (sk,SOCK_WAKE_WAITD ,POLL_IN );if ((sk->sk_shutdown ==SHUTDOWN_MASK ) || (sk->sk_state ==SMC_CLOSED )) -sk_wake_async (sk,SOCK_WAKE_WAITD ,POLL_HUP ); +sk_wake_async_rcu (sk,SOCK_WAKE_WAITD ,POLL_HUP );rcu_read_unlock (); }
net/unix/af_unix.c +1 -1
@@ -546,7 +546,7 @@ static void unix_write_space(struct sock *sk)if (skwq_has_sleeper (wq))wake_up_interruptible_sync_poll (&wq->wait,EPOLLOUT |EPOLLWRNORM |EPOLLWRBAND ); -sk_wake_async (sk,SOCK_WAKE_SPACE ,POLL_OUT ); +sk_wake_async_rcu (sk,SOCK_WAKE_SPACE ,POLL_OUT ); }rcu_read_unlock (); }
Signature · 1 line
2.44.0.396.g6e790dbe36-goog
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 28 Mar 2024 14:40:28 +0000 you wrote:
This series is based on an observation I made in UDP receive path.
The
sock_def_readable()costs are pretty high, especially when epoll is used to generate EPOLLIN events.First patch annotates races on
sk->sk_rcvbufreads.[...]
Here is the summary with links:
- [net-next,1/4] udp: annotate data-race in __udp_enqueue_schedule_skb()
https://git.kernel.org/netdev/net-next/c/605579699513 - [net-next,2/4] udp: relax atomic operation on sk->sk_rmem_alloc https://git.kernel.org/netdev/net-next/c/6a1f12dd85a8 - [net-next,3/4] udp: avoid calling sock_def_readable() if possible https://git.kernel.org/netdev/net-next/c/612b1c0dec5b - [net-next,4/4] net: add sk_wake_async_rcu() helper https://git.kernel.org/netdev/net-next/c/1abe267f173e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html