Skip to content

Commit 0413f7a

Browse files
magnus-karlssongregkh
authored andcommitted
xsk: Do not sleep in poll() when need_wakeup set
commit bd0687c upstream. Do not sleep in poll() when the need_wakeup flag is set. When this flag is set, the application needs to explicitly wake up the driver with a syscall (poll, recvmsg, sendmsg, etc.) to guarantee that Rx and/or Tx processing will be processed promptly. But the current code in poll(), sleeps first then wakes up the driver. This means that no driver processing will occur (baring any interrupts) until the timeout has expired. Fix this by checking the need_wakeup flag first and if set, wake the driver and return to the application. Only if need_wakeup is not set should the process sleep if there is a timeout set in the poll() call. Fixes: 77cd0d7 ("xsk: add support for need_wakeup flag in AF_XDP rings") Reported-by: Keith Wiles <keith.wiles@intel.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Link: https://lore.kernel.org/bpf/20211214102607.7677-1-magnus.karlsson@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6b8d8ec commit 0413f7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/xdp/xsk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
499499
struct xdp_sock *xs = xdp_sk(sk);
500500
struct xsk_buff_pool *pool;
501501

502-
sock_poll_wait(file, sock, wait);
503-
504502
if (unlikely(!xsk_is_bound(xs)))
505503
return mask;
506504

@@ -512,6 +510,8 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
512510
else
513511
/* Poll needs to drive Tx also in copy mode */
514512
__xsk_sendmsg(sk);
513+
} else {
514+
sock_poll_wait(file, sock, wait);
515515
}
516516

517517
if (xs->rx && !xskq_prod_is_empty(xs->rx))

0 commit comments

Comments
 (0)