-
Notifications
You must be signed in to change notification settings - Fork 61
Support for XDP_USE_NEED_WAKEUP? #35
Description
From a quick overview of the code it seems that there is no support for XDP_USE_NEED_WAKEUP and XDP_RING_NEED_WAKEUP and the sendto / pool functions are invoked continuously.
Their used would drammatically reduce the invocation of the pool and sendto syscalls as they would be needed only when the flag XDP_RING_NEED_WAKEUP would be set on the ring and a flag check comes with basically no cost.
For reference here how the XDP_RING_NEED_WAKEUP flag check is implemented in libxdp
https://github.com/xdp-project/xdp-tools/blob/7fe0a0946a38a26d4196bc3819fc43227e0a9ddd/headers/xdp/xsk.h#L87
Here an example of how that check is used
if (xsk_ring_prod__needs_wakeup(&my_tx_ring))
sendto(xsk_socket__fd(xsk_handle), NULL, 0, MSG_DONTWAIT, NULL, 0);
Here another example of how the pattern would change for poll
https://android.googlesource.com/kernel/common/+/35556bed836f/samples/bpf/xdpsock_user.c#1103
rcvd = xsk_ring_cons__peek(&xsk->rx, opt_batch_size, &idx_rx);
if (!rcvd) {
if (xsk_ring_prod__needs_wakeup(&xsk->umem->fq))
ret = poll(fds, num_socks, opt_timeout);
return;
}