Skip to content

Commit 339346d

Browse files
committed
net: sched: gred: prevent races when adding offloads to stats
Naresh reports seeing a warning that gred is calling u64_stats_update_begin() with preemption enabled. Arnd points out it's coming from _bstats_update(). We should be holding the qdisc lock when writing to stats, they are also updated from the datapath. Reported-by: Linux Kernel Functional Testing <[email protected]> Link: https://lore.kernel.org/all/CA+G9fYsTr9_r893+62u6UGD3dVaCE-kN9C-Apmb2m=hxjc1Cqg@mail.gmail.com/ Fixes: e49efd5 ("net: sched: gred: support reporting stats from offloads") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent edb5b63 commit 339346d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/sched/sch_gred.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch)
377377
/* Even if driver returns failure adjust the stats - in case offload
378378
* ended but driver still wants to adjust the values.
379379
*/
380+
sch_tree_lock(sch);
380381
for (i = 0; i < MAX_DPs; i++) {
381382
if (!table->tab[i])
382383
continue;
@@ -393,6 +394,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch)
393394
sch->qstats.overlimits += hw_stats->stats.qstats[i].overlimits;
394395
}
395396
_bstats_update(&sch->bstats, bytes, packets);
397+
sch_tree_unlock(sch);
396398

397399
kfree(hw_stats);
398400
return ret;

0 commit comments

Comments
 (0)