All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] Revert "xsk: Do not sleep in poll() when need_wakeup set"
@ 2022-01-04  9:57 Xuan Zhuo
  2022-01-04 11:03 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Xuan Zhuo @ 2022-01-04  9:57 UTC (permalink / raw)
  To: netdev
  Cc: Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Maciej Fijalkowski, bpf

This reverts commit bd0687c18e635b63233dc87f38058cd728802ab4.

When working with epoll, if the application encounters tx full, the
application will enter epoll_wait and wait for tx to be awakened when
there is room.

In the current situation, when tx is full pool->cached_need_wakeup may
not be 0 (regardless of whether the driver supports wakeup, or whether
the user uses XDP_USE_NEED_WAKEUP). The result is that if the user
enters epoll_wait, because soock_poll_wait is not called, causing the
user process to not be awakened.

Fixes: bd0687c18e63 ("xsk: Do not sleep in poll() when need_wakeup set")
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 net/xdp/xsk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index e3d35850fdea..28ef3f4465ae 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -677,6 +677,8 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
 	struct xdp_sock *xs = xdp_sk(sk);
 	struct xsk_buff_pool *pool;
 
+	sock_poll_wait(file, sock, wait);
+
 	if (unlikely(!xsk_is_bound(xs)))
 		return mask;
 
@@ -688,8 +690,6 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
 		else
 			/* Poll needs to drive Tx also in copy mode */
 			__xsk_sendmsg(sk);
-	} else {
-		sock_poll_wait(file, sock, wait);
 	}
 
 	if (xs->rx && !xskq_prod_is_empty(xs->rx))
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] Revert "xsk: Do not sleep in poll() when need_wakeup set"
  2022-01-04  9:57 [PATCH net] Revert "xsk: Do not sleep in poll() when need_wakeup set" Xuan Zhuo
@ 2022-01-04 11:03 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2022-01-04 11:03 UTC (permalink / raw)
  To: Xuan Zhuo, netdev
  Cc: Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov,
	Jesper Dangaard Brouer, John Fastabend, Maciej Fijalkowski, bpf

Hi Xuan,

On 1/4/22 10:57 AM, Xuan Zhuo wrote:
> This reverts commit bd0687c18e635b63233dc87f38058cd728802ab4.
> 
> When working with epoll, if the application encounters tx full, the
> application will enter epoll_wait and wait for tx to be awakened when
> there is room.
> 
> In the current situation, when tx is full pool->cached_need_wakeup may
> not be 0 (regardless of whether the driver supports wakeup, or whether
> the user uses XDP_USE_NEED_WAKEUP). The result is that if the user
> enters epoll_wait, because soock_poll_wait is not called, causing the
> user process to not be awakened.
> 
> Fixes: bd0687c18e63 ("xsk: Do not sleep in poll() when need_wakeup set")
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>

This is already reverted in net tree:

   https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=0706a78f31c4217ca144f630063ec9561a21548d

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-04 11:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04  9:57 [PATCH net] Revert "xsk: Do not sleep in poll() when need_wakeup set" Xuan Zhuo
2022-01-04 11:03 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.