]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/sched: qdisc_qstats_qlen_backlog() runs locklessly
authorEric Dumazet <edumazet@google.com>
Wed, 13 May 2026 08:08:51 +0000 (08:08 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 May 2026 00:05:20 +0000 (17:05 -0700)
qdisc_qstats_qlen_backlog() can be called without qdisc spinlock being held.

Use qdisc_qlen_lockless() instead of qdisc_qlen().

Add a const qualifier to its first parameter (struct Qdisc *sch).

Fixes: edb09eb17ed8 ("net: sched: do not acquire qdisc spinlock in qdisc/class stats dump")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://patch.msgid.link/20260513080853.1383975-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/sch_generic.h

index 9e6ed92729d282642e17a72cc578f25e1d22e4d9..d0ca932b1871c086f0ba7aad11241742bba0a9d8 100644 (file)
@@ -1070,13 +1070,13 @@ static inline int qdisc_qstats_copy(struct gnet_dump *d, const struct Qdisc *sch
        return gnet_stats_copy_queue(d, sch->cpu_qstats, &sch->qstats, qlen);
 }
 
-static inline void qdisc_qstats_qlen_backlog(struct Qdisc *sch,  __u32 *qlen,
-                                            __u32 *backlog)
+static inline void qdisc_qstats_qlen_backlog(const struct Qdisc *sch,
+                                            u32 *qlen, u32 *backlog)
 {
        struct gnet_stats_queue qstats = { 0 };
 
        gnet_stats_add_queue(&qstats, sch->cpu_qstats, &sch->qstats);
-       *qlen = qstats.qlen + qdisc_qlen(sch);
+       *qlen = qstats.qlen + qdisc_qlen_lockless(sch);
        *backlog = qstats.backlog;
 }