From: Tianyi Gao <tianyi@cloudflare.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: netdev@vger.kernel.org, "Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Eric Dumazet" <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"Simon Horman" <horms@kernel.org>,
"David Keogh" <dkeogh@amazon.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"David Woodhouse" <dwmw2@infradead.org>,
"Dragos Tatulea" <dtatulea@nvidia.com>,
"Nimrod Oren" <noren@nvidia.com>,
"Alasdair McWilliam" <alasdair@mcwilliam.dev>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"David Ahern" <dsahern@kernel.org>,
"Ido Schimmel" <idosch@nvidia.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Donald Hunter" <donald.hunter@gmail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Shuah Khan" <shuah@kernel.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Breno Leitao" <leitao@debian.org>,
"Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"Danielle Ratson" <danieller@nvidia.com>,
"Kuniyuki Iwashima" <kuniyu@google.com>,
bpf@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org, kernel-team@cloudflare.com,
nh-open-source@amazon.com
Subject: Re: [PATCH net-next 1/8] net: add tx_extra_headroom and LL_ALLOC_SPACE()
Date: Sun, 8 Nov 2026 21:43:56 +0000 [thread overview]
Message-ID: <20261108214356.95406-1-tianyi@cloudflare.com> (raw)
In-Reply-To: <willemdebruijn.kernel.2c6a653eb65fa@gmail.com>
On Sun, Nov 08, 2026 at 10:13:03AM -0500, Willem de Bruijn wrote:
> Pushing back on another design choice: the UAPI change. That both cannot be
> undone, and is fragile and laborious, requiring manual admin arithmetic.
Thanks for the valuable feedback.
On fragile: a wrong value never changes the packet. If it is too
small, the push reallocates, as it does today. If it is too large,
locally generated skbs on that device use more memory. So if the value
drifts from what the programs push, only performance changes. The
software that loads the encapsulating program knows the size and can
set the value at the same time.
On manual arithmetic: user space already does this for netkit. Commit
b9ed315d3c4c ("netkit: Allow for configuring needed_{head,tail}room")
lets the Cilium CNI plugin compute the headroom and set it on the
device.
On "cannot be undone": the IFLA_TX_EXTRA_HEADROOM UAPI does not block
in-kernel mechanisms. They can write the same field later, and the UAPI
stays a bounded, explicit value.
> The RFC patch mentioned two other approaches: explicit headroom requirement
> labeling for tc and BPF, and dynamic adjustment of this field whenever a
> realloc in the stack is encountered.
>
> They are left for future work. But should those instead be implemented
> first? As said, this manual hackery cannot be undone. While in-kernel
> mechanisms can be refined and built upon.
>
> It seems to be that this series is trying to address a few related
> situations and argues that no single solution fixes all except for manual
> adjustment. But likely a combination of the above (and more) will.
>
> This does leave the veth peer to solve, but that does not seem
> fundamentally intractable.
Regarding labeling for tc and BPF: it is also a new UAPI, and a label
increases the value of the device that the program is attached to.
That is often not the device that the skb was allocated on, as in the
cases below. If we have to add a new UAPI anyway, I would prefer one
that covers all of them.
I looked at what dynamic adjustment would take. The kernel can find
the device to increase in these cases:
- XDP on a veth peer: veth_xdp_set() and generic_xdp_install() can
increase the headroom of the peer to XDP_PACKET_HEADROOM on attach
and reset it on detach.
- A TC egress program on the device that the skb was allocated on: a
check around the tc egress hook catches a head reallocation, and the
kernel increases the headroom of skb->dev.
- Stacked devices: a vlan leaves its tag in skb->vlan_tci, so the lower
device can find the vlan with __vlan_find_dev_deep_rcu(). macvlan,
ipvlan and team keep the dst.
It cannot in this case, which we have at Cloudflare:
- A service in a network namespace sends through a veth pair. The host
forwards the traffic to the uplink, and a TC egress program there
encapsulates it. ip_rcv_core() has already orphaned the skb, so the
kernel can only guess that the veth peer of skb_iif allocated it.
Even where the kernel finds the right device, auto-tuning has problems:
- It grows too easily. Background traffic counts the same as the main
traffic, so a few encapsulated health-check probes increase the
headroom of every skb on the device. A threshold to filter them out
would be one more policy value to choose.
- That growth can move skbs into a larger kmalloc size without anyone
deciding it. On x86_64, for 1500-byte MTU UDP over IPv4 on an
Ethernet device, 194 bytes or more moves the skb head from
kmalloc-2048 to kmalloc-4096. That adds 2048 bytes to the memory and
the truesize of each such skb. The IFLA_TX_EXTRA_HEADROOM UAPI can
do the same, but then the operator chose to pay that cost.
- It only grows, unless it is reset on detach. A reset on detach must
find every device that the auto-tuning increased, which can be a veth
peer in another namespace.
So I prefer to keep the IFLA_TX_EXTRA_HEADROOM UAPI. If we need
auto-tuning on top of it, we can discuss it when someone actually needs
it.
Thanks again for pushing on this. If you see a simpler way to do
this, I am happy to change direction after discussing it with David
Keogh, who posted the initial RFC.
next prev parent reply other threads:[~2026-11-08 21:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 3:34 [PATCH net-next 0/8] net: configurable extra TX headroom for local egress Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 1/8] net: add tx_extra_headroom and LL_ALLOC_SPACE() Tianyi Gao
2026-11-07 14:51 ` Willem de Bruijn
2026-11-07 18:25 ` Tianyi Gao
2026-11-08 15:13 ` Willem de Bruijn
2026-11-08 21:43 ` Tianyi Gao [this message]
2026-11-10 14:48 ` Jesper Dangaard Brouer
2026-11-09 3:08 ` Stephen Hemminger
2026-11-09 15:49 ` Tianyi Gao
2026-11-10 16:23 ` Willem de Bruijn
2026-11-10 20:12 ` Tianyi Gao
2026-11-11 3:27 ` Willem de Bruijn
2026-11-11 20:23 ` David Keogh
2026-11-11 20:37 ` David Keogh
2026-11-11 21:41 ` Tianyi Gao
2026-11-11 23:19 ` David Keogh
2026-11-12 0:03 ` Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 2/8] net: reserve extra TX headroom for local egress Tianyi Gao
[not found] ` <sashiko-outbox-203545@kernel.org>
2026-11-08 22:22 ` Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 3/8] rtnetlink: add IFLA_TX_EXTRA_HEADROOM Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 4/8] selftests: net: add tx_extra_headroom test Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 5/8] selftests: net: tx_extra_headroom: test a push at TC egress Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 6/8] selftests: net: add flag to send a frame in xdp_helper Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 7/8] selftests: net: tx_extra_headroom: test generic XDP on the veth peer Tianyi Gao
2026-11-07 3:34 ` [PATCH net-next 8/8] selftests: net: tx_extra_headroom: test veth peer at creation Tianyi Gao
2026-11-10 15:38 ` Jakub Kicinski
2026-11-10 15:45 ` Tianyi Gao
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=20261108214356.95406-1-tianyi@cloudflare.com \
--to=tianyi@cloudflare.com \
--cc=alasdair@mcwilliam.dev \
--cc=andrew+netdev@lunn.ch \
--cc=ast@fiberby.net \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=danieller@nvidia.com \
--cc=davem@davemloft.net \
--cc=dkeogh@amazon.com \
--cc=donald.hunter@gmail.com \
--cc=dsahern@kernel.org \
--cc=dtatulea@nvidia.com \
--cc=dwmw2@infradead.org \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=leitao@debian.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nh-open-source@amazon.com \
--cc=noren@nvidia.com \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--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