From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=zNWt98NO; arc=none (Message is not ARC signed); dmarc=none Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by mail.toke.dk (Postfix) with ESMTPS id 6160A177C516 for ; Thu, 08 Oct 2026 09:47:32 +0200 (CEST) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-533778ab0bdso28921371cf.3 for ; Thu, 08 Oct 2026 00:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu.com; s=google; t=1791445651; x=1792050451; darn=lists.bufferbloat.net; h=content-transfer-encoding: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=17lNCcyUrXS3jCmNwr/tkmkS1CRv+uhmVrNVbaSV7Vg=; b=zNWt98NOGr/RzKCcc94+/jMbFG4JmwTu9lYj0rwiUff9xyHhS0FZshX6iLp92gRjAe VulE9ZQhmUdxEuQL0YYHx+aN0tDJ0dbocT4ueoIkl+17HPNeR5H3jVHPXB20BldCPvEn RxQAJrzCF5q1XW7sls5jN0mRNweFdtnKjlxGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791445651; x=1792050451; h=content-transfer-encoding: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=17lNCcyUrXS3jCmNwr/tkmkS1CRv+uhmVrNVbaSV7Vg=; b=JlK+CYW/Qr5rclFeSKyoRZSrP8y66rdG8ywXJ8USR6rHDeBGWhUnlTZ35FmcqfmFH3 4b298j87CAsXNiRhjkrhMVC7rH4sGiyaZP16mYR58RtEXLUW12lt/JlZqJciVMwcU++1 psgZZ4KJcNiJDmqPR8G8fwYgH86Y6TPrcUqQR3zPY9anco1Lod3rXLmzbtAk+SkU3IrO 0jPSOHnFtWV99YdsuO2EDPuk1bmojheoGepNmSPbaVvFd5OTKnT+O6H2/9u72Q1tu0y5 RKf50kzE2+yBRFaltNvveZQ+fMFH88IVIrks1p/ss1SC3TrWbtm/n9+VWLhGVoLP9zQN sz5g== X-Forwarded-Encrypted: i=1; AKwUvBxwyeuflOMhLggMZJFp018PyckCMYE+CS/VYmfoHb/GntJdspoT+V1iCndKsN9cZZB+R90x@lists.bufferbloat.net X-Gm-Message-State: AFuF++mphYf9KIXv3KJ2erWL4undvWN9feaFkowervpovMB7uaX+KXyr AJB/WqQLsSeTCxa48OACra/8dIfX+KA4Opn/TXoHHf+06YDii8kNWWw4vnFLLjNyyw== X-Gm-Gg: AYBFou3HaCNBMdsaH3z2afftc4qaol72oTGHGYx3Al9B67oLhB/rJAwHIl7QLNRzMMU TfCOk3q3RQex1IvyfcChDfhgeLAjT+VBdEqV7h3KClXSsMMKFcKE1Wm/QaPdQmAbYp7mQ8Y0amO giWLy5+AMdb+QTiPHROA5fs2X8uhvRWns7H2mKdWoWobKSQDQI2M3EuZkzj8vlDsu/vj4LLZQn6 iirAfcGoVMVatmftsJEuWmSsv9Rb12VgxDD1PqGQy8HnCOGcHe2xOcGcAt/6nQ90LZ8mU092IjH 3oMgbsjLsqAkdZzlHFk0ova9OpIS0gY4fKu5/yh+nshzXQ6VObqh+F0N69IIojUga5dK2pZ9FDm hJF+xxcCDik5VS3Vx6I2afaFWI+5PJTkwiY2ACEaPbq8aCvLxTBfc27jCYEEUTWZjr0neH2iAll sja9DoIlRUEGxuOHmytzao/1WBY+lFwhv+69alOcUxBUSWfzwSaiYzyK8oAqGkXdvHO/yGUOhnD 907epMrL3EBMpEGI/EhG2ssGsqnAvckJSp1mEi5C20XwyLX3w== X-Received: by 2002:a05:622a:8c7:b0:535:521:75aa with SMTP id d75a77b69052e-535755c13d8mr80487401cf.48.1791445650909; Thu, 08 Oct 2026 00:47:30 -0700 (PDT) Received: from majuu.waya ([184.147.180.207]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5357213f3dcsm38253961cf.17.2026.10.08.00.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2026 00:47:30 -0700 (PDT) From: Jamal Hadi Salim To: netdev@vger.kernel.org Cc: Jamal Hadi Salim , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , cake@lists.bufferbloat.net, Victor Nogueira , Sashiko Date: Thu, 8 Oct 2026 03:47:10 -0400 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RY4ZXEY6DE7LYFGKW5WTINXOIBJMGJGH X-Message-ID-Hash: RY4ZXEY6DE7LYFGKW5WTINXOIBJMGJGH X-MailFrom: jhs@mojatatu.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Subject: [Cake] [PATCH net-next 2/4] net/sched/sch_cake: reduce parent backlog when clearing a tin List-Id: Cake - FQ_codel the next generation Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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. 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) Link: https://sashiko.dev/#/patchset/20260816012109.2865223-1-ooonea@gmail.com Link: https://lore.kernel.org/netdev/20260816012109.2865223-1-ooonea@gmail.com/ Reviewed-by: Victor Nogueira Signed-off-by: Jamal Hadi Salim --- 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