From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Mon, 30 Nov 2026 15:46:49 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79E831F0092A; Mon, 30 Nov 2026 15:46:48 +0000 (UTC) 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== Subject: Re: [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow From: netdev-bot+sashiko@kernel.org To: julius@bairaktaris.de 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 Date: Mon, 30 Nov 2026 15:46:48 +0000 Message-ID: <179605360803.3146.7627194726801802221@kernel.org> In-Reply-To: <20261129151144.2194312-5-julius@bairaktaris.de> References: <20261129151144.2194312-5-julius@bairaktaris.de> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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