aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
authorWillem de Bruijn <willemb@google.com>2026-05-26 09:40:37 -0400
committerJakub Kicinski <kuba@kernel.org>2026-05-27 18:41:19 -0700
commitfabcf8cad67b4e2aa51b4c3f79f26fd215b50c8c (patch)
tree228d5a5c345dbccf7ebae918d88a38c9ae5eb9a0 /net
parent56edbedb74ac8c99ef693a344cb8834885d4bdac (diff)
downloadlinux-next-history-fabcf8cad67b4e2aa51b4c3f79f26fd215b50c8c.tar.gz
net: sch_fq: update flow delivery time on earlier EDT packet
When inserting an EDT packet with time before flow->time_next_packet, update the flow and possibly queue next delivery time. Reinsert the flow into the q->delayed rb-tree to position correctly and to have fq_check_throttled set wake-up at the right next time. Factor RB tree insertion out fq_flow_set_throttled to avoid open coding twice. EDT packets do not take precedence over queue rate limit. Skip this new step if a queue limit is set. EDT packets do take precedence over per-socket rate limits, as can be seen from fq_dequeue reading sk_pacing_rate if !skb->tstamp. With this change the so_txtime selftest sends packets in the expected order. Signed-off-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20260526134109.2624493-1-willemdebruijn.kernel@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/sched/sch_fq.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index 796cb8046a902..33783c9f8e166 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -217,7 +217,7 @@ static void fq_flow_unset_throttled(struct fq_sched_data *q, struct fq_flow *f)
fq_flow_add_tail(q, f, OLD_FLOW);
}
-static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
+static void fq_flow_rb_insert(struct fq_sched_data *q, struct fq_flow *f)
{
struct rb_node **p = &q->delayed.rb_node, *parent = NULL;
@@ -233,14 +233,18 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
}
rb_link_node(&f->rate_node, parent, p);
rb_insert_color(&f->rate_node, &q->delayed);
- q->throttled_flows++;
- q->stat_throttled++;
- f->next = &throttled;
if (q->time_next_delayed_flow > f->time_next_packet)
q->time_next_delayed_flow = f->time_next_packet;
}
+static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
+{
+ fq_flow_rb_insert(q, f);
+ q->throttled_flows++;
+ q->stat_throttled++;
+ f->next = &throttled;
+}
static struct kmem_cache *fq_flow_cachep __read_mostly;
@@ -539,6 +543,24 @@ static bool fq_packet_beyond_horizon(const struct sk_buff *skb,
return unlikely((s64)skb->tstamp > (s64)(now + q->horizon));
}
+static void fq_flow_adjust_timer(struct fq_sched_data *q, struct fq_flow *flow,
+ u64 time_to_send, u64 now)
+{
+ if (time_to_send <= now) {
+ fq_flow_unset_throttled(q, flow);
+ if (q->time_next_delayed_flow == flow->time_next_packet) {
+ struct rb_node *p = rb_first(&q->delayed);
+
+ q->time_next_delayed_flow = p ? rb_entry(p, struct fq_flow, rate_node)->time_next_packet : ~0ULL;
+ }
+ flow->time_next_packet = time_to_send;
+ } else {
+ rb_erase(&flow->rate_node, &q->delayed);
+ flow->time_next_packet = time_to_send;
+ fq_flow_rb_insert(q, flow);
+ }
+}
+
static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free)
{
@@ -596,6 +618,10 @@ static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
/* Note: this overwrites f->age */
flow_queue_add(f, skb);
+ if (fq_skb_cb(skb)->time_to_send < f->time_next_packet && skb->tstamp &&
+ fq_flow_is_throttled(f) && q->flow_max_rate == ~0UL)
+ fq_flow_adjust_timer(q, f, fq_skb_cb(skb)->time_to_send, now);
+
qdisc_qstats_backlog_inc(sch, skb);
qdisc_qlen_inc(sch);