diff mbox series

[net] Revert "xsk: Do not sleep in poll() when need_wakeup set"

Message ID 20220104095701.10661-1-xuanzhuo@linux.alibaba.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [net] Revert "xsk: Do not sleep in poll() when need_wakeup set" | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/apply success Patch already applied to net

Commit Message

Xuan Zhuo Jan. 4, 2022, 9:57 a.m. UTC
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(-)

Comments

Daniel Borkmann Jan. 4, 2022, 11:03 a.m. UTC | #1
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
diff mbox series

Patch

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