On Wed, Feb 28, 2024 at 07:05:56PM +0800, Yunjian Wang wrote: > This patch set allows TUN to support the AF_XDP Tx zero-copy feature, > which can significantly reduce CPU utilization for XDP programs. Why no Rx ZC support though? What will happen if I try rxdrop xdpsock against tun with this patch? You clearly allow for that. > > Since commit fc72d1d54dd9 ("tuntap: XDP transmission"), the pointer > ring has been utilized to queue different types of pointers by encoding > the type into the lower bits. Therefore, we introduce a new flag, > TUN_XDP_DESC_FLAG(0x2UL), which allows us to enqueue XDP descriptors > and differentiate them from XDP buffers and sk_buffs. Additionally, a > spin lock is added for enabling and disabling operations on the xsk pool. > > The performance testing was performed on a Intel E5-2620 2.40GHz machine. > Traffic were generated/send through TUN(testpmd txonly with AF_XDP) > to VM (testpmd rxonly in guest). > > +------+---------+---------+---------+ > | | copy |zero-copy| speedup | > +------+---------+---------+---------+ > | UDP | Mpps | Mpps | % | > | 64 | 2.5 | 4.0 | 60% | > | 512 | 2.1 | 3.6 | 71% | > | 1024 | 1.9 | 3.3 | 73% | > +------+---------+---------+---------+ > > Signed-off-by: Yunjian Wang <wangyunjian@xxxxxxxxxx> > --- > drivers/net/tun.c | 177 +++++++++++++++++++++++++++++++++++++++-- > drivers/vhost/net.c | 4 + > include/linux/if_tun.h | 32 ++++++++ > 3 files changed, 208 insertions(+), 5 deletions(-) >