net_sched: sch_hhf: annotate data-races in hhf_dump_stats()
Subsystems (3)
PATCH 1/1 net_sched: sch_hhf: annotate data-races in hhf_dump_stats()
hhf_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path.
Add READ_ONCE()/WRITE_ONCE() annotations.
Fixes edb09eb17ed8 ("net: sched: do not acquire qdisc spinlock in qdisc/class stats dump")
Signed-off-by Eric Dumazet <[email protected]>
Reviewed-by Jamal Hadi Salim <[email protected]>
--- net/sched/sch_hhf.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
net/sched/sch_hhf.c +10 -9
@@ -198,7 +198,8 @@ static struct hh_flow_state *seek_list(const u32 hash,return NULL ;list_del (&flow->flowchain);kfree (flow); - q->hh_flows_current_cnt--; +WRITE_ONCE (q->hh_flows_current_cnt, + q->hh_flows_current_cnt -1 ); }else if (flow->hash_id == hash) {return flow; }
@@ -226,7 +227,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head, }if (q->hh_flows_current_cnt >= q->hh_flows_limit) { - q->hh_flows_overlimit++; +WRITE_ONCE (q->hh_flows_overlimit, q->hh_flows_overlimit +1 );return NULL ; }/* Create new entry. */
@@ -234,7 +235,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head,if (!flow)return NULL ; - q->hh_flows_current_cnt++; +WRITE_ONCE (q->hh_flows_current_cnt, q->hh_flows_current_cnt +1 );INIT_LIST_HEAD (&flow->flowchain);list_add_tail (&flow->flowchain, head);
@@ -309,7 +310,7 @@ static enum wdrr_bucket_idx hhf_classify(struct sk_buff *skb, struct Qdisc *sch)return WDRR_BUCKET_FOR_NON_HH ; flow->hash_id = hash; flow->hit_timestamp = now; - q->hh_flows_total_cnt++; +WRITE_ONCE (q->hh_flows_total_cnt, q->hh_flows_total_cnt +1 );/* By returning without updating counters in q->hhf_arrays, * we implicitly implement "shielding" (see Optimization O1).
@@ -403,7 +404,7 @@ static int hhf_enqueue(struct sk_buff *skb, struct Qdisc *sch,return NET_XMIT_SUCCESS ; prev_backlog = sch->qstats.backlog; - q->drop_overlimit++; +WRITE_ONCE (q->drop_overlimit, q->drop_overlimit +1 );/* Return Congestion Notification only if we dropped a packet from this * bucket. */
@@ -686,10 +687,10 @@ static int hhf_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct hhf_sched_data *q =qdisc_priv (sch);struct tc_hhf_xstats st = { - .drop_overlimit = q->drop_overlimit, - .hh_overlimit = q->hh_flows_overlimit, - .hh_tot_count = q->hh_flows_total_cnt, - .hh_cur_count = q->hh_flows_current_cnt, + .drop_overlimit =READ_ONCE (q->drop_overlimit), + .hh_overlimit =READ_ONCE (q->hh_flows_overlimit), + .hh_tot_count =READ_ONCE (q->hh_flows_total_cnt), + .hh_cur_count =READ_ONCE (q->hh_flows_current_cnt), };return gnet_stats_copy_app (d, &st,sizeof (st));
Signature · 1 line
2.54.0.rc2.533.g4f5dca5207-goog
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 21 Apr 2026 14:33:49 +0000 you wrote:
hhf_dump_stats()only runs with RTNL held, reading fields that can be changed in qdisc fast path.Add READ_ONCE()/WRITE_ONCE() annotations.
Fixes edb09eb17ed8 ("net: sched: do not acquire qdisc spinlock in qdisc/class stats dump")Signed-off-by Eric Dumazet <[email protected]>Reviewed-by Jamal Hadi Salim <[email protected]>[...]
Here is the summary with links:
- [net] net_sched: sch_hhf: annotate data-races in hhf_dump_stats()
https://git.kernel.org/netdev/net/c/a6edf2cd4156
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html