Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] net: sched: fix wrong class stats dumping in sch_mqprio
@ 2019-11-28  6:31 Dust Li
  2019-11-30  5:48 ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Dust Li @ 2019-11-28  6:31 UTC (permalink / raw)
  To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, John Fastabend; +Cc: Tony Lu, netdev

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")
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
---
 net/sched/sch_mqprio.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 6887084bd5ad..0a931d17a7df 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -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);
-- 
2.19.1.3.ge56e4f7


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sched: fix wrong class stats dumping in sch_mqprio
  2019-11-28  6:31 [PATCH] net: sched: fix wrong class stats dumping in sch_mqprio Dust Li
@ 2019-11-30  5:48 ` Cong Wang
  2019-12-02 11:18   ` Dust Li
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2019-11-30  5:48 UTC (permalink / raw)
  To: Dust Li
  Cc: Jamal Hadi Salim, Jiri Pirko, John Fastabend, Tony Lu,
	Linux Kernel Network Developers

On Wed, Nov 27, 2019 at 10:31 PM Dust Li <dust.li@linux.alibaba.com> wrote:
>
> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sched: fix wrong class stats dumping in sch_mqprio
  2019-11-30  5:48 ` Cong Wang
@ 2019-12-02 11:18   ` Dust Li
  0 siblings, 0 replies; 3+ messages in thread
From: Dust Li @ 2019-12-02 11:18 UTC (permalink / raw)
  To: Cong Wang
  Cc: Jamal Hadi Salim, Jiri Pirko, John Fastabend, Tony Lu,
	Linux Kernel Network Developers


On 11/30/19 1:48 PM, Cong Wang wrote:
> On Wed, Nov 27, 2019 at 10:31 PM Dust Li <dust.li@linux.alibaba.com> wrote:
>> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  6:31 [PATCH] net: sched: fix wrong class stats dumping in sch_mqprio Dust Li
2019-11-30  5:48 ` Cong Wang
2019-12-02 11:18   ` Dust Li

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git