sch_htb: redefine htb qdisc overlimits
Subsystems (3)
PATCH 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.
--- net/sched/sch_htb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/sched/sch_htb.c +5 -2
@@ -177,6 +177,7 @@ struct htb_sched {int row_mask[TC_HTB_MAXDEPTH ];struct htb_level hlevel[TC_HTB_MAXDEPTH ]; +u32 overlimits; };/* find class in global hash table using given handle */
@@ -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
Quoted 26 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.
Cc Eric Dumazet <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/sch_htb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/sched/sch_htb.c +0
-0
net/sched/sch_htb.c struct htb_sched { · line 181
Quoted 5 lines
net/sched/sch_htb.c +1
-0@@ -177,6 +177,7 @@ struct htb_sched {int row_mask[TC_HTB_MAXDEPTH ];struct htb_level hlevel[TC_HTB_MAXDEPTH ]; +u32 overlimits; };
Hi Cong, your patch makes sense, but I am not sure about the location of this field, as this might need another cache line miss.
Maybe instead reduce 'long direct_pkts;' to 'u32 direct_pkts;' since we only exportdirect_pkts as 32bit quantity in the struct tc_htb_glob.
Then move the 'u32 overlimits;' right after direct_pkts to fill the new hole.
Thanks !
Quoted 40 lines · Eric Dumazet
Quoted 26 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.
Cc Eric Dumazet <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/sch_htb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/sched/sch_htb.c +0
-0net/sched/sch_htb.c struct htb_sched { · line 181
Quoted 5 lines
net/sched/sch_htb.c +1
-0@@ -177,6 +177,7 @@ struct htb_sched {int row_mask[TC_HTB_MAXDEPTH ];struct htb_level hlevel[TC_HTB_MAXDEPTH ]; +u32 overlimits; };Hi Cong, your patch makes sense, but I am not sure about the location of this field, as this might need another cache line miss.
Quoted 4 lines
Maybe instead reduce 'long
direct_pkts;' to 'u32direct_pkts;' since we only exportdirect_pktsas 32bit quantity in the structtc_htb_glob.Then move the 'u32 overlimits;' right after
direct_pktsto fill the new hole.
Sure, v2 is coming. :)
Thanks for catching it.
Quoted 1 line · Cong Wang
Sure, v2 is coming. :)
Another possibility would to reuse existing sch->qstats.overlimits ?
Quoted 6 lines · Eric Dumazet
Quoted 1 line · Cong Wang
Sure, v2 is coming. :)
Another possibility would to reuse existing
sch->qstats.overlimits?
I don't find any way to retrieve qdisc pointer from struct htb_sched, unless we add a pointer there, which will end up bigger.
Or refactor the functions on the call path of htb_change_class_mode() to use struct Qdisc*, which will end up a bigger patch.
Therefore, I think your suggestion of folding it into 'direct_pkts' is better.
Thanks.
Quoted 11 lines · Cong Wang
Quoted 6 lines · Eric Dumazet
Quoted 1 line · Cong Wang
Sure, v2 is coming. :)
Another possibility would to reuse existing
sch->qstats.overlimits?I don't find any way to retrieve qdisc pointer from struct
htb_sched, unless we add a pointer there, which will end up bigger.
Quoted 7 lines
Or refactor the functions on the call path of
htb_change_class_mode()to use struct Qdisc*, which will end up a bigger patch.Therefore, I think your suggestion of folding it into '
direct_pkts' is better.Thanks.
I see, SGTM then.