All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: netdev@vger.kernel.org,
	syzbot+9744ccaabe337c6fb123@syzkaller.appspotmail.com,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Victor Nogueira" <victor@mojatatu.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/sched: re-enable queue reset on root qdisc graft
Date: Mon, 18 May 2026 18:16:40 -0700	[thread overview]
Message-ID: <20260518181640.150337d5@kernel.org> (raw)
In-Reply-To: <20260514031242.2667-1-jiayuan.chen@linux.dev>

On Thu, 14 May 2026 11:12:41 +0800 Jiayuan Chen wrote:
> Commit 47e8dbb6e763 ("net/sched: do not reset queues in graft
> operations") changed dev_deactivate() in qdisc_graft() from
> reset_needed=true to false. This was the right call for graft paths
> where the new qdisc has an ->attach op (mq): the new root
> takes over per-tx-queue state via attach, and a blanket reset would
> needlessly drop packets in unrelated leaves on every graft.
> 
> For the path where the new qdisc has no ->attach (e.g. HTB, sfq
> as root, or qdisc_graft() called for deletion with new == NULL), the
> old root subtree is going to be torn down anyway: every leaf will be
> freed shortly via __qdisc_destroy(). Skipping the early reset there
> provides no benefit, but it leaves leaf qdiscs with their queues
> intact during the window between rcu_assign_pointer(dev->qdisc, new)
> and the per-leaf sfq_destroy()/timer_delete_sync(). If a leaf has a
> self-armed timer that walks the parent chain (sfq_perturbation ->
> sfq_rehash -> qdisc_tree_reduce_backlog), the timer can fire after the
> old root has been swapped out, find dev->qdisc no longer matching,
> and trigger WARN_ON_ONCE(parentid != TC_H_ROOT).

Is not resetting root really worth the extra code?
We care about mq not resetting for each child N times
more than we care about the mq itself?

If we do care - you're breaking reverse xmas tree,
and "need_skip" is quite a poor choice of a name for
readability. 

> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index 6f7847c5536f..932cd1144b2b 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -1097,6 +1097,7 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
>  	struct net *net = dev_net(dev);
>  
>  	if (parent == NULL) {
> +		bool need_skip = false;
>  		unsigned int i, num_q, ingress;
>  		struct netdev_queue *dev_queue;
>  
> @@ -1123,12 +1124,15 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
>  			}
>  		}
>  
> +		if (new && new->ops->attach && !ingress)
> +			need_skip = true;
> +
>  		if (dev->flags & IFF_UP)
> -			dev_deactivate(dev, false);
> +			dev_deactivate(dev, !need_skip);
>  
>  		qdisc_offload_graft_root(dev, new, old, extack);
>  
> -		if (new && new->ops->attach && !ingress)
> +		if (need_skip)
>  			goto skip;
>  
>  		if (!ingress) {


      reply	other threads:[~2026-05-19  1:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14  3:12 [PATCH net] net/sched: re-enable queue reset on root qdisc graft Jiayuan Chen
2026-05-19  1:16 ` Jakub Kicinski [this message]

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=20260518181640.150337d5@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+9744ccaabe337c6fb123@syzkaller.appspotmail.com \
    --cc=toke@redhat.com \
    --cc=victor@mojatatu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.