net/sched: sch_drr: lockless cl->deficit and cl->quantum
Subsystems (3)
cover net/sched: sch_drr: lockless cl->deficit and cl->quantum
First patch adds missing annotations around cl->deficit.
Second patch makes cl->quantum lockless, to prepare future lockless qdisc dumps.
Eric Dumazet (2):
net/sched: sch_drr: annotate data-races around cl->deficit net/sched: sch_drr: make cl->quantum lockless
net/sched/sch_drr.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
PATCH 1/2 net/sched: sch_drr: annotate data-races around cl->deficit
drr_dump_class_stats() runs without qdisc spinlock held.
Add missing READ_ONCE()/WRITE_ONCE() annotations around cl->deficit.
--- net/sched/sch_drr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/sched/sch_drr.c +4 -4
@@ -270,7 +270,7 @@ static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg,memset (&xstats,0 ,sizeof (xstats));if (qlen) - xstats.deficit = cl->deficit; + xstats.deficit =READ_ONCE (cl->deficit); if (gnet_stats_copy_basic(d, NULL, &cl->bstats, true) < 0 || gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
@@ -362,7 +362,7 @@ static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (!cl_is_active (cl)) {list_add_tail (&cl->alist, &q->active); - cl->deficit = cl->quantum; +WRITE_ONCE (cl->deficit, cl->quantum); }qstats_backlog_add (sch, len);
@@ -389,7 +389,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch) len =qdisc_pkt_len (skb);if (len <= cl->deficit) { - cl->deficit -= len; +WRITE_ONCE (cl->deficit, cl->deficit - len); skb =qdisc_dequeue_peeked (cl->qdisc);if (unlikely (skb ==NULL )) goto out;
@@ -403,7 +403,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)return skb; } - cl->deficit += cl->quantum; +WRITE_ONCE (cl->deficit, cl->deficit + cl->quantum);list_move_tail (&cl->alist, &q->active); } out:
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
PATCH 2/2 net/sched: sch_drr: make cl->quantum lockless
In reply to Eric Dumazetcl->quantum does not need to be protected by RTNL or qdisc spinlock.
--- net/sched/sch_drr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
net/sched/sch_drr.c +4 -6
@@ -97,10 +97,8 @@ static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, } } -sch_tree_lock (sch);if (tb[TCA_DRR_QUANTUM ]) - cl->quantum = quantum; -sch_tree_unlock (sch); +WRITE_ONCE (cl->quantum, quantum);return 0 ; }
@@ -251,7 +249,7 @@ static int drr_dump_class(struct Qdisc *sch, unsigned long arg, nest =nla_nest_start_noflag (skb,TCA_OPTIONS );if (nest ==NULL ) goto nla_put_failure; -if (nla_put_u32 (skb,TCA_DRR_QUANTUM , cl->quantum)) +if (nla_put_u32 (skb,TCA_DRR_QUANTUM ,READ_ONCE (cl->quantum))) goto nla_put_failure;return nla_nest_end (skb, nest);
@@ -362,7 +360,7 @@ static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (!cl_is_active (cl)) {list_add_tail (&cl->alist, &q->active); -WRITE_ONCE (cl->deficit, cl->quantum); +WRITE_ONCE (cl->deficit,READ_ONCE (cl->quantum)); }qstats_backlog_add (sch, len);
@@ -403,7 +401,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)return skb; } -WRITE_ONCE (cl->deficit, cl->deficit + cl->quantum); +WRITE_ONCE (cl->deficit, cl->deficit +READ_ONCE (cl->quantum));list_move_tail (&cl->alist, &q->active); } out:
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 19 May 2026 09:46:16 +0000 you wrote:
First patch adds missing annotations around
cl->deficit.Second patch makes
cl->quantumlockless, to prepare future lockless qdisc dumps.Eric Dumazet (2):
net/sched:sch_drr: annotate data-races aroundcl->deficitnet/sched:sch_drr: makecl->quantumlockless[...]
Here is the summary with links:
- [net-next,1/2] net/sched: sch_drr: annotate data-races around cl->deficit
https://git.kernel.org/netdev/net-next/c/c67b104fd798 - [net-next,2/2] net/sched: sch_drr: make cl->quantum lockless https://git.kernel.org/netdev/net-next/c/a4d880b85089
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html