🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23545

Re: [PATCH net] net/sched: enforce the FQ-PIE memory limit

#23545
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 13:14
171 lines
13988 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

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

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] fq_pie_reset() (net/sched/sch_fq_pie.c:539-556) frees every
  queued skb with rtnl_kfree_skbs() but never clears q->memory_usage.
- [Medium] Before this patch, fq_pie never dropped packets because of
  memory_limit (since ec97ecf1ebe4).
- [Low] fq_pie now enforces memory_limit at enqueue, but fq_pie_change()
  still trims the queue only with `while (sch->q.qlen > sch->limit)`…
- [Low] The commit message is written as an email or bug report, not a
  changelog.

--

net/sched: enforce the FQ-PIE memory limit

This patch makes fq_pie_qdisc_enqueue() drop an skb when its truesize
exceeds the remaining memory_limit budget. Previously the memory_limited
branch only incremented the overmemory counter. The patch also rewrites
the check with subtraction so that memory_limit + truesize cannot
overflow.

> Hello,
>
> [ ... ]
>
> HEAD commit:    8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
> git tree:       fe970b05333fb8e41da21e9e289f652abcc7cba7
> source version: Linux 7.4.0-rc4-g8d7fe9885c62
> compiler:       gcc 11.4.0, GNU ld 2.38
>
> The Gist contains the complete console output, kernel configuration,
> sender source, and initramfs/QEMU helpers:

[ ... ]

[Severity: Low]
This isn't a bug, but several parts of the commit message would end up
in git history permanently:

  - the greeting
  - the build metadata
  - the seven gist URLs
  - the QEMU/initramfs reproduction steps

Could these move below the --- line or into a cover letter?

> diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
> index 5982847df8f85..2e14467ae6585 100644
> --- a/net/sched/sch_fq_pie.c
> +++ b/net/sched/sch_fq_pie.c

[ ... ]

> @@ -152,7 +152,8 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
>  	sel_flow = &q->flows[idx];
>  	/* Checks whether adding a new packet would exceed memory limit */
>  	get_pie_cb(skb)->mem_usage = skb->truesize;
> -	memory_limited = q->memory_usage > q->memory_limit + skb->truesize;
> +	memory_limited = skb->truesize > q->memory_limit ||
> +		q->memory_usage > q->memory_limit - skb->truesize;

[Severity: Medium]
This still charges the full skb->truesize for every skb, including skbs
owned by local sockets. With the new goto out, that accounting now causes
drops under the unchanged default from fq_pie_init():

	q->memory_limit = SZ_32M;

fq_codel has the same 32 MiB default. Commit 150061a20651 ("net/sched:
fq_codel: local packets no longer count against memory limit") found that
default was not reasonable in practice. fq_codel_enqueue() now does:

	get_codel_cb(skb)->mem_usage = is_skb_wmem(skb) ? 0 : skb->truesize;

Consider a busy host with fq_pie as root and many local TCP/GSO bulk
flows. Once usage passes 32 MiB, could this tail-drop whatever packet
arrives next, including packets from thin flows? Those hosts previously
only saw overmemory increase. fq_codel drops from the fattest flow
instead.

Since this is tagged Cc: stable, should the commit message mention this
change in behaviour? And should fq_pie follow the fq_codel accounting?

>  
>  	/* Checks if the qdisc is full */
>  	if (unlikely(qdisc_qlen(sch) >= sch->limit)) {
> @@ -160,6 +161,7 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
>  		goto out;
>  	} else if (unlikely(memory_limited)) {
>  		q->overmemory++;
> +		goto out;
>  	}

[Severity: High]
Can fq_pie end up dropping every packet after a reset? fq_pie_reset()
frees all queued skbs but leaves q->memory_usage unchanged:

net/sched/sch_fq_pie.c:fq_pie_reset() {
    ...
	for (idx = 0; idx < q->flows_cnt; idx++) {
		struct fq_pie_flow *flow = q->flows + idx;

		/* Removes all packets from flow */
		rtnl_kfree_skbs(flow->head, flow->tail);
		flow->head = NULL;
    ...
}

The generic qdisc_reset() only zeroes q.qlen and qstats.backlog. The only
place that lowers memory_usage is fq_pie_qdisc_dequeue():

	q->memory_usage -= get_pie_cb(skb)->mem_usage;

Before this patch, a stale memory_usage only made the overmemory and
memory_usage stats wrong. Now suppose the queue is close to memory_limit
when a reset happens. The leftover memory_usage sends every later enqueue
down this goto out path. Nothing gets enqueued, so nothing is dequeued,
and memory_usage never comes back down. The interface keeps dropping
traffic until the qdisc is replaced or memory_limit is raised.

qdisc_reset() is reached in three ways:

  - dev_deactivate() via dev_reset_queue(), on link down or carrier loss
  - a parent reset such as tbf_reset()->qdisc_reset(q->qdisc)
  - graft

The sibling qdiscs clear their counter on reset. fq_codel_reset() does:

	q->memory_usage = 0;

and dualpi2_reset() does WRITE_ONCE(q->memory_used, 0).

Should fq_pie_reset() also clear q->memory_usage now that enqueue depends
on it being accurate?

[Severity: Low]
Now that enqueue enforces memory_limit, should fq_pie_change() also trim
the queue when memory_limit is lowered? It updates q->memory_limit from
TCA_FQ_PIE_MEMORY_LIMIT, but the trim loop only checks qlen:

net/sched/sch_fq_pie.c:fq_pie_change() {
    ...
	/* Drop excess packets if new limit is lower */
	while (sch->q.qlen > sch->limit) {
    ...
}

fq_codel_change() also trims on memory:

	while (sch->q.qlen > sch->limit ||
	       q->memory_usage > q->memory_limit) {

dualpi2_change() does the same with q->memory_used.

If tc qdisc change sets memory_limit below the current memory_usage,
fq_pie keeps the excess until the queue drains on its own. That can take
a long time if dequeue is stalled, for example behind a slow TBF parent
or a stopped txq.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126122902.1504968-1-shawnq1%40163.com
Technical Details
Message-ID: <179578525954.3135.976273510614457459@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372727-linux-kernel-netdev=dewy.ru
References: <20261126122902.1504968-1-shawnq1@163.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372727-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net/sched: enforce the FQ-PIE memory limit
Date: Fri, 27 Nov 2026 13:14:19 +0000
Organization: Usenet Network
Message-ID: <179578525954.3135.976273510614457459@kernel.org>
References: <20261126122902.1504968-1-shawnq1@163.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="736488"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rukZyV/kQ9LLSFji3RCQYm+tS2U= sha256:9oimi/rRBB9r6LxtcLI8GSZ3jj2mhjnjEMORSLNRvt0= sha1:w6+22LvzltAGsPsWfKdw5Vj4jZA= sha256:67anV+dWpt2ZEHN5MjFlkfH/RuWYQ9ZnhV++NiLZeOw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id DA377125F53; Fri, 27 Nov 2026 16:14:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gNN9bsmMwLIZ; Fri, 27 Nov 2026 16:14:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372727-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E53FE125F48; Fri, 27 Nov 2026 16:14:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 780BD44E36; Fri, 27 Nov 2026 13:14:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795785262; b=P3E7ZvQMIO5XHVBLyKcndHvmFWsGXtmiau2P7WhOi2zMyDBY1mjLF3wy8pKYSvguZUlm RE7OOhsEAqXc8DA6kPvdVUlL9nqsco2he61NgdX8x1v360pxYj2ak2xsM0Hj+bwL0cmOk TrvRxTxB4p/r1xn7Gg1cEnxhFGF6TY9FhMonfII160SXJxwoMuf5Guh+nePNwrb8igTMf iblBVf47ec38e4S1IF0hmlxTUGa5jASOlJsPtWdtSxSmZnx0hZkvw1JZPNPof94as5jaK 0Zsvb8tboHlUiuxi05GLePntYcKqsNQz+BBG1bX4u7dRDl9ZRmIlM1ar+FnrTMDx+7g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795785262; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=opKcnubl27drJR5MynPgskxgraLdng2dtGTp3OwZnpU=; b=Ol1jIXwjJBN1kOOXvoZzz6Sg/u7k5+vjHxl+7DH54mzlTNyUCozab/bZC17mupMn7B3m b6yQL5xvSj93RwjBdOuh5uttMdr+MQgSeZKm3YhixtgCqmRK0ua833TQniKU8sNsYtK74 cUCSjOo5J32GmiGmG+w6SJNB0eiuUXFzEynvbmPdMqIEzrNdiFTiHCfzTYuDMWMPWPGAH wkzA3wSv5nh4gKnJVN076W7wD3Tx21aATASHd+IvNU1JQj+pqxGFfs0EPNDjJsM1gdrLv k53Ngu/f/1elbhmwlihZo0qX7gvPNzlRWw2jwdRsTHSwkDbm/+iIABm4FY+DbTkVfPQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hLAPQUWY; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 408F4606A329; Fri, 27 Nov 2026 13:14:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hLAPQUWY
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795785261; b=PXM0CblLivVimtoYKd/GGI5ueuJudOlRzRPmwsIaezoi5tV6TLIuWHpuoBQpnQ4PL9sz nC26SrCdcTiQIkITc6XVuREthdAHbpNtMbg7FeyKqJ2qSYqE5b7/u/oHyNs9U1xDKy/q6 PgK5F6namfk6yQ5ubeIr/lOB6qGA8JUmUP/nlXJuNi3IH5io73n7JV+VZZG+6lVbCYEfo TKDdo86lu+FV6kiZR5bsp9zu6saviA8fTcpUoMSxqzyQ+g2VOoMDCO99iEuCCb4Vzzsbw rVXZCVdkNpsl4E/pRwjQx/5BVHTFAUaqvrqbIU+znvejVqmZSBYaLh3kMmdt5gFJFtQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795785261; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=opKcnubl27drJR5MynPgskxgraLdng2dtGTp3OwZnpU=; b=UWubF4hIl76g4zj8tf+1PlkB29Zkw8xx/aVRWEZYjuO1wk7YYHinMd+BNInvXUG5koZK YDMA7afDgl3I207MlTqJaHBRvppE2RdhUxSFEJlLWvaPa7IHv1fj4gSxbptbcKceJHjsm tp7r4hLnm8Y0c3uLvlWVD8n6F/Qr86tgcFciAT3QRErOd2XnVQVWtNz1xGVEj17wnTAxV +EYwwOTkKk7eH0t1BMnFeKEnWb6jj4YCJCfgAmbv2QO2bOnRkV5fj3eRJa6e+aZkciPjX Nb23oS03QXHFOiZDHkgM5CzgO6kSsZLLx84O4ym+Al0Covu48xg0hsUFuUP8xS5Pmwg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hLAPQUWY; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D50A606A31C; Fri, 27 Nov 2026 13:14:21 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 055491F0089A; Fri, 27 Nov 2026 13:14:19 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795785260; bh=opKcnubl27drJR5MynPgskxgraLdng2dtGTp3OwZnpU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=hLAPQUWYkFM/KZOrTNUnsaiXz5u7Kf314rFLomEz7CYaDKFnNLXyy28tFd6oDLii2 90HfAxQ//Fw6ARfZzHBplLpeIpuE5RD30rNnWkAdnVEnS1h9z5F21FkiX2EG+F62oi fINOvHt6mfDEG6cFTDVPJRCRnmWBT3QYI3PKGPhz5lZGyDs4gzuvWAgsttX3BASSrp 02VTUrES5vbhcfQW6c0lLhw2YJYU/T1drlR3+m/f3rLpb1k5NrelIRIOHAtymVjdCR S+JqBlYOnSAsdpFJLYe6C0h2bsxGEit68/UV1tXanOv4ywPKUvNEKpYP0yuJAgh1/e XeW9E6CbLhh9g==
X-Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261126122902.1504968-1-shawnq1@163.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 13729