This is a note to let you know that I've just added the patch titled net_sched: sch_fq: properly set sk->sk_pacing_status to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: net_sched-sch_fq-properly-set-sk-sk_pacing_status.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Wed 01 Jan 2020 10:35:31 PM CET From: Eric Dumazet <edumazet@xxxxxxxxxx> Date: Mon, 23 Dec 2019 11:13:24 -0800 Subject: net_sched: sch_fq: properly set sk->sk_pacing_status From: Eric Dumazet <edumazet@xxxxxxxxxx> [ Upstream commit bb3d0b8bf5be61ab1d6f472c43cbf34de17e796b ] 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: 218af599fa63 ("tcp: internal implementation for pacing") Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Soheil Hassas Yeganeh <soheil@xxxxxxxxxx> Cc: Neal Cardwell <ncardwell@xxxxxxxxxx> Acked-by: Soheil Hassas Yeganeh <soheil@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/sched/sch_fq.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) --- a/net/sched/sch_fq.c +++ b/net/sched/sch_fq.c @@ -301,6 +301,9 @@ static struct fq_flow *fq_classify(struc f->socket_hash != sk->sk_hash)) { f->credit = q->initial_quantum; f->socket_hash = sk->sk_hash; + if (q->rate_enable) + smp_store_release(&sk->sk_pacing_status, + SK_PACING_FQ); if (fq_flow_is_throttled(f)) fq_flow_unset_throttled(q, f); f->time_next_packet = 0ULL; @@ -322,8 +325,12 @@ static struct fq_flow *fq_classify(struc fq_flow_set_detached(f); f->sk = sk; - if (skb->sk == sk) + if (skb->sk == sk) { f->socket_hash = sk->sk_hash; + if (q->rate_enable) + smp_store_release(&sk->sk_pacing_status, + SK_PACING_FQ); + } f->credit = q->initial_quantum; rb_link_node(&f->fq_node, parent, p); @@ -428,17 +435,9 @@ static int fq_enqueue(struct sk_buff *sk f->qlen++; qdisc_qstats_backlog_inc(sch, skb); if (fq_flow_is_detached(f)) { - struct sock *sk = skb->sk; - fq_flow_add_tail(&q->new_flows, f); if (time_after(jiffies, f->age + q->flow_refill_delay)) f->credit = max_t(u32, f->credit, q->quantum); - if (sk && q->rate_enable) { - if (unlikely(smp_load_acquire(&sk->sk_pacing_status) != - SK_PACING_FQ)) - smp_store_release(&sk->sk_pacing_status, - SK_PACING_FQ); - } q->inactive_flows--; } Patches currently in stable-queue which might be from edumazet@xxxxxxxxxx are queue-5.4/net_sched-sch_fq-properly-set-sk-sk_pacing_status.patch queue-5.4/net-icmp-fix-data-race-in-cmp_global_allow.patch queue-5.4/dma-debug-add-a-schedule-point-in-debug_dma_dump_map.patch queue-5.4/tcp-dccp-fix-possible-race-__inet_lookup_established.patch queue-5.4/net-add-a-read_once-in-skb_peek_tail.patch queue-5.4/inetpeer-fix-data-race-in-inet_putpeer-inet_putpeer.patch queue-5.4/tcp-do-not-send-empty-skb-from-tcp_write_xmit.patch queue-5.4/netfilter-bridge-make-sure-to-pull-arp-header-in-br_nf_forward_arp.patch queue-5.4/6pack-mkiss-fix-possible-deadlock.patch queue-5.4/tcp-fix-highest_sack-and-highest_sack_seq.patch queue-5.4/hrtimer-annotate-lockless-access-to-timer-state.patch