Sharing UMEM without XDP_SHARED_UMEM

Richard Patel <[email protected]> Thu, 5 Dec 2024 14:59:38 +0100
Newsgroups org.kernel.vger.xdp-newbies
Message-ID <[email protected]>
Hello,

Is it safe to share the same virtual memory region as UMEM between two =
zero-copy XSKs without setting XDP_SHARED_UMEM?
The XSKs do not share the same (dev, queue) pair. They are backed by =
separate receive queues and have separate fill and completion rings.

I have an application receiving and sending packets via two such XSKs on =
the same thread.
I=E2=80=99d like to reuse buffers across both XSKs while ensuring each =
chunk is only submitted to one of the fill or TX rings.

In principle, this seems safe but undocumented.
If queue IDs or devices between two XSKs differ, the only notable =
difference in behavior when setting XDP_SHARED_UMEM is that =
xp_assign_dev_shared is called instead of xp_assign_dev. However, =
xdp_assign_dev_shared only copies XSK flags and then tail calls to =
xp_assign_dev.

Is there any special behaviour introduced by XDP_SHARED_UMEM in this =
case that I=E2=80=99m missing?
(Perhaps something to do with ref counting of memory pinning, or support =
for simultaneous DMAs from different devices into the same page?)
And is it possible that future changes to the kernel AF_XDP code or =
kernel drivers might break such operation without XDP_SHARED_UMEM?

Thanks
Richard=