Skip to contentSkip to conversation

net: sched: fix wrong class stats dumping in sch_mqprio

PATCH In review Dust Li 2 participants 3 messages Nov 28, 2019 – Dec 2, 2019

Subsystems (3)
lore
Share & tools
lore

Dust Li

author
#0 lore raw

PATCH 1/1 net: sched: fix wrong class stats dumping in sch_mqprio

Actually, the stack variables bstats and qstats in mqprio_dump_class_stats() are not really used. As a result, 'tc -s class show' for the mqprio class always return 0 for both bstats and qstats. Use them to store the child qdisc's stats and add them up as the stats for the mqprio class.

Fixes ce679e8df7ed ("net: sched: add support for TCQ_F_NOLOCK subqueues to sch_mqprio")
---
 net/sched/sch_mqprio.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
net/sched/sch_mqprio.c +16 -7
index 6887084bd5ad..0a931d17a7df 100644
@@ -511,8 +511,8 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
 	if (cl >= TC_H_MIN_PRIORITY) {
 		int i;
 		__u32 qlen = 0;
-		struct gnet_stats_queue qstats = {0};
-		struct gnet_stats_basic_packed bstats = {0};
+		struct gnet_stats_queue tqstats = {0};
+		struct gnet_stats_basic_packed tbstats = {0};
 		struct net_device *dev = qdisc_dev(sch);
 		struct netdev_tc_txq tc = dev->tc_to_txq[cl & TC_BITMASK];
 
@@ -529,6 +529,8 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
 			struct Qdisc *qdisc = rtnl_dereference(q->qdisc);
 			struct gnet_stats_basic_cpu __percpu *cpu_bstats = NULL;
 			struct gnet_stats_queue __percpu *cpu_qstats = NULL;
+			struct gnet_stats_queue qstats = {0};
+			struct gnet_stats_basic_packed bstats = {0};
 
 			spin_lock_bh(qdisc_lock(qdisc));
 			if (qdisc_is_percpu_stats(qdisc)) {
@@ -536,21 +538,28 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
 				cpu_qstats = qdisc->cpu_qstats;
 			}
 
-			qlen = qdisc_qlen_sum(qdisc);
-			__gnet_stats_copy_basic(NULL, &sch->bstats,
+			qlen += qdisc_qlen_sum(qdisc);
+			__gnet_stats_copy_basic(NULL, &bstats,
 						cpu_bstats, &qdisc->bstats);
-			__gnet_stats_copy_queue(&sch->qstats,
+			__gnet_stats_copy_queue(&qstats,
 						cpu_qstats,
 						&qdisc->qstats,
 						qlen);
 			spin_unlock_bh(qdisc_lock(qdisc));
+
+			tbstats.bytes		+= bstats.bytes;
+			tbstats.packets		+= bstats.packets;
+			tqstats.backlog		+= qstats.backlog;
+			tqstats.drops		+= qstats.drops;
+			tqstats.requeues	+= qstats.requeues;
+			tqstats.overlimits	+= qstats.overlimits;
 		}
 
 		/* Reclaim root sleeping lock before completing stats */
 		if (d->lock)
 			spin_lock_bh(d->lock);
-		if (gnet_stats_copy_basic(NULL, d, NULL, &bstats) < 0 ||
-		    gnet_stats_copy_queue(d, NULL, &qstats, qlen) < 0)
+		if (gnet_stats_copy_basic(NULL, d, NULL, &tbstats) < 0 ||
+		    gnet_stats_copy_queue(d, NULL, &tqstats, qlen) < 0)
 			return -1;
 	} else {
 		struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
Signature · 1 line
2.19.1.3.ge56e4f7
#1 lore raw
Quoted 6 lines · Dust Li

Actually, the stack variables bstats and qstats in mqprio_dump_class_stats() are not really used. As a result, 'tc -s class show' for the mqprio class always return 0 for both bstats and qstats. Use them to store the child qdisc's stats and add them up as the stats for the mqprio class.

This patch is on top of the previous one you sent, so please group and number them as "Patch X/N", otherwise it is confusing.

Thanks.

author
#2 lore raw
Quoted 10 lines · Cong Wang
Quoted 5 lines · Dust Li

Actually, the stack variables bstats and qstats in mqprio_dump_class_stats() are not really used. As a result, 'tc -s class show' for the mqprio class always return 0 for both bstats and qstats. Use them to store the child qdisc's stats and add them up as the stats for the mqprio class.

This patch is on top of the previous one you sent, so please group and number them as "Patch X/N", otherwise it is confusing.

Thanks.

OK, Thanks for your kind advice, I'll group them and re-send.

Thanks.

Dust Li