Question regarding the use of XDP_USE_NEED_WAKEUP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, I'm currently trying to write a Rust wrapper for using AF_XDP
sockets (using libbpf bindings) and have a couple questions about how
the XDP_USE_NEED_WAKEUP flag and the UMEM's fill queue interact. I'm
pretty new to this so apologies in advance if this is a dumb question.

While mucking around I created an AF_XDP socket with the
XDP_USE_NEED_WAKEUP flag set, and as I expected a call to
xsk_ring_prod__needs_wakeup returned 'true' when passed the xsk->tx
producer, however returned 'false' when passed the umem->fq producer.

I was a bit confused by this, as I thought it was a sort of 'fixed'
setting, so I think I'm misunderstanding one of two things:

1. Binding the socket with XDP_USE_NEED_WAKEUP isn't sufficient, I
also need to inform the UMEM through a particular flag / function
call, either on creation or after binding the socket? (To me this
seems unlikely and I've looked through the example [1] and I couldn't
find anything doing this, though I may have overlooked it).

2. Ater binding the socket with the XDP_USE_NEED_WAKEUP flag, both the
fill ring and tx ring may now require waking up, and the required flag
(XDP_RING_NEED_WAKEUP I believe) is set dynamically based on some
criteria at the time. Indeed going back over the docs [2] it appears
this way, so that at any time XDP_RING_NEED_WAKEUP can be set on the
fill ring (or tx ring) depending on a variety of conditions, and if it
is set then I should definitely send a wakeup, however there are
conditions where I may add to the fill ring / tx ring and I do not
need to send a wakeup.

I feel like #2 is the correct misinterpretation, does that sound
right? If that is correct, then out of interest (and if possible)
please could someone point me in the direction of the code which sets
the XDP_RING_NEED_WAKEUP flag on the UMEM's fill ring? I see there is
a comment in if_xdp.h [3] which says 'If this option is set, the
driver might go sleep and in that case, the XDP_RING_NEED_WAKEUP flag
in the fill and/or Tx rings will be set'. I couldn't find any further
code that mentions this flag however, so does its setting happen
deeper in the kernel / by the driver itself?

Thanks all!

Doug

[1] https://github.com/torvalds/linux/blob/master/samples/bpf/xdpsock_user.c

[2] https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-use-need-wakeup-bind-flag

[3] https://github.com/libbpf/libbpf/blob/d2f307c7f657bc7a4d3545bfcb7d42d66f9cedc1/include/uapi/linux/if_xdp.h



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux