From: Jakub Kicinski <kuba@kernel.org>
To: Ren Wei <n05ec@lzu.edu.cn>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, jiri@resnulli.us,
davem@davemloft.net, petrm@mellanox.com, yuantan098@gmail.com,
yifanwucs@gmail.com, tomapufckgml@gmail.com, zcliangcn@gmail.com,
bird@lzu.edu.cn, bronzed_45_vested@icloud.com
Subject: Re: [PATCH net v2 1/1] net: sched: ets: avoid deficit wrap and bound empty dequeue rounds
Date: Sat, 27 Jun 2026 15:14:58 -0700 [thread overview]
Message-ID: <20260627151458.4e5822d9@kernel.org> (raw)
In-Reply-To: <0e17a0309061300d31036a6a4c139919192f6373.1782379460.git.bronzed_45_vested@icloud.com>
On Fri, 26 Jun 2026 16:32:00 +0800 Ren Wei wrote:
> From: Wyatt Feng <bronzed_45_vested@icloud.com>
>
> ETS keeps each DRR-style deficit in a u32 and replenishes it with
> the configured quantum whenever the head packet is too large. Both
> the quantum and qdisc_pkt_len() are user-controlled inputs: a large
> quantum can wrap the deficit counter, while a tiny quantum combined
> with an inflated qdisc_pkt_len() can force billions of iterations in
> softirq context before any packet becomes eligible.
Do you mean when packet is gigabytes in size?
Where do such packets originate?
> Store the deficit in u64 so replenishment cannot wrap the counter.
> This keeps the existing dequeue logic unchanged while fixing the
> overflow condition.
>
> Bound one dequeue attempt to at most nbands * 2 ETS rotations, as
> suggested in review. This avoids the livelock without adding heavier
> logic to the fast path.
>
> Fixes: dcc68b4d8084 ("net: sch_ets: Add a new Qdisc")
> Cc: stable@vger.kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
> Assisted-by: Codex:GPT-5.4
> Signed-off-by: Wyatt Feng <bronzed_45_vested@icloud.com>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
> ---
> changes in v2:
> - Instead of doing a div() in the fast path, simply bound the loop per
> dequeue
> - v1 Link: https://lore.kernel.org/all/20260615103759.2404228-2-n05ec@lzu.edu.cn/
>
>
> net/sched/sch_ets.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c
> index cb8cf437ce87..12a156ccb0a6 100644
> --- a/net/sched/sch_ets.c
> +++ b/net/sched/sch_ets.c
> @@ -40,7 +40,7 @@ struct ets_class {
> struct list_head alist; /* In struct ets_sched.active. */
> struct Qdisc *qdisc;
> u32 quantum;
> - u32 deficit;
> + u64 deficit;
> struct gnet_stats_basic_sync bstats;
> struct gnet_stats_queue qstats;
> };
> @@ -463,6 +463,8 @@ ets_qdisc_dequeue_skb(struct Qdisc *sch, struct sk_buff *skb)
> static struct sk_buff *ets_qdisc_dequeue(struct Qdisc *sch)
> {
> struct ets_sched *q = qdisc_priv(sch);
> + unsigned int max_loops = READ_ONCE(q->nbands) * 2;
> + unsigned int loops = 0;
> struct ets_class *cl;
> struct sk_buff *skb;
> unsigned int band;
> @@ -499,6 +501,8 @@ static struct sk_buff *ets_qdisc_dequeue(struct Qdisc *sch)
>
> cl->deficit += READ_ONCE(cl->quantum);
> list_move_tail(&cl->alist, &q->active);
> + if (++loops > max_loops)
> + goto out;
> }
> out:
> return NULL;
next prev parent reply other threads:[~2026-06-27 22:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 8:32 [PATCH net v2 1/1] net: sched: ets: avoid deficit wrap and bound empty dequeue rounds Ren Wei
2026-06-26 9:54 ` Jamal Hadi Salim
2026-06-26 17:34 ` Yuan Tan
2026-06-27 22:14 ` Jakub Kicinski [this message]
2026-06-27 22:15 ` Jakub Kicinski
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=20260627151458.4e5822d9@kernel.org \
--to=kuba@kernel.org \
--cc=bird@lzu.edu.cn \
--cc=bronzed_45_vested@icloud.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=n05ec@lzu.edu.cn \
--cc=netdev@vger.kernel.org \
--cc=petrm@mellanox.com \
--cc=tomapufckgml@gmail.com \
--cc=yifanwucs@gmail.com \
--cc=yuantan098@gmail.com \
--cc=zcliangcn@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 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.