xdp: use needs-wakeup flag

This is recommended in the kernel docs:
https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-use-need-wakeup-bind-flag

PiperOrigin-RevId: 472596449
This commit is contained in:
Kevin Krakauer
2022-09-06 17:34:14 -07:00
committed by gVisor bot
parent e907aff6ce
commit ad7b1121d4
2 changed files with 11 additions and 4 deletions
+6 -2
View File
@@ -202,11 +202,15 @@ func ReadOnlyFromSocket(sockfd int, ifaceIdx, queueID uint32, opts ReadOnlySocke
rxQueue.init(off, opts)
addr := unix.SockaddrXDP{
// XDP_USE_NEED_WAKEUP lets the driver sleep if there is no
// work to do. It will need to be woken by poll. It is expected
// that this improves performance by preventing the driver from
// burning cycles.
//
// By not setting either XDP_COPY or XDP_ZEROCOPY, we instruct
// the kernel to use zerocopy if available and then fallback to
// copy mode.
// TODO(b/240191988): Look into whether to use XDP_USE_NEED_WAKEUP.
Flags: 0,
Flags: unix.XDP_USE_NEED_WAKEUP,
Ifindex: ifaceIdx,
// AF_XDP sockets are per device RX queue, although multiple
// sockets on multiple queues (or devices) can share a single
+5 -2
View File
@@ -31,8 +31,11 @@ must also look at [libbpf itself][libbpf] to understand what's really going on.
## TODO
Kernel version < 5.4 has some weird offsets behavior. Just don't run on those
machines.
- Kernel version < 5.4 has some weird offsets behavior. Just don't run on
those machines.
- Implement SHARED, although it looks like we usually run with only 1
dispatcher.
- Add a -redirect $fromdev $todev option in order to test fast path.
[af_xdp_tutorial]: https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP
[libbpf]: https://github.com/torvalds/linux/tree/master/tools/testing/selftests/bpf/xsk.c