* Re: [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
2026-11-23 18:46 [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset() Eric Dumazet
@ 2026-11-24 0:49 ` Jamal Hadi Salim
2026-11-24 18:48 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Jamal Hadi Salim @ 2026-11-24 0:49 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman, netdev
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset()
2026-11-23 18:46 [PATCH net] net/sched: fq_pie: clear memory_usage and flow backlog in fq_pie_reset() Eric Dumazet
2026-11-24 0:49 ` Jamal Hadi Salim
@ 2026-11-24 18:48 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 18:48 UTC (permalink / raw)
To: edumazet; +Cc: davem, kuba, pabeni, willemb, horms, netdev, jhs
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
^ permalink raw reply [flat|nested] 3+ messages in thread