Skip to content

Commit bb3d0b8

Browse files
edumazetdavem330
authored andcommitted
net_sched: sch_fq: properly set sk->sk_pacing_status
If fq_classify() recycles a struct fq_flow because a socket structure has been reallocated, we do not set sk->sk_pacing_status immediately, but later if the flow becomes detached. This means that any flow requiring pacing (BBR, or SO_MAX_PACING_RATE) might fallback to TCP internal pacing, which requires a per-socket high resolution timer, and therefore more cpu cycles. Fixes: 218af59 ("tcp: internal implementation for pacing") Signed-off-by: Eric Dumazet <[email protected]> Cc: Soheil Hassas Yeganeh <[email protected]> Cc: Neal Cardwell <[email protected]> Acked-by: Soheil Hassas Yeganeh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e55a11 commit bb3d0b8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

net/sched/sch_fq.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
301301
f->socket_hash != sk->sk_hash)) {
302302
f->credit = q->initial_quantum;
303303
f->socket_hash = sk->sk_hash;
304+
if (q->rate_enable)
305+
smp_store_release(&sk->sk_pacing_status,
306+
SK_PACING_FQ);
304307
if (fq_flow_is_throttled(f))
305308
fq_flow_unset_throttled(q, f);
306309
f->time_next_packet = 0ULL;
@@ -322,8 +325,12 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
322325

323326
fq_flow_set_detached(f);
324327
f->sk = sk;
325-
if (skb->sk == sk)
328+
if (skb->sk == sk) {
326329
f->socket_hash = sk->sk_hash;
330+
if (q->rate_enable)
331+
smp_store_release(&sk->sk_pacing_status,
332+
SK_PACING_FQ);
333+
}
327334
f->credit = q->initial_quantum;
328335

329336
rb_link_node(&f->fq_node, parent, p);
@@ -428,17 +435,9 @@ static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
428435
f->qlen++;
429436
qdisc_qstats_backlog_inc(sch, skb);
430437
if (fq_flow_is_detached(f)) {
431-
struct sock *sk = skb->sk;
432-
433438
fq_flow_add_tail(&q->new_flows, f);
434439
if (time_after(jiffies, f->age + q->flow_refill_delay))
435440
f->credit = max_t(u32, f->credit, q->quantum);
436-
if (sk && q->rate_enable) {
437-
if (unlikely(smp_load_acquire(&sk->sk_pacing_status) !=
438-
SK_PACING_FQ))
439-
smp_store_release(&sk->sk_pacing_status,
440-
SK_PACING_FQ);
441-
}
442441
q->inactive_flows--;
443442
}
444443

0 commit comments

Comments
 (0)