net/sched: changes around qdisc_qstats_qlen_backlog()
Subsystems (4)
cover net/sched: changes around qdisc_qstats_qlen_backlog()
First patch makes clear qdisc_qstats_qlen_backlog() runs locklessly.
Second patch changes ioam6 to not acquire qdisc spinlock anymore.
Third pach adds missing READ_ONCE()/WRITE_ONCE() annotations in hfsc.
htb still needs fixes, I will take care of them separately.
Eric Dumazet (3):
net/sched: qdisc_qstats_qlen_backlog() runs locklessly
net: ioam6: no longer acquire qdisc spinlock while calling
qdisc_qstats_qlen_backlog()
net/sched: sch_hfsc: annotate data-races in hfsc_dump_class_stats()
include/net/sch_generic.h | 6 +++--- net/ipv6/ioam6.c | 4 +--- net/sched/sch_hfsc.c | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
PATCH 1/3 net/sched: qdisc_qstats_qlen_backlog() runs locklessly
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).
--- include/net/sch_generic.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/net/sch_generic.h +3 -3
@@ -1070,13 +1070,13 @@ static inline int qdisc_qstats_copy(struct gnet_dump *d, const struct Qdisc *schreturn 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; }
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
PATCH 2/3 net: ioam6: no longer acquire qdisc spinlock while calling qdisc_qstats_qlen_backlog()
In reply to Eric DumazetRecent changes in qdisc_qstats_qlen_backlog() and friends make it safe to use locklessly.
--- net/ipv6/ioam6.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv6/ioam6.c +1 -3
@@ -800,7 +800,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,/* queue depth */ if (trace->type.bit6) {struct netdev_queue *queue; -struct Qdisc *qdisc; +const struct Qdisc *qdisc;__u32 qlen, backlog; if (dev->flags & IFF_LOOPBACK ||
@@ -810,9 +810,7 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb, queue =skb_get_tx_queue (dev, skb); qdisc =rcu_dereference (queue->qdisc); -spin_lock_bh (qdisc_lock (qdisc));qdisc_qstats_qlen_backlog (qdisc, &qlen, &backlog); -spin_unlock_bh (qdisc_lock (qdisc)); *(__be32 *)data =cpu_to_be32 (backlog); }
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
PATCH 3/3 net/sched: sch_hfsc: annotate data-races in hfsc_dump_class_stats()
In reply to Eric Dumazethfsc_dump_class_stats() runs without qdisc spinlock being held.
Add READ_ONCE()/WRITE_ONCE() annotations around:
- cl->level
- cl->cl_vtperiod
- cl->cl_total
- cl->cl_cumul
--- net/sched/sch_hfsc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/sched/sch_hfsc.c +11 -11
@@ -715,7 +715,7 @@ init_vf(struct hfsc_class *cl, unsigned int len)rtsc_min (&cl->cl_virtual, &cl->cl_fsc, cl->cl_vt, cl->cl_total); cl->cl_vtadj =0 ; - cl->cl_vtperiod++;/* increment vt period */ +WRITE_ONCE (cl->cl_vtperiod, cl->cl_vtperiod +1 );/* increment vt period */ cl->cl_parentperiod = cl->cl_parent->cl_vtperiod;if (cl->cl_parent->cl_nactive ==0 ) cl->cl_parentperiod++;
@@ -757,7 +757,7 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time) go_passive =1 ;for (; cl->cl_parent !=NULL ; cl = cl->cl_parent) { - cl->cl_total += len; +WRITE_ONCE (cl->cl_total, cl->cl_total + len);if (!(cl->cl_flags &HFSC_FSC ) || cl->cl_nactive ==0 )continue ;
@@ -847,7 +847,7 @@ hfsc_adjust_levels(struct hfsc_class *cl)if (p->level >= level) level = p->level +1 ; } - cl->level = level; +WRITE_ONCE (cl->level, level); }while ((cl = cl->cl_parent) !=NULL ); }
@@ -1338,10 +1338,10 @@ hfsc_dump_class_stats(struct Qdisc *sch, unsigned long arg,__u32 qlen;qdisc_qstats_qlen_backlog (cl->qdisc, &qlen, &cl->qstats.backlog); - xstats.level = cl->level; - xstats.period = cl->cl_vtperiod; - xstats.work = cl->cl_total; - xstats.rtwork = cl->cl_cumul; + xstats.level =READ_ONCE (cl->level); + xstats.period =READ_ONCE (cl->cl_vtperiod); + xstats.work =READ_ONCE (cl->cl_total); + xstats.rtwork =READ_ONCE (cl->cl_cumul); if (gnet_stats_copy_basic(d, NULL, &cl->bstats, true) < 0 || gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
@@ -1452,15 +1452,15 @@ hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt,static void hfsc_reset_class (struct hfsc_class *cl) { - cl->cl_total =0 ; - cl->cl_cumul =0 ; +WRITE_ONCE (cl->cl_total,0 ); +WRITE_ONCE (cl->cl_cumul,0 ); cl->cl_d =0 ; cl->cl_e =0 ; cl->cl_vt =0 ; cl->cl_vtadj =0 ; cl->cl_cvtmin =0 ; cl->cl_cvtoff =0 ; - cl->cl_vtperiod =0 ; +WRITE_ONCE (cl->cl_vtperiod,0 ); cl->cl_parentperiod =0 ; cl->cl_f =0 ; cl->cl_myf =0 ;
@@ -1626,7 +1626,7 @@ hfsc_dequeue(struct Qdisc *sch)bstats_update (&cl->bstats, skb);update_vf (cl,qdisc_pkt_len (skb), cur_time);if (realtime) - cl->cl_cumul +=qdisc_pkt_len (skb); +WRITE_ONCE (cl->cl_cumul, cl->cl_cumul +qdisc_pkt_len (skb));if (cl->cl_flags &HFSC_RSC ) {if (cl->qdisc->q.qlen !=0 ) {
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
Quoted 14 lines · Eric Dumazet
First patch makes clear
qdisc_qstats_qlen_backlog()runs locklessly.Second patch changes ioam6 to not acquire qdisc spinlock anymore.
Third pach adds missing READ_ONCE()/WRITE_ONCE() annotations in hfsc.
htb still needs fixes, I will take care of them separately.
Eric Dumazet (3):
net/sched:qdisc_qstats_qlen_backlog()runs locklessly
net: ioam6: no longer acquire qdisc spinlock while calling
qdisc_qstats_qlen_backlog()
net/sched:sch_hfsc: annotate data-races inhfsc_dump_class_stats()
Quoted 4 lines
include/net/sch_generic.h | 6 +++--- net/ipv6/ioam6.c | 4 +--- net/sched/sch_hfsc.c | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-)
For the series:
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 9 lines · On Wed, 13 May 2026 08:08:50 +0000 you wrote:
First patch makes clear
qdisc_qstats_qlen_backlog()runs locklessly.Second patch changes ioam6 to not acquire qdisc spinlock anymore.
Third pach adds missing READ_ONCE()/WRITE_ONCE() annotations in hfsc.
htb still needs fixes, I will take care of them separately.
[...]
Here is the summary with links:
- [net-next,1/3] net/sched: qdisc_qstats_qlen_backlog() runs locklessly
https://git.kernel.org/netdev/net-next/c/72a1795999df - [net-next,2/3] net: ioam6: no longer acquire qdisc spinlock while calling qdisc_qstats_qlen_backlog() https://git.kernel.org/netdev/net-next/c/d3f3c8a4d1f6 - [net-next,3/3] net/sched: sch_hfsc: annotate data-races in hfsc_dump_class_stats() https://git.kernel.org/netdev/net-next/c/e300c7d470ad
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html