Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] tun: trim per-packet work on the write path
@ 2026-11-27 14:14 Antonio Quartulli
  2026-11-27 14:14 ` [PATCH net-next v3 1/3] tun: don't disable BHs for the XDP program check of every packet Antonio Quartulli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Antonio Quartulli @ 2026-11-27 14:14 UTC (permalink / raw)
  To: willemdebruijn.kernel, jasowangio
  Cc: Antonio Quartulli, andrew+netdev, davem, edumazet, kuba, pabeni,
	ast, daniel, hawk, john.fastabend, sdf, netdev, bpf

Profiling a link-bonding daemon that writes every packet to a tun device
showed tun doing per-packet work its packets do not need:

- patch 1: a BH-disabled RCU section, only to check for tun's XDP
  program, which only TAP devices can have
- patch 3: the parsing of an all-zero virtio-net header without
  IFF_VNET_HDR

Patch 2 reads tun->flags once in tun_get_user(), so that patch 3 and the
existing checks all see the same flags. The other paths read each flag
only once and are left as they are.

Together they cut the instructions per 1400-byte UDP packet written to a
TUN device by 3.3% when an iptables raw-table rule drops it on ingress,
and by 1.9% when it is forwarded to a dummy device. Counted under qemu
-icount on x86_64, with ERMS/FSRM hidden so that user copies are not
counted per byte; the counts include the syscall, so tun's own share of
the saving is larger. The tun selftests pass.

v3:
- Add patch 2, reading tun->flags once in tun_get_user(), and base the
  vnet header check on it (Willem)

v2: https://lore.kernel.org/netdev/20261124235959.1141963-1-antonio@mandelbit.com/
- Drop the patch that stopped probing the transport header: tc ematches
  and generic XDP rely on it (Sashiko)
- Rename the XDP check variable, which shadowed another one (Sashiko)
- Patch 2: adapt to the has_eth argument tun_vnet_hdr_tnl_to_skb()
  gained in 73e08d50eb13

v1: https://lore.kernel.org/netdev/20261112150612.3866546-1-antonio@mandelbit.com/

Antonio Quartulli (3):
  tun: don't disable BHs for the XDP program check of every packet
  tun: read tun->flags once in tun_get_user()
  tun: skip the virtio-net header parsing without IFF_VNET_HDR

 drivers/net/tun.c | 54 +++++++++++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 21 deletions(-)


base-commit: f89726ffabef1b08c52e6163b7ab94b0d5f15503
-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-27 14:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:14 [PATCH net-next v3 0/3] tun: trim per-packet work on the write path Antonio Quartulli
2026-11-27 14:14 ` [PATCH net-next v3 1/3] tun: don't disable BHs for the XDP program check of every packet Antonio Quartulli
2026-11-27 14:14 ` [PATCH net-next v3 2/3] tun: read tun->flags once in tun_get_user() Antonio Quartulli
2026-11-27 14:14 ` [PATCH net-next v3 3/3] tun: skip the virtio-net header parsing without IFF_VNET_HDR Antonio Quartulli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox