* [Cake] [PATCH] net/sched: cake: clamp active flow deficit on rate changes
@ 2026-06-09 0:08 Samuel Moelius
2026-06-09 1:08 ` [Cake] " Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Moelius @ 2026-06-09 0:08 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: Samuel Moelius, Jamal Hadi Salim, Jiri Pirko, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
moderated list:CAKE QDISC, open list:TC subsystem, open list
Changing CAKE rate parameters updates the quantum used for future
scheduling, but active flows can retain deficit computed under the old
rate.
That stale deficit lets an already active flow receive service based on
the previous configuration after userspace changes the shaper rate.
After recomputing rate-derived scheduling parameters, clamp positive
active-flow deficits to the quantum that applies under the new
configuration.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
net/sched/sch_cake.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index 5862933be8d7..048d313e70fe 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2621,6 +2621,36 @@ static void cake_configure_rates(struct Qdisc *sch, u64 rate, bool rate_adjust)
qd->rate_shft = qd->tins[ft].tin_rate_shft;
}
+static void cake_clamp_flow_deficit(struct cake_tin_data *b,
+ struct cake_flow *flow,
+ int flow_mode)
+{
+ s32 quantum;
+
+ if (flow->deficit <= 0)
+ return;
+
+ quantum = cake_get_flow_quantum(b, flow, flow_mode);
+ if (flow->deficit > quantum)
+ WRITE_ONCE(flow->deficit, quantum);
+}
+
+static void cake_clamp_active_deficits(struct cake_sched_data *qd)
+{
+ struct cake_sched_config *q = qd->config;
+ struct cake_flow *flow;
+ u32 tin;
+
+ for (tin = 0; tin < qd->tin_cnt; tin++) {
+ struct cake_tin_data *b = &qd->tins[tin];
+
+ list_for_each_entry(flow, &b->new_flows, flowchain)
+ cake_clamp_flow_deficit(b, flow, q->flow_mode);
+ list_for_each_entry(flow, &b->old_flows, flowchain)
+ cake_clamp_flow_deficit(b, flow, q->flow_mode);
+ }
+}
+
static void cake_reconfigure(struct Qdisc *sch)
{
struct cake_sched_data *qd = qdisc_priv(sch);
@@ -2628,6 +2658,7 @@ static void cake_reconfigure(struct Qdisc *sch)
u32 buffer_limit;
cake_configure_rates(sch, qd->config->rate_bps, false);
+ cake_clamp_active_deficits(qd);
if (q->buffer_config_limit) {
buffer_limit = q->buffer_config_limit;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [Cake] Re: [PATCH] net/sched: cake: clamp active flow deficit on rate changes
2026-06-09 0:08 [Cake] [PATCH] net/sched: cake: clamp active flow deficit on rate changes Samuel Moelius
@ 2026-06-09 1:08 ` Eric Dumazet
2026-06-09 12:16 ` Samuel Moelius
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2026-06-09 1:08 UTC (permalink / raw)
To: Samuel Moelius
Cc: Toke Høiland-Jørgensen, Jamal Hadi Salim, Jiri Pirko,
David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
moderated list:CAKE QDISC, open list:TC subsystem, open list
On Mon, Jun 8, 2026 at 5:08 PM Samuel Moelius
<sam.moelius@trailofbits.com> wrote:
>
> Changing CAKE rate parameters updates the quantum used for future
> scheduling, but active flows can retain deficit computed under the old
> rate.
>
> That stale deficit lets an already active flow receive service based on
> the previous configuration after userspace changes the shaper rate.
>
> After recomputing rate-derived scheduling parameters, clamp positive
> active-flow deficits to the quantum that applies under the new
> configuration.
>
> Assisted-by: Codex:gpt-5.5-cyber-preview
> Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
> ---
This is bloat for a not existent issue.
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cake] Re: [PATCH] net/sched: cake: clamp active flow deficit on rate changes
2026-06-09 1:08 ` [Cake] " Eric Dumazet
@ 2026-06-09 12:16 ` Samuel Moelius
0 siblings, 0 replies; 3+ messages in thread
From: Samuel Moelius @ 2026-06-09 12:16 UTC (permalink / raw)
To: Eric Dumazet
Cc: Toke Høiland-Jørgensen, Jamal Hadi Salim, Jiri Pirko,
David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
moderated list:CAKE QDISC, open list:TC subsystem, open list
On Mon, Jun 8, 2026 at 9:08 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Mon, Jun 8, 2026 at 5:08 PM Samuel Moelius
> <sam.moelius@trailofbits.com> wrote:
> >
> > Changing CAKE rate parameters updates the quantum used for future
> > scheduling, but active flows can retain deficit computed under the old
> > rate.
> >
> > That stale deficit lets an already active flow receive service based on
> > the previous configuration after userspace changes the shaper rate.
> >
> > After recomputing rate-derived scheduling parameters, clamp positive
> > active-flow deficits to the quantum that applies under the new
> > configuration.
> >
> > Assisted-by: Codex:gpt-5.5-cyber-preview
> > Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
> > ---
>
> This is bloat for a not existent issue.
>
> pw-bot: cr
Sorry for misunderstanding, but is this patch rejected?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-09 12:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 0:08 [Cake] [PATCH] net/sched: cake: clamp active flow deficit on rate changes Samuel Moelius
2026-06-09 1:08 ` [Cake] " Eric Dumazet
2026-06-09 12:16 ` Samuel Moelius
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox