Commit 1598f7cb authored by Yang Yingliang's avatar Yang Yingliang Committed by David S. Miller

net: sched: htb: fix the calculation of quantum

Now, 32bit rates may be not the true rate.
So use rate_bytes_ps which is from
max(rate32, rate64) to calcualte quantum.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cc106e44
...@@ -1477,11 +1477,22 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1477,11 +1477,22 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
sch_tree_lock(sch); sch_tree_lock(sch);
} }
rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
/* it used to be a nasty bug here, we have to check that node /* it used to be a nasty bug here, we have to check that node
* is really leaf before changing cl->un.leaf ! * is really leaf before changing cl->un.leaf !
*/ */
if (!cl->level) { if (!cl->level) {
cl->quantum = hopt->rate.rate / q->rate2quantum; u64 quantum = cl->rate.rate_bytes_ps;
do_div(quantum, q->rate2quantum);
cl->quantum = min_t(u64, quantum, INT_MAX);
if (!hopt->quantum && cl->quantum < 1000) { if (!hopt->quantum && cl->quantum < 1000) {
pr_warning( pr_warning(
"HTB: quantum of class %X is small. Consider r2q change.\n", "HTB: quantum of class %X is small. Consider r2q change.\n",
...@@ -1500,13 +1511,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1500,13 +1511,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
cl->prio = TC_HTB_NUMPRIO - 1; cl->prio = TC_HTB_NUMPRIO - 1;
} }
rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
cl->buffer = PSCHED_TICKS2NS(hopt->buffer); cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer); cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment