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
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 [thread overview]
Message-ID: <179605360803.3146.7627194726801802221@kernel.org> (raw)
In-Reply-To: <20261129151144.2194312-5-julius@bairaktaris.de>
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
prev parent reply other threads:[~2026-11-30 15:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 15:11 [PATCH net-next 0/4] net/sched: sch_cake: per-packet cost of a shaping CAKE Julius Bairaktaris
2026-11-29 15:11 ` [PATCH net-next 1/4] net/sched: sch_cake: give the shaper timer slack Julius Bairaktaris
2026-11-30 15:46 ` netdev-bot+sashiko
2026-11-29 15:11 ` [PATCH net-next 2/4] net/sched: sch_cake: dither the flow quantum from a per-tin generator Julius Bairaktaris
2026-11-30 15:46 ` netdev-bot+sashiko
2026-11-29 15:11 ` [PATCH net-next 3/4] net/sched: sch_cake: keep short GSO aggregates whole Julius Bairaktaris
2026-11-30 15:46 ` netdev-bot+sashiko
2026-11-29 15:11 ` [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow Julius Bairaktaris
2026-11-30 15:46 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179605360803.3146.7627194726801802221@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=julius@bairaktaris.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=toke@toke.dk \
--cc=victor@mojatatu.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox