Skip to contentSkip to conversation

sch_htb: redefine htb qdisc overlimits

PATCH Applied Cong Wang 3 participants 3 messages May 4, 2019 – May 6, 2019

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 sch_htb: redefine htb qdisc overlimits

In commit 3c75f6ee139d ("net_sched: sch_htb: add per class overlimits counter") we added an overlimits counter for each HTB class which could properly reflect how many times we use up all the bandwidth
on each class. However, the overlimits counter in HTB qdisc
does not, it is way bigger than the sum of each HTB class.
In fact, this qdisc overlimits counter increases when we have
no skb to dequeue, which happens more often than we run out of bandwidth.

It makes more sense to make this qdisc overlimits counter just be a sum of each HTB class, in case people still get confused.

I have verified this patch with one single HTB class, where HTB qdisc counters now always match HTB class counters as expected.

Eric suggested we could fold this field into 'direct_pkts' as we only use its 32bit on 64bit CPU, this saves one cache line.

Cc Eric Dumazet <[email protected]>
---
 net/sched/sch_htb.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/sched/sch_htb.c +6 -3
index d27d9bc9d010..909370049fca 100644
@@ -165,7 +165,8 @@ struct htb_sched {
 
 	/* non shaped skbs; let them go directly thru */
 	struct qdisc_skb_head	direct_queue;
-	long			direct_pkts;
+	u32			direct_pkts;
+	u32			overlimits;
 
 	struct qdisc_watchdog	watchdog;
 
@@ -533,8 +534,10 @@ htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, s64 *diff)
 	if (new_mode == cl->cmode)
 		return;
 
-	if (new_mode == HTB_CANT_SEND)
+	if (new_mode == HTB_CANT_SEND) {
 		cl->overlimits++;
+		q->overlimits++;
+	}
 
 	if (cl->prio_activity) {	/* not necessary: speed optimization */
 		if (cl->cmode != HTB_CANT_SEND)
@@ -937,7 +940,6 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch)
 				goto ok;
 		}
 	}
-	qdisc_qstats_overlimit(sch);
 	if (likely(next_event > q->now))
 		qdisc_watchdog_schedule_ns(&q->watchdog, next_event);
 	else
@@ -1048,6 +1050,7 @@ static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
 	struct nlattr *nest;
 	struct tc_htb_glob gopt;
 
+	sch->qstats.overlimits = q->overlimits;
 	/* Its safe to not acquire qdisc lock. As we hold RTNL,
 	 * no change can happen on the qdisc parameters.
 	 */
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Cong Wang

In commit 3c75f6ee139d ("net_sched: sch_htb: add per class overlimits counter") we added an overlimits counter for each HTB class which could properly reflect how many times we use up all the bandwidth
on each class. However, the overlimits counter in HTB qdisc
does not, it is way bigger than the sum of each HTB class.
In fact, this qdisc overlimits counter increases when we have
no skb to dequeue, which happens more often than we run out of bandwidth.

It makes more sense to make this qdisc overlimits counter just be a sum of each HTB class, in case people still get confused.

I have verified this patch with one single HTB class, where HTB qdisc counters now always match HTB class counters as expected.

Quoted 6 lines

Eric suggested we could fold this field into 'direct_pkts' as we only use its 32bit on 64bit CPU, this saves one cache line.

Cc Eric Dumazet <[email protected]>

---

Thanks !

maintainer Applied
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Sat, 4 May 2019 11:43:42 -0700

Quoted 12 lines

In commit 3c75f6ee139d ("net_sched: sch_htb: add per class overlimits counter") we added an overlimits counter for each HTB class which could properly reflect how many times we use up all the bandwidth
on each class. However, the overlimits counter in HTB qdisc
does not, it is way bigger than the sum of each HTB class.
In fact, this qdisc overlimits counter increases when we have
no skb to dequeue, which happens more often than we run out of bandwidth.

It makes more sense to make this qdisc overlimits counter just be a sum of each HTB class, in case people still get confused.

Quoted 8 lines

I have verified this patch with one single HTB class, where HTB qdisc counters now always match HTB class counters as expected.

Eric suggested we could fold this field into 'direct_pkts' as we only use its 32bit on 64bit CPU, this saves one cache line.

Cc Eric Dumazet <[email protected]>

Applied.