Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 30 Nov 2026 15:46
Re: [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads