A Alexander Lobakin #
Message details and related content
This series introduces XSK generic zerocopy xmit by adding XSK umem pages as skb frags instead of copying data to linear space. The only requirement for this for drivers is to be able to xmit skbs with skb_headlen(skb) == 0, i.e. all data including hard headers starts from frag 0. To indicate whether a particular driver supports this, a new netdev priv flag, IFF_TX_SKB_NO_LINEAR, is added (and declared in virtio_net as it's already capable of doing it). So consider implementing this in your drivers to greatly speed-up generic XSK xmit. The first bit adds missing IFF self-definition. It's a bit out, but "while we are here". The fourth patch adds headroom and tailroom reservations for the allocated skbs on XSK generic xmit path. This ensures there won't be any unwanted skb reallocations on fast-path due to headroom and/or tailroom driver/device requirements (own headers/descriptors etc.). The other three add a new private flag, declare it in virtio_net driver and introduce generic XSK zerocopy xmit itself. The main body of work is created and done by Xuan Zhuo. His original cover letter: v3: Optimized code v2: 1. add priv_flags IFF_TX_SKB_NO_LINEAR instead of netdev_feature 2. split the patch to three: a. add priv_flags IFF_TX_SKB_NO_LINEAR b. virtio net add priv_flags IFF_TX_SKB_NO_LINEAR c. When there is support this flag, construct skb without linear space 3. use ERR_PTR() and PTR_ERR() to handle the err v1 message log: --------------- This patch is used to construct skb based on page to save memory copy overhead.
xdpsock -i eth0 -t -S -s <msg size>
Test result data:
size 64 512 1024 1500
copy 1916747 1775988 1600203 1440054
page 1974058 1953655 1945463 1904478
percent 3.0% 10.0% 21.58% 32.3%
From v7 [4]:
- drop netdev priv flags rework (will be issued separately);
- pick up Acks from John.
From v6 [3]:
- rebase ontop of bpf-next after merge with net-next;
- address kdoc warnings.
From v5 [2]:
- fix a refcount leak in 0006 introduced in v4.
From v4 [1]:
- fix 0002 build error due to inverted static_assert() condition
(0day bot);
- collect two Acked-bys (Magnus).
From v3 [0]:
- refactor netdev_priv_flags to make it easier to add new ones and
prevent bitwidth overflow;
- add headroom (both standard and zerocopy) and tailroom (standard)
reservation in skb for drivers to avoid potential reallocations;
- fix skb->truesize accounting;
- misc comment rewords.
[0] https://lore.kernel.org/netdev/cover.1611236588.git.xuanzhuo@linux.alibaba.com
[1] https://lore.kernel.org/netdev/20210216113740.62041-1-alobakin@pm.me
[2] https://lore.kernel.org/netdev/20210216143333.5861-1-alobakin@pm.me
[3] https://lore.kernel.org/netdev/20210216172640.374487-1-alobakin@pm.me
[4] https://lore.kernel.org/netdev/20210217120003.7938-1-alobakin@pm.me
Alexander Lobakin (2):
netdevice: add missing IFF_PHONY_HEADROOM self-definition