diff --git a/pkg/xdp/xdp.go b/pkg/xdp/xdp.go index 3afc2eb6f..f3c7fc81e 100644 --- a/pkg/xdp/xdp.go +++ b/pkg/xdp/xdp.go @@ -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 diff --git a/tools/xdp/README.md b/tools/xdp/README.md index 85dabd1e8..1eb8ed3b6 100644 --- a/tools/xdp/README.md +++ b/tools/xdp/README.md @@ -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