From: Eric Dumazet <edumazet@google.com>
To: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
jiri@resnulli.us, sdf@fomichev.me, kuniyu@google.com,
aleksander.lobakin@intel.com, netdev@vger.kernel.org,
skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: Revert tx queue length on partial failure in dev_qdisc_change_tx_queue_len()
Date: Tue, 22 Jul 2025 08:41:48 -0700 [thread overview]
Message-ID: <CANn89iJgG3yRQv+a04wzUtgqorSOM3DOFvGV2mgFV8QTVFjYxg@mail.gmail.com> (raw)
In-Reply-To: <20250722071508.12497-1-suchitkarunakaran@gmail.com>
On Tue, Jul 22, 2025 at 12:15 AM Suchit Karunakaran
<suchitkarunakaran@gmail.com> wrote:
>
> When changing the tx queue length via dev_qdisc_change_tx_queue_len(),
> if one of the updates fails, the function currently exits
> without rolling back previously modified queues. This can leave the
> device and its qdiscs in an inconsistent state. This patch adds rollback logic
> that restores the original dev->tx_queue_len and re-applies it to each previously
> updated queue's qdisc by invoking qdisc_change_tx_queue_len() again.
> To support this, dev_qdisc_change_tx_queue_len() now takes an additional
> parameter old_len to remember the original tx_queue_len value.
>
> Note: I have built the kernel with these changes to ensure it compiles, but I
> have not tested the runtime behavior, as I am currently unsure how to test this
> change.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
> ---
> include/net/sch_generic.h | 2 +-
> net/core/dev.c | 2 +-
> net/sched/sch_generic.c | 12 +++++++++---
> 3 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index 638948be4c50..a4f59df2982f 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -681,7 +681,7 @@ void qdisc_class_hash_remove(struct Qdisc_class_hash *,
> void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
> void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
>
> -int dev_qdisc_change_tx_queue_len(struct net_device *dev);
> +int dev_qdisc_change_tx_queue_len(struct net_device *dev, unsigned int old_len);
> void dev_qdisc_change_real_num_tx(struct net_device *dev,
> unsigned int new_real_tx);
> void dev_init_scheduler(struct net_device *dev);
> diff --git a/net/core/dev.c b/net/core/dev.c
> index be97c440ecd5..afa3c5a9bba1 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -9630,7 +9630,7 @@ int netif_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
> res = notifier_to_errno(res);
> if (res)
> goto err_rollback;
> - res = dev_qdisc_change_tx_queue_len(dev);
> + res = dev_qdisc_change_tx_queue_len(dev, orig_len);
> if (res)
> goto err_rollback;
> }
> diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
> index 16afb834fe4a..701dfbe722ed 100644
> --- a/net/sched/sch_generic.c
> +++ b/net/sched/sch_generic.c
> @@ -1445,7 +1445,7 @@ void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx)
> }
> EXPORT_SYMBOL(mq_change_real_num_tx);
>
> -int dev_qdisc_change_tx_queue_len(struct net_device *dev)
> +int dev_qdisc_change_tx_queue_len(struct net_device *dev, unsigned int old_len)
> {
> bool up = dev->flags & IFF_UP;
> unsigned int i;
> @@ -1456,12 +1456,18 @@ int dev_qdisc_change_tx_queue_len(struct net_device *dev)
>
> for (i = 0; i < dev->num_tx_queues; i++) {
> ret = qdisc_change_tx_queue_len(dev, &dev->_tx[i]);
> -
> - /* TODO: revert changes on a partial failure */
> if (ret)
> break;
> }
>
> + if (ret) {
> + dev->tx_queue_len = old_len;
WRITE_ONCE() is missing.
> + while (i >= 0) {
> + qdisc_change_tx_queue_len(dev, &dev->_tx[i]);
What happens if one of these calls fails ?
I think a fix will be more complicated...
next prev parent reply other threads:[~2025-07-22 15:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 7:15 [PATCH] net: Revert tx queue length on partial failure in dev_qdisc_change_tx_queue_len() Suchit Karunakaran
2025-07-22 13:36 ` Jakub Kicinski
2025-07-22 13:56 ` Suchit K
2025-07-22 14:33 ` Jakub Kicinski
2025-07-22 14:48 ` Suchit K
2025-07-22 15:41 ` Eric Dumazet [this message]
2025-07-22 16:21 ` Suchit K
2025-07-22 16:28 ` Eric Dumazet
2025-07-22 16:45 ` Suchit K
2025-07-23 18:17 ` Suchit K
2025-07-23 18:36 ` Eric Dumazet
2025-07-25 17:47 ` Cong Wang
2025-07-26 11:02 ` Suchit K
2025-07-23 15:52 ` kernel test robot
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=CANn89iJgG3yRQv+a04wzUtgqorSOM3DOFvGV2mgFV8QTVFjYxg@mail.gmail.com \
--to=edumazet@google.com \
--cc=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=skhan@linuxfoundation.org \
--cc=suchitkarunakaran@gmail.com \
--cc=xiyou.wangcong@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;
as well as URLs for NNTP newsgroup(s).