mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SeungJong Ha <engineer.jjhama@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	 Simon Horman <horms@kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	 Jiri Pirko <jiri@resnulli.us>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 Jason Wang <jasowangio@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	 John Fastabend <john.fastabend@gmail.com>,
	linux-kernel@vger.kernel.org,  netdev@vger.kernel.org,
	SeungJong Ha <engineer.jjhama@gmail.com>
Subject: [PATCH RFC net-next 0/5] net: make tx_queue_len changes all-or-nothing
Date: Sun, 06 Dec 2026 23:44:41 +0900	[thread overview]
Message-ID: <20261206-tc1-txqlen-commit-v1-0-ec9f34dce973@gmail.com> (raw)

This follows the discussion of v1 [1], a different fix that sent
NETDEV_CHANGE_TX_QUEUE_LEN again after a failed change. I proposed
preallocating instead [2].

The only listener that can fail is the driver of the device itself
(tun, macvtap or ipvtap), and its resize already changes all rings or
none. So only the qdiscs need a separate allocation step:

  prepare qdiscs -> resize device rings -> set tx_queue_len
                 -> swap qdisc rings -> notify

Patches 1-3 do not depend on patches 4-5.

Questions:
- Is rtnl_link_ops the right place for the callback? A ndo does not
  work because macvtap and ipvtap use the net_device_ops of macvlan
  and ipvlan.
- Patch 5 ignores the return value of the notifier, so an out-of-tree
  listener can no longer veto the change. No in-tree one does after
  patch 4. The only in-tree listener left is rtnetlink, for
  RTM_NEWLINK. I kept the event like the ones of other link
  attributes, but it could become a direct rtmsg_ifinfo() call.
  Should it be removed?
- The three new Qdisc_ops are not documented, like the other ones.
  Their contract: all three run once per tx queue, so more than once
  for a root qdisc shared by them, and commit and abort must do
  nothing when nothing is pending. Should it be written down next to
  them?

All new qdisc rings are allocated before any old one is freed, so a
change needs more memory at once.

I found this with a prototype static analysis tool I am developing.
It flags error paths that return after a change was already made
visible to other code.

The analysis, the reproducer and the fix were written with Claude Code
(Claude Opus 5.5). I reviewed every line of the patches and the commit
messages, and re-ran the reproducer myself.

Tested in a QEMU VM on net-next d5cf954cebe4 with KASAN, lockdep and
kmemleak. failslab failed each allocation of the resize in turn.
Before, 37 of 64 runs left some qdiscs at the new length; after, none.
tun, macvtap and ipvtap no longer announce a refused length in
RTM_NEWLINK. All rings follow on growing and shrinking. tc-testing
pfifo_fast.json and fifo.json give the same results before and after.
Not tested on hardware.

[1] https://lore.kernel.org/netdev/20261125-tc1-txqlen-renotify-v1-1-6c8e9c4d0503@gmail.com/
[2] https://lore.kernel.org/netdev/CAGAB666kgzt9SF+QgAQ3ZnwhP3624P64Z89e5+uUrW0Pkkkdzg@mail.gmail.com/

Signed-off-by: SeungJong Ha <engineer.jjhama@gmail.com>
---
SeungJong Ha (5):
      ptr_ring: drop the unused gfp argument of __ptr_ring_swap_queue()
      ptr_ring: split ptr_ring_resize_multiple_bh() into alloc and swap
      net_sched: change tx_queue_len on all tx queues or on none
      net: resize tun and tap rings from rtnl_link_ops
      net: change tx_queue_len only after all allocations succeeded

 drivers/net/ipvlan/ipvtap.c |  13 ++++--
 drivers/net/macvtap.c       |  13 ++++--
 drivers/net/tap.c           |   7 ++-
 drivers/net/tun.c           |  73 +++++++++++++++---------------
 include/linux/if_tap.h      |   4 +-
 include/linux/ptr_ring.h    |  86 +++++++++++++++++++++++++----------
 include/linux/skb_array.h   |  14 +++---
 include/net/rtnetlink.h     |   5 +++
 include/net/sch_generic.h   |  10 ++++-
 net/core/dev.c              |  24 ++++++----
 net/sched/sch_generic.c     | 106 ++++++++++++++++++++++++++++++++++----------
 11 files changed, 235 insertions(+), 120 deletions(-)
---
base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
change-id: 20261205-tc1-txqlen-commit-42c8f03df652

Best regards,
--  
SeungJong Ha <engineer.jjhama@gmail.com>


             reply	other threads:[~2026-12-06 14:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06 14:44 SeungJong Ha [this message]
2026-12-06 14:44 ` [PATCH RFC net-next 1/5] ptr_ring: drop the unused gfp argument of __ptr_ring_swap_queue() SeungJong Ha
2026-12-06 14:44 ` [PATCH RFC net-next 2/5] ptr_ring: split ptr_ring_resize_multiple_bh() into alloc and swap SeungJong Ha
2026-12-06 14:44 ` [PATCH RFC net-next 3/5] net_sched: change tx_queue_len on all tx queues or on none SeungJong Ha
2026-12-06 14:44 ` [PATCH RFC net-next 4/5] net: resize tun and tap rings from rtnl_link_ops SeungJong Ha
2026-12-06 14:44 ` [PATCH RFC net-next 5/5] net: change tx_queue_len only after all allocations succeeded SeungJong Ha

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=20261206-tc1-txqlen-commit-v1-0-ec9f34dce973@gmail.com \
    --to=engineer.jjhama@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    --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

all inboxes | Powered by JetHome®