Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Eric Dumazet
Mon, 23 Nov 2026 18:46
[PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
Author: Eric Dumazet
Date: Mon, 23 Nov 2026 18:46
Date: Mon, 23 Nov 2026 18:46
43 lines
8787 bytes
8787 bytes
fq_pie_reset() frees all queued packets but does not update
q->memory_usage, which is only decremented in fq_pie_qdisc_dequeue().
After each reset of a non-empty qdisc (dev_deactivate(), parent purge),
the memory_usage reported in tc statistics is too high, and once it
exceeds memory_limit the overmemory counter is incremented for every
enqueued packet.
Clear q->memory_usage like fq_codel_reset() does.
Also clear flow->backlog, as fq_pie_timer() keeps feeding it to
pie_calculate_probability() for flows that no longer hold packets.
Found by code inspection (AI review) while looking at an unrelated
syzbot KCSAN report in fq_pie_reset(), not reproduced.
Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
net/sched/sch_fq_pie.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index 5982847df8f8..a5e2a83efb67 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -547,10 +547,12 @@ static void fq_pie_reset(struct Qdisc *sch)
/* Removes all packets from flow */
rtnl_kfree_skbs(flow->head, flow->tail);
flow->head = NULL;
+ flow->backlog = 0;
INIT_LIST_HEAD(&flow->flowchain);
pie_vars_init(&flow->vars);
}
+ q->memory_usage = 0;
}
static void fq_pie_destroy(struct Qdisc *sch)
--
2.53.0
Re: [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
Author: Jamal Hadi Salim
Date: Tue, 24 Nov 2026 00:49
Date: Tue, 24 Nov 2026 00:49
54 lines
13560 bytes
13560 bytes
On Mon, Nov 23, 2026 at 1:46 PM Eric Dumazet <edumazet@kernel.org> wrote:
>
> fq_pie_reset() frees all queued packets but does not update
> q->memory_usage, which is only decremented in fq_pie_qdisc_dequeue().
>
> After each reset of a non-empty qdisc (dev_deactivate(), parent purge),
> the memory_usage reported in tc statistics is too high, and once it
> exceeds memory_limit the overmemory counter is incremented for every
> enqueued packet.
>
> Clear q->memory_usage like fq_codel_reset() does.
>
> Also clear flow->backlog, as fq_pie_timer() keeps feeding it to
> pie_calculate_probability() for flows that no longer hold packets.
>
> Found by code inspection (AI review) while looking at an unrelated
> syzbot KCSAN report in fq_pie_reset(), not reproduced.
>
> Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
> ---
> net/sched/sch_fq_pie.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
> index 5982847df8f8..a5e2a83efb67 100644
> --- a/net/sched/sch_fq_pie.c
> +++ b/net/sched/sch_fq_pie.c
> @@ -547,10 +547,12 @@ static void fq_pie_reset(struct Qdisc *sch)
> /* Removes all packets from flow */
> rtnl_kfree_skbs(flow->head, flow->tail);
> flow->head = NULL;
> + flow->backlog = 0;
>
> INIT_LIST_HEAD(&flow->flowchain);
> pie_vars_init(&flow->vars);
> }
> + q->memory_usage = 0;
> }
>
> static void fq_pie_destroy(struct Qdisc *sch)
> --
> 2.53.0
>
Re: [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
Author: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 18:48
Date: Tue, 24 Nov 2026 18:48
101 lines
11585 bytes
11585 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] This patch leaves the problem it gives as its reason for
clearing `flow->backlog` in place for the default configuration.
--
net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
This commit makes fq_pie_reset() clear q->memory_usage, matching
fq_codel_reset(), so tc statistics and the overmemory counter stay correct
after a non-empty qdisc is reset. It also clears flow->backlog, since
fq_pie_timer() keeps passing it to pie_calculate_probability() for flows
that no longer hold packets.
> diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
> index 5982847df8f85..a5e2a83efb679 100644
> --- a/net/sched/sch_fq_pie.c
> +++ b/net/sched/sch_fq_pie.c
> @@ -547,10 +547,12 @@ static void fq_pie_reset(struct Qdisc *sch)
> /* Removes all packets from flow */
> rtnl_kfree_skbs(flow->head, flow->tail);
> flow->head = NULL;
> + flow->backlog = 0;
>
> INIT_LIST_HEAD(&flow->flowchain);
> pie_vars_init(&flow->vars);
[Severity: High]
Is clearing flow->backlog enough to stop fq_pie_timer() from feeding stale
per-flow state into pie_calculate_probability()?
With the default dq_rate_estimator=0, pie_calculate_probability() does not
derive the delay from the backlog argument. It reads the cached values:
net/sched/sch_pie.c:pie_calculate_probability() {
...
} else {
qdelay = vars->qdelay;
qdelay_old = vars->qdelay_old;
}
...
delta += alpha * (qdelay - params->target);
delta += beta * (qdelay - qdelay_old);
...
}
In that mode backlog only gates update_prob when qdelay is 0.
pie_vars_init() only resets burst_time, dq_tstamp, accu_prob, dq_count and
avg_dq_rate. It leaves vars->qdelay, vars->qdelay_old, vars->prob and
vars->backlog_old as they were.
When the dequeue-time estimator is off, pie_process_dequeue() is the only
place that writes a fresh vars->qdelay. The reset frees the packets without
going through it. If the flow was congested at reset time, vars->qdelay
therefore keeps the last sojourn time of the purged queue.
adapt_timer is only stopped in fq_pie_destroy(), so it keeps running after
a reset such as:
linkwatch -> dev_deactivate() -> dev_deactivate_many() -> dev_reset_queue()
-> qdisc_reset() -> fq_pie_reset()
If the stale qdelay is above target, can each tupdate round compute a
positive delta and keep raising prob for as long as the flow is idle? The
decay branch for qdelay == 0 && qdelay_old == 0 never runs in that case.
prob is only clamped when the u64 wraps, so it looks like it can grow past
MAX_PROB.
When traffic hashed to that bucket comes back, the 150ms burst_time runs
out. After that, pie_drop_early() no longer takes this early return:
if ((vars->qdelay < params->target / 2) &&
(vars->prob < MAX_PROB / 5))
return false;
Would that flow then see almost every packet dropped once its backlog
reaches 2 MTU? It looks like this would last until prob decays, which can
take seconds or longer depending on how long the flow was idle.
Should the reset path also clear vars->qdelay, vars->qdelay_old, vars->prob
and vars->backlog_old? That could go either in fq_pie_reset() or in a
full-reset helper. pie_reset() in sch_pie.c appears to have the same gap.
> }
> + q->memory_usage = 0;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123184602.386372-1-edumazet%40kernel.org
Re: [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
Author: patchwork-bot+netdevbpf
Date: Mon, 30 Nov 2026 16:10
Date: Mon, 30 Nov 2026 16:10
25 lines
8648 bytes
8648 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Mon, 23 Nov 2026 19:46:02 +0100 you wrote:
> fq_pie_reset() frees all queued packets but does not update
> q->memory_usage, which is only decremented in fq_pie_qdisc_dequeue().
>
> After each reset of a non-empty qdisc (dev_deactivate(), parent purge),
> the memory_usage reported in tc statistics is too high, and once it
> exceeds memory_limit the overmemory counter is incremented for every
> enqueued packet.
>
> [...]
Here is the summary with links:
- [net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
https://git.kernel.org/netdev/net/c/911e929f07d3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads