]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/sched: sch_drr: make cl->quantum lockless
authorEric Dumazet <edumazet@google.com>
Tue, 19 May 2026 09:46:18 +0000 (09:46 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 May 2026 02:04:58 +0000 (19:04 -0700)
cl->quantum does not need to be protected by RTNL or qdisc spinlock.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260519094618.2632073-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/sched/sch_drr.c

index 7da8c7c8421b7f2477c7c07d3b5920b375ce029e..020657f959b575667f7a4b4d6aacd05c03c654a0 100644 (file)
@@ -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: