Netdev List
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@mandelbit.com>
To: willemdebruijn.kernel@gmail.com, jasowangio@gmail.com
Cc: Antonio Quartulli <antonio@mandelbit.com>,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
	daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
	sdf@fomichev.me, netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH net-next v3 0/3] tun: trim per-packet work on the write path
Date: Fri, 27 Nov 2026 15:14:02 +0100	[thread overview]
Message-ID: <20261127141406.651406-1-antonio@mandelbit.com> (raw)

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


             reply	other threads:[~2026-11-27 14:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 14:14 Antonio Quartulli [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127141406.651406-1-antonio@mandelbit.com \
    --to=antonio@mandelbit.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox