Re: Sharing UMEM without XDP_SHARED_UMEM
Magnus Karlsson <[email protected]> Thu, 5 Dec 2024 15:55:07 +0100
| Newsgroups | org.kernel.vger.xdp-newbies |
|---|---|
| Message-ID | <CAJ8uoz2oviM7k1HLuT_Kzk4S0RKKds7gdB6t_poohNmXo8Frgg@mail.gmail.com> |
On Thu, 5 Dec 2024 at 15:00, Richard Patel <[email protected]> wrote: > > Hello, > > Is it safe to share the same virtual memory region as UMEM between two ze= ro-copy XSKs without setting XDP_SHARED_UMEM? > The XSKs do not share the same (dev, queue) pair. They are backed by sepa= rate receive queues and have separate fill and completion rings. It is safe to share a umem by just registering the same umem region for each socket. This was the method before XDP_SHARED_UMEM. The drawback is that it consumes more memory as the xsk code in the kernel does not understand that it is indeed shared and structures could be shared too. > 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 ch= unk 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 differe= nce in behavior when setting XDP_SHARED_UMEM is that xp_assign_dev_shared i= s called instead of xp_assign_dev. However, xdp_assign_dev_shared only copi= es 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 kerne= l drivers might break such operation without XDP_SHARED_UMEM? > > Thanks > Richard