Article View: linux.kernel.netdev
Article #24672Re: [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:46
Date: Mon, 30 Nov 2026 15:46
120 lines
12282 bytes
12282 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of this performance-only patch has no
measurement, does not mention a small extra cost, and does not coverโฆ
--
net/sched: sch_cake: skip the dissection for a packet of an active flow
In cake_hash(), this patch skips skb_flow_dissect_flow_keys() and the
host hash computation when three things hold: the skb carries an L4
hash, nat mode has no conntrack tuple to rewrite the keys, and the flow
already holds an active queue. The conntrack tuple lookup moves ahead of
the dissection into a new cake_nat_lookup(). A new helper,
cake_flow_active(), scans the flow's set for an in-use queue.
> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> index e7bf7bc97d9f1..aee9bf963a291 100644
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c
[ ... ]
> @@ -713,6 +728,25 @@ static u16 cake_get_flow_quantum(struct cake_tin_data *q,
> (u16)prandom_u32_state(&q->dither)) >> 16;
> }
>
> +/* Whether the flow with @hash holds a queue of @q that is still in use. Its
> + * tag is then in that queue's set once, and cake_hash() resolves to that
> + * queue without allocating, so it reads no host hash.
> + */
> +static bool cake_flow_active(const struct cake_tin_data *q, u32 hash)
> +{
> + u32 reduced_hash = hash % CAKE_QUEUES;
> + u32 inner_hash = reduced_hash % CAKE_SET_WAYS;
> + u32 outer_hash = reduced_hash - inner_hash;
> + u32 i, k;
> +
> + for (i = 0, k = inner_hash; i < CAKE_SET_WAYS;
> + i++, k = (k + 1) % CAKE_SET_WAYS)
> + if (q->tags[outer_hash + k] == hash)
> + return q->flows[outer_hash + k].set != CAKE_SET_NONE;
> +
> + return false;
> +}
> +
[ ... ]
> @@ -734,11 +770,23 @@ static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb,
> if ((!hash_flows || (use_skbhash && !nat_enabled)) && !hash_hosts)
> goto skip_hash;
>
> + if (nat_enabled)
> + nat_found = cake_nat_lookup(&nat, skb);
> +
> + /* Without a conntrack tuple to rewrite the keys from, the SKB hash is
> + * the flow hash. The host hashes are only read when a queue is newly
> + * allocated to the flow, so a packet of a flow that already holds an
> + * active queue needs neither them nor the dissection.
> + */
> + if (hash_flows && use_skbhash && !nat_found &&
> + (!hash_hosts || cake_flow_active(q, skb->hash)))
> + goto skip_hash;
[Severity: Low]
This isn't a bug, but could the commit message cover a few more details?
The patch is only a performance change. Are there any numbers showing how
much skipping skb_flow_dissect_flow_keys() and the two
flow_hash_from_keys() calls saves per packet?
Sometimes hash_hosts is set and cake_flow_active() returns false. That
happens for a new flow, a flow whose queue is back at CAKE_SET_NONE, or a
tag collision. Such a packet still takes the full dissection path. The
set-associative lookup later in cake_hash() then scans the same
CAKE_SET_WAYS entries of q->tags[] a second time:
net/sched/sch_cake.c:cake_hash() {
...
for (i = 0, k = inner_hash; i < CAKE_SET_WAYS;
i++, k = (k + 1) % CAKE_SET_WAYS) {
if (q->tags[outer_hash + k] == flow_hash) {
...
}
Could the message mention this extra scan for packets that miss?
The message also says:
Check for such a queue first and skip the dissection when the flow has
one.
The !hash_hosts arm of the new condition also covers nat mode without
host hashing, that is, flows plus nat or host_override set. There, any
packet without a conntrack tuple now skips dissection with no queue check
at all.
Before the patch, such packets were dissected and cake_update_flowkeys()
returned false, so the use_skbhash && !hash_hosts exit was taken. The
selected queue is the same in both cases.
Could the message describe this branch as well?
> skb_flow_dissect_flow_keys(skb, &keys,
> FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
>
> /* Don't use the SKB hash if we change the lookup keys from conntrack */
> - if (nat_enabled && cake_update_flowkeys(&keys, skb))
> + if (nat_found && cake_update_flowkeys(&keys, &nat, skb))
> use_skbhash = false;
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129151144.2194312-1-julius%40bairaktaris.de
Technical Details
Message-ID:
<179605360803.3146.7627194726801802221@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374284-linux-kernel-netdev=dewy.ruReferences:
<20261129151144.2194312-5-julius@bairaktaris.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374284-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow Date: Mon, 30 Nov 2026 15:46:48 +0000 Organization: Usenet Network Message-ID: <179605360803.3146.7627194726801802221@kernel.org> References: <20261129151144.2194312-5-julius@bairaktaris.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1459921"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bXH3q19LGSlhUrGlouOcpVXPhC8= sha256:6JwbAErKxFAF7dAj+6VoiYTQuBZYupWdkehqcYB+zOg= sha1:tR5FIbtCQkhVXU6wxTfe6yqmmSs= sha256:UIerWuAMMSlJC36E7Kb27rV0skX/ksFFkdP1vvzd6s8= 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 85627125FEE; Mon, 30 Nov 2026 18:47:41 +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 h_VPa4Nrp_wL; Mon, 30 Nov 2026 18:47:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374284-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 D23FB125FED; Mon, 30 Nov 2026 18:47:29 +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 002B933209; Mon, 30 Nov 2026 15:46:55 +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=1796053610; b=ZDfJGWhw+PnDUWIQ570lleKE/BoJgYB772zkw/dRl/czYsiL5hgA7plvABdAYh9nPkET rkJgO0GOYrELkxfoTRLkEy2HK9G6bdCxxZXw3Ae03I0xy5wf37Z+gdGncHPFAfKgxnFbm 07Apb/t2zN5ymRdjwWcndqrt1kRfPnsRsxiz3+HADw7KlFIOUpGFYwbit39vzRrwcBYD3 HI1Ecu0rUv5i2cYkYtlsu9OBVgTlkqXmS3UcXekHt+Ans74ocjhTh8wHucGpD4lsUb/Rl AryFZMltrtrIViUmrUeAHmtQx0SfALUTDJ01YZw/DbUcu36lVkPeYfgnKTMgvnP1frg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053610; 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=ZCwPdx8wDA8fTTCGsBzvPWwqhxgVOdcEKVIJWQdtVKw=; b=tNwbChfyupEAZaUtY8IFH8hyhEav/JmX6+tDPWQ5VLE//+8FpC+nhMAjX266dCacGT9M EjVBtNlvEXLY+0Owcv8tdnUTBX/nBa4XeAzD+7JuKfmcx+6pTKhL9qEciaaVkRCWMlPcp nPvyC9Xm5cERXqEJzI/IjltwLjR3JCvxrRkhOrn/O1p2Aqy1GrI2VPhn5Do9uRW9KlNj1 1vityUA5N0JaWrrGTezswkuFg4xYgKnYXeXxmCL+Xr7GSwguQ7skCXXEFFQljf8eIQfcP hLz6zdZr1plwxG0sdttP8E5n2rBkqdAQ08eBFh8bny7klDsePifV0er+YYmrtmhvTzw== 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=CAmuRwAy; 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 78192606A68B; Mon, 30 Nov 2026 15:46:50 +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=CAmuRwAy 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=1796053609; b=Q+6kejB/5jruW7EcqvYdA8iVvNfhHWX3ajKM6a2KGU0kwrzs7+ANfW+wNpJH2N3LIAjU 47VIdRsspicH1eLH0r7LjO/sdqKWLyfQtMvgeBH4tAh9XkbbNAMGI6/OrrNOXXunR6/7Z zaYZdPX1qVVvlfDiXgWaNvG32mDT1jqa2RWyEhBk6HJFixwyamOhATNk6EX3M7krDyUKJ KkZLx15ImZNBdogp5LeclmEks6rJbFvHWgNVw84bCk28VhxiFemioNIcUFNlhbRFereH6 /0SKUD6Jb8Wf44lkBZvXA6FwUDuxof4mF6E1k9AR8YlARJSpvYYjFi88ne+nz6+TE0g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053609; 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=ZCwPdx8wDA8fTTCGsBzvPWwqhxgVOdcEKVIJWQdtVKw=; b=hiWvLeIfZT6jWcKyTFtwZXsgPvkGB2A3z1prLPibz7bj0yimAItAQknKaMfV8GwLinSs IJtpn4ohHmRIS0LcpG7PT70lIJ3+ZLKPlzoaWlkugrsmjhDaMs5h0nuncNMykNs28wkqP R2YHhEJM1wQfrmkdrkxek9jpVhVoJ/Uq90mpb0fOtD0RojGLQODKFUpPKkE9ETvkhwTs9 FsmGSb2X4k6P/Q8RgagwwZeg00tvYuytLucBZvHg/sMR6HsZSCnseV+t4lMYXNueWGCP3 02NGxSNdEPrSh35GrX5vnH9I3diAKWV21dFOEaKDEKoTDrqcDc5w8HifYFo/sv1VK6A== 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=CAmuRwAy; 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 99107606A320 for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 15:46:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79E831F0092A; Mon, 30 Nov 2026 15:46:48 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053609; bh=ZCwPdx8wDA8fTTCGsBzvPWwqhxgVOdcEKVIJWQdtVKw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CAmuRwAyEDwseXMf3gLCAbP8hgGpqjTewinTmZKrDdD7zpQuSmF/UuunVlD76tGc1 mwoCVjZeU04+t4G3OZqQ923NA0LMPMLEbP59kUWhZWqoh/4UidhkPvly1merUdfVYa weDPDJJgW0sfUPl6RKgaLAzEl4QkgbkI7mVy17tmFsPgBcF0ptN3QVpp5RPvvMow4y CXWiLTTIPEKr4Z7SNyWIoTRCYNUBjbrNJXXomqka6QDlSetW62qaJ+/tOLGiyjMLpl tLGj9QdMN43Eyb/C7I93Aauk0Cp6CKr0UC/dcXN2YrhssrGIRaWk90MM8Rcsry3I1H jqcJCiDbRty3w== X-Cc: toke@toke.dk, netdev@vger.kernel.org, jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, victor@mojatatu.com X-In-Reply-To: <20261129151144.2194312-5-julius@bairaktaris.de> X-sashiko-severity: Low 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