All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size
@ 2026-09-26 18:03 Jamal Hadi Salim
  2026-09-26 18:03 ` [PATCH net 2/2] net/sched: sch_codel: " Jamal Hadi Salim
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jamal Hadi Salim @ 2026-09-26 18:03 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Victor Nogueira,
	hybris, Sashiko

commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu")
clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX].
The two fields mean different things: quantum is a DRR credit that wants
the 256 floor, but cparams.mtu is the CoDel no-drop threshold
(codel_impl.h "*backlog <= params->mtu"). On a link whose maximum
transmitted packet size is below 256, the floor extends CoDel's
minimum-backlog exemption beyond one packet and delays drop or mark
eligibility by several small packets.

Split the clamp. quantum keeps [256, FQ_CODEL_QUANTUM_MAX]; cparams.mtu
tracks psched_mtu() (the device MTU plus its hard-header length) with
only the upper bound that guards the original overflow (psched_mtu()
wrapping to ~2 GiB on a huge-MTU device).

Conditions to recreate the bug: attach an fq_codel qdisc on a link
whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At
that MTU the no-drop threshold must equal the device MTU plus its
hard-header length; before this patch it was forced to 256.
Basic Testing done: with dev->mtu=100 and hard_header_len=14, a
return probe on fq_codel_init() observed cparams.mtu change from 256 to 114

Fixes: d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu")
Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260819143136.57350-1-jhs@mojatatu.com
Tested-by: hybris <hybris@mojatatu.ai>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/sched/sch_fq_codel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index 969b2510b0b8..e6c87a32950f 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -517,8 +517,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
 	q->flows_cnt = 1024;
 	q->memory_limit = 32 << 20; /* 32 MBytes */
 	q->drop_batch_size = 64;
-	mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, FQ_CODEL_QUANTUM_MAX);
-	q->quantum = mtu;
+	mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), FQ_CODEL_QUANTUM_MAX);
+	q->quantum = clamp_t(u32, mtu, 256, FQ_CODEL_QUANTUM_MAX);
 	INIT_LIST_HEAD(&q->new_flows);
 	INIT_LIST_HEAD(&q->old_flows);
 	codel_params_init(&q->cparams);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net/sched: sch_codel: match the no-drop threshold to the packet size
  2026-09-26 18:03 [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size Jamal Hadi Salim
@ 2026-09-26 18:03 ` Jamal Hadi Salim
  2026-09-29  0:04 ` [PATCH net 1/2] net/sched: fq_codel: " netdev-bot+sashiko
  2026-09-29 11:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jamal Hadi Salim @ 2026-09-26 18:03 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Victor Nogueira,
	hybris, Sashiko

commit 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid
disabling CoDel") clamped q->params.mtu to [256, 1 << 20]. The value is
the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"), so
on a link whose maximum transmitted packet size is below 256 the floor
extends CoDel's minimum-backlog exemption beyond one packet and delays
drop or mark eligibility by several small packets.

Keep the upper bound that guards the original overflow (psched_mtu()
wrapping to ~2 GiB on a huge-MTU device) but drop the 256 floor, so the
threshold tracks the real device packet size.

Conditions to recreate the bug: attach a codel qdisc on a link whose
MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that
MTU the no-drop threshold must equal the device MTU plus its
hard-header length; before this patch it was forced to 256.
Requires CAP_NET_ADMIN in a user namespace.

Fixes: 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid disabling CoDel")
Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260819143136.57350-1-jhs@mojatatu.com
Tested-by: hybris <hybris@mojatatu.ai>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/sched/sch_codel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c
index 6aa5829d6961..a1ba2e355f2d 100644
--- a/net/sched/sch_codel.c
+++ b/net/sched/sch_codel.c
@@ -205,7 +205,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,
 	codel_params_init(&q->params);
 	codel_vars_init(&q->vars);
 	codel_stats_init(&q->stats);
-	q->params.mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, 1 << 20);
+	q->params.mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), 1 << 20);
 
 	if (opt) {
 		int err = codel_change(sch, opt, extack);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size
  2026-09-26 18:03 [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size Jamal Hadi Salim
  2026-09-26 18:03 ` [PATCH net 2/2] net/sched: sch_codel: " Jamal Hadi Salim
@ 2026-09-29  0:04 ` netdev-bot+sashiko
  2026-09-29 11:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-09-29  0:04 UTC (permalink / raw)
  To: jhs
  Cc: netdev, jiri, davem, edumazet, kuba, pabeni, horms, victor,
	hybris, sashiko-bot

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] sch_codel has the same 256-byte floor on the CoDel no-drop
  threshold.

--

net/sched: fq_codel: match the no-drop threshold to the packet size

This patch splits the clamp in fq_codel_init(). q->quantum keeps the
[256, FQ_CODEL_QUANTUM_MAX] range. q->cparams.mtu now follows psched_mtu()
with only the upper bound, so CoDel's no-drop threshold matches the real
packet size on links where the MTU plus hard_header_len is below 256.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260819143136.57350-1-jhs@mojatatu.com

> diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
> index 969b2510b0b86..e6c87a32950f9 100644
> --- a/net/sched/sch_fq_codel.c
> +++ b/net/sched/sch_fq_codel.c
> @@ -517,8 +517,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
>  	q->flows_cnt = 1024;
>  	q->memory_limit = 32 << 20; /* 32 MBytes */
>  	q->drop_batch_size = 64;
> -	mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, FQ_CODEL_QUANTUM_MAX);
> -	q->quantum = mtu;
> +	mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), FQ_CODEL_QUANTUM_MAX);
> +	q->quantum = clamp_t(u32, mtu, 256, FQ_CODEL_QUANTUM_MAX);

[Severity: Medium]
Should the plain codel qdisc get the same change? At this commit,
codel_init() in net/sched/sch_codel.c still puts the 256 floor on the
CoDel no-drop threshold:

net/sched/sch_codel.c:codel_init() {
    ...
	q->params.mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, 1 << 20);
    ...
}

Both qdiscs use the same exemption in codel_should_drop()
(include/net/codel_impl.h):

    *backlog <= params->mtu

So if a codel qdisc is attached to a device where psched_mtu() is below
256 (e.g. a CAN interface), the path codel_init() ->
__codel_qdisc_dequeue() -> codel_should_drop() still exempts more than one
packet of backlog. That is the same delay in drop or mark eligibility that
this patch describes for fq_codel.

It looks like the next patch in this series, "net/sched: sch_codel: match
the no-drop threshold to the packet size", fixes this by changing the line
to:

	q->params.mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), 1 << 20);

That means the gap is only present between the two commits.

>  	INIT_LIST_HEAD(&q->new_flows);
>  	INIT_LIST_HEAD(&q->old_flows);
>  	codel_params_init(&q->cparams);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-34MS.v1.20260925165535%40mojatatu.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size
  2026-09-26 18:03 [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size Jamal Hadi Salim
  2026-09-26 18:03 ` [PATCH net 2/2] net/sched: sch_codel: " Jamal Hadi Salim
  2026-09-29  0:04 ` [PATCH net 1/2] net/sched: fq_codel: " netdev-bot+sashiko
@ 2026-09-29 11:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-29 11:00 UTC (permalink / raw)
  To: Jamal Hadi Salim
  Cc: netdev, jiri, davem, edumazet, kuba, pabeni, horms, victor,
	hybris, sashiko-bot

Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Sat, 26 Sep 2026 14:03:27 -0400 you wrote:
> commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu")
> clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX].
> The two fields mean different things: quantum is a DRR credit that wants
> the 256 floor, but cparams.mtu is the CoDel no-drop threshold
> (codel_impl.h "*backlog <= params->mtu"). On a link whose maximum
> transmitted packet size is below 256, the floor extends CoDel's
> minimum-backlog exemption beyond one packet and delays drop or mark
> eligibility by several small packets.
> 
> [...]

Here is the summary with links:
  - [net,1/2] net/sched: fq_codel: match the no-drop threshold to the packet size
    https://git.kernel.org/netdev/net/c/d031465acc36
  - [net,2/2] net/sched: sch_codel: match the no-drop threshold to the packet size
    https://git.kernel.org/netdev/net/c/54518e0e827f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-29 11:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-26 18:03 [PATCH net 1/2] net/sched: fq_codel: match the no-drop threshold to the packet size Jamal Hadi Salim
2026-09-26 18:03 ` [PATCH net 2/2] net/sched: sch_codel: " Jamal Hadi Salim
2026-09-29  0:04 ` [PATCH net 1/2] net/sched: fq_codel: " netdev-bot+sashiko
2026-09-29 11:00 ` patchwork-bot+netdevbpf

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.