Article View: linux.kernel.netdev
Article #3540[PATCH net-next v2 2/4] net/sched/sch_cake: reduce parent backlog when clearing a tin
From: Jamal Hadi Salim
Date: Thu, 15 Oct 2026 10:32
Date: Thu, 15 Oct 2026 10:32
72 lines
11007 bytes
11007 bytes
The issue:
CAKE has purged unused tins on DiffServ reconfiguration since commit
83f8fd69af4f ("sch_cake: Add DiffServ handling") without propagating the
resulting backlog reduction to classful parents. The issue was noticed
while reviewing 7cbfb180945c, but predates that change.
cake_clear_tin() drops every packet from a tin with
kfree_skb_reason() but never calls qdisc_tree_reduce_backlog(), so a
CAKE qdisc under a classful parent (e.g. HTB) leaves the dropped packets
in the parent qdisc's and class's qlen/backlog accounting forever. The
normal dequeue path does reduce the parent; only the live reconfigure
purge misses it.
The fix:
Tins are cleared from cake_reset() and, on reconfigure, from
cake_configure_rates(). The qdisc core already owns the parent delta for
the reset path: qdisc_purge_queue() snapshots qlen/backlog, runs
qdisc_reset(), then reduces the tree, so propagating the reduction from
cake_clear_tin() itself would subtract the same backlog twice. Snapshot
CAKE's qlen/backlog around only the reconfiguration purge in
cake_configure_rates() and reduce the parent once afterwards, matching
the delta pattern already used by cake_enqueue().
Conditions to recreate the bug:
put CAKE (diffserv8) under an HTB class, flood DSCP-classified traffic
into a high tin so it backlogs, then change CAKE to diffserv3. The HTB
parent keeps the purged packets in its qlen and backlog; a kernel with
the fix shows the parent at the leaf's backlog (426b/5p) instead of
retaining the purged packets.
Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260816012109.2865223-1-ooonea@gmail.com
Link: https://lore.kernel.org/netdev/20260816012109.2865223-1-ooonea@gmail.com/
Link: https://lore.kernel.org/netdev/8733ugtry8.fsf@toke.dk/
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
v1 -> v2:
- No changes to this patch. Resent as part of the
series_cake_clear_tin_backlog_underflow v2, which revises patches 1/4
and 3/4. It is unchanged and carries Toke Høiland-Jørgensen's Acked-by
from the v1 posting.
net/sched/sch_cake.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index 1c29695dc928..2bad0b6eb13f 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2611,10 +2611,17 @@ static void cake_configure_rates(struct Qdisc *sch, u64 rate, bool rate_adjust)
}
if (!rate_adjust) {
+ u32 backlog = sch->qstats.backlog, qlen = sch->q.qlen;
+
for (c = qd->tin_cnt; c < CAKE_MAX_TINS; c++) {
cake_clear_tin(sch, c);
qd->tins[c].cparams.mtu_time = qd->tins[ft].cparams.mtu_time;
}
+
+ backlog -= sch->qstats.backlog;
+ qlen -= sch->q.qlen;
+ if (qlen)
+ qdisc_tree_reduce_backlog(sch, qlen, backlog);
}
qd->rate_ns = qd->tins[ft].tin_rate_ns;
--
2.43.0
Technical Details
Message-ID:
<QDISC-5RTM.v2.r0.20261015051735-2@mojatatu.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346674-linux-kernel-netdev=dewy.ruReferences:
<QDISC-5RTM.v2.r0.20261015051735@mojatatu.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346674-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 2/4] net/sched/sch_cake: reduce parent backlog when clearing a tin
Date: Thu, 15 Oct 2026 06:32:43 -0400
Organization: Usenet Network
Message-ID: <QDISC-5RTM.v2.r0.20261015051735-2@mojatatu.com>
References: <QDISC-5RTM.v2.r0.20261015051735@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2509906"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qUV4hUU5davkyX2Fh0YAQrKQHWM= sha256:K73Ao5iHyEh5NG0CiRvAtKO9kROHr0FlJw2+cWOXnUE=
sha1:Qtpm6efJP+QhoK1bm7hDwlsOpwk= sha256:qaf6L6GRB+omAtDQdATsTC5aT68cecLYV8w3ZKw3OMk=
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 D69111102C6; Thu, 15 Oct 2026 13:45:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.75
X-Spam-Status: No, score=-0.75 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=mojatatu.com
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 DC6vqchq-w5B;
Thu, 15 Oct 2026 13:45:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-346674-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id E30C31102A0; Thu, 15 Oct 2026 13:45:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sin.lore.kernel.org (Postfix) with ESMTP id E112A2B573; Thu, 15 Oct 2026 10:33:01 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D29050AC23;
Thu, 15 Oct 2026 10:32:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.b="jVn/6tfx"
X-Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A0E951599A
for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 10:32:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1792060376; cv=none; b=gnBOI/yBiJZSL6F1HgDrc3XeDjpcArIgThaLpxDzGeVYWXQmDq54IwPrlofCghZeOFMAXBbgfD+jKMtsKwwy01gBHIEgE5p8YNd+fEBsC9/Vp8tiGj+aTQOKfspq2Lz2owsp690NdjmH6pECwb1gN3NSN6AGaUVIjSiGhpDpzug=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1792060376; c=relaxed/simple;
bh=OZbxwBxho4GfAvxbfrN+rMAHBZAt+e5t5XFJxKarp4o=;
h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:
MIME-Version:Content-Type; b=Zx8e2TPvV4njs0aiRbjpxIE19dgG9odgDdW+TAWhbM40CZ5Rw10SdcTDXJO8/Y5Eqw/xB7jWmO2EeOmRwVivyN6N25k1KGdlTgER2LDh+JCrYSf2SIvI6YChLwcu9ZjUMS4s8ugKAc1Rhot9VExZhut2/8xBsZnrO0bAnTeM9/I=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.b=jVn/6tfx; arc=none smtp.client-ip=209.85.219.47
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-917a20e9efeso72704196d6.2
for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 03:32:54 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mojatatu.com; s=google; t=1792060373; x=1792665173; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:references
:in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=9DR84ZATlyuLvZzGt+FeMmZtU5PGVpmcWJxla2K50nA=;
b=jVn/6tfxQrGEfiGRl6t4XoX4pLjLKzqPX5q93J4QWfXcwH2syAKsHfcCw9kXchMvKW
KQ1Yz7oiNoMADIaMHpAgACHXYCCz8bP/VzMySBy9HnIklWPBy5R2BfhdYevekTYcLGRq
l0bQ0j0xHWqJkvwu0RCm7Y6v4aBJUAZdhPkYY=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792060373; x=1792665173;
h=content-transfer-encoding:content-type:mime-version:references
:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=9DR84ZATlyuLvZzGt+FeMmZtU5PGVpmcWJxla2K50n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EjUG+I44uJzTrloIT+DQvTXwM=
X-Received: by 2002:a05:6214:4a06:b0:91b:8aad:79da with SMTP id 6a1803df08f44-91b8aad7bd4mr180472026d6.28.1792060373467;
Thu, 15 Oct 2026 03:32:53 -0700 (PDT)
X-Received: from mbili.waya ([64.203.83.2])
by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91ba684f404sm55261936d6.31.2026.10.15.03.32.52
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 15 Oct 2026 03:32:53 -0700 (PDT)
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Toke Høiland-Jørgensen <toke@toke.dk>,
Jiri Pirko <jiri@resnulli.us>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
cake@lists.bufferbloat.net,
Victor Nogueira <victor@mojatatu.com>,
Sashiko <sashiko-bot@kernel.org>
X-Mailer: git-send-email 2.34.1
X-In-Reply-To: <QDISC-5RTM.v2.r0.20261015051735@mojatatu.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>