diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 391ee8530017..0edf05d56862 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -542,6 +542,11 @@ static inline int qdisc_qlen(const struct Qdisc *q) return q->q.qlen; } +static inline int qdisc_qlen_lockless(const struct Qdisc *q) +{ + return READ_ONCE(q->q.qlen); +} + static inline void qdisc_qlen_inc(struct Qdisc *q) { WRITE_ONCE(q->q.qlen, q->q.qlen + 1); @@ -561,7 +566,7 @@ static inline int qdisc_qlen_sum(const struct Qdisc *q) for_each_possible_cpu(i) qlen += READ_ONCE(per_cpu_ptr(q->cpu_qstats, i)->qlen); } else { - qlen += READ_ONCE(q->q.qlen); + qlen += qdisc_qlen_lockless(q); } return qlen; diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c index ec8c91d3fde0..4172ec24a43d 100644 --- a/net/sched/sch_mq.c +++ b/net/sched/sch_mq.c @@ -163,7 +163,7 @@ void mq_dump_common(struct Qdisc *sch, struct sk_buff *skb) &qdisc->bstats, false); gnet_stats_add_queue(&sch->qstats, qdisc->cpu_qstats, &qdisc->qstats); - qlen += qdisc_qlen(qdisc); + qlen += qdisc_qlen_lockless(qdisc); spin_unlock_bh(qdisc_lock(qdisc)); } diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 91a92992cd24..3b4881c389c5 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -576,7 +576,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) &qdisc->bstats, false); gnet_stats_add_queue(&sch->qstats, qdisc->cpu_qstats, &qdisc->qstats); - qlen += qdisc_qlen(qdisc); + qlen += qdisc_qlen_lockless(qdisc); spin_unlock_bh(qdisc_lock(qdisc)); } @@ -691,7 +691,7 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl, &qdisc->bstats, false); gnet_stats_add_queue(&qstats, qdisc->cpu_qstats, &qdisc->qstats); - qlen += qdisc_qlen(qdisc); + qlen += qdisc_qlen_lockless(qdisc); spin_unlock_bh(qdisc_lock(qdisc)); }