Commit 339346d4 authored by Jakub Kicinski's avatar Jakub Kicinski

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: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
Link: https://lore.kernel.org/all/CA+G9fYsTr9_r893+62u6UGD3dVaCE-kN9C-Apmb2m=hxjc1Cqg@mail.gmail.com/
Fixes: e49efd52 ("net: sched: gred: support reporting stats from offloads")
Link: https://lore.kernel.org/r/20230113044137.1383067-1-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent edb5b63e
...@@ -377,6 +377,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch) ...@@ -377,6 +377,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch)
/* Even if driver returns failure adjust the stats - in case offload /* Even if driver returns failure adjust the stats - in case offload
* ended but driver still wants to adjust the values. * ended but driver still wants to adjust the values.
*/ */
sch_tree_lock(sch);
for (i = 0; i < MAX_DPs; i++) { for (i = 0; i < MAX_DPs; i++) {
if (!table->tab[i]) if (!table->tab[i])
continue; continue;
...@@ -393,6 +394,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch) ...@@ -393,6 +394,7 @@ static int gred_offload_dump_stats(struct Qdisc *sch)
sch->qstats.overlimits += hw_stats->stats.qstats[i].overlimits; sch->qstats.overlimits += hw_stats->stats.qstats[i].overlimits;
} }
_bstats_update(&sch->bstats, bytes, packets); _bstats_update(&sch->bstats, bytes, packets);
sch_tree_unlock(sch);
kfree(hw_stats); kfree(hw_stats);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment