Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <edumazet@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Cong Wang and committed by
David S. Miller
b362487a f452825d

+6 -3
+6 -3
net/sched/sch_htb.c
··· 165 165 166 166 /* non shaped skbs; let them go directly thru */ 167 167 struct qdisc_skb_head direct_queue; 168 - long direct_pkts; 168 + u32 direct_pkts; 169 + u32 overlimits; 169 170 170 171 struct qdisc_watchdog watchdog; 171 172 ··· 534 533 if (new_mode == cl->cmode) 535 534 return; 536 535 537 - if (new_mode == HTB_CANT_SEND) 536 + if (new_mode == HTB_CANT_SEND) { 538 537 cl->overlimits++; 538 + q->overlimits++; 539 + } 539 540 540 541 if (cl->prio_activity) { /* not necessary: speed optimization */ 541 542 if (cl->cmode != HTB_CANT_SEND) ··· 940 937 goto ok; 941 938 } 942 939 } 943 - qdisc_qstats_overlimit(sch); 944 940 if (likely(next_event > q->now)) 945 941 qdisc_watchdog_schedule_ns(&q->watchdog, next_event); 946 942 else ··· 1050 1048 struct nlattr *nest; 1051 1049 struct tc_htb_glob gopt; 1052 1050 1051 + sch->qstats.overlimits = q->overlimits; 1053 1052 /* Its safe to not acquire qdisc lock. As we hold RTNL, 1054 1053 * no change can happen on the qdisc parameters. 1055 1054 */