* [PATCH net] sch_tbf: use do_div() for 64-bit divide
@ 2013-12-12 2:22 Yang Yingliang
2013-12-12 2:57 ` [PATCH resend " Yang Yingliang
2013-12-12 13:21 ` [PATCH " Sergei Shtylyov
0 siblings, 2 replies; 5+ messages in thread
From: Yang Yingliang @ 2013-12-12 2:22 UTC (permalink / raw)
To: davem, netdev
It's doing a 64-bit divide which is not supported
on 32-bit architectures in psched_ns_t2l(). The
correct way to do this is to use do_div().
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
net/sched/sch_tbf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index a44928c..887e672 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -131,8 +131,10 @@ static u64 psched_ns_t2l(const struct psched_ratecfg *r,
do_div(len, NSEC_PER_SEC);
- if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
- len = (len / 53) * 48;
+ if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) {
+ do_div(len, 53);
+ len = len * 48;
+ }
if (len > r->overhead)
len -= r->overhead;
--
1.8.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH resend net] sch_tbf: use do_div() for 64-bit divide
2013-12-12 2:22 [PATCH net] sch_tbf: use do_div() for 64-bit divide Yang Yingliang
@ 2013-12-12 2:57 ` Yang Yingliang
2013-12-12 3:54 ` David Miller
2013-12-12 10:28 ` David Laight
2013-12-12 13:21 ` [PATCH " Sergei Shtylyov
1 sibling, 2 replies; 5+ messages in thread
From: Yang Yingliang @ 2013-12-12 2:57 UTC (permalink / raw)
To: davem, netdev; +Cc: fengguang.wu, kbuild-all
It's doing a 64-bit divide which is not supported
on 32-bit architectures in psched_ns_t2l(). The
correct way to do this is to use do_div().
It's introduced by commit cc106e441a63
("net: sched: tbf: fix the calculation of max_size")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
Change note:
Add commit which introduced this problem.
---
net/sched/sch_tbf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index a44928c..887e672 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -131,8 +131,10 @@ static u64 psched_ns_t2l(const struct psched_ratecfg *r,
do_div(len, NSEC_PER_SEC);
- if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
- len = (len / 53) * 48;
+ if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) {
+ do_div(len, 53);
+ len = len * 48;
+ }
if (len > r->overhead)
len -= r->overhead;
-- 1.8.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH resend net] sch_tbf: use do_div() for 64-bit divide
2013-12-12 2:57 ` [PATCH resend " Yang Yingliang
@ 2013-12-12 3:54 ` David Miller
2013-12-12 10:28 ` David Laight
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2013-12-12 3:54 UTC (permalink / raw)
To: yangyingliang; +Cc: netdev, fengguang.wu, kbuild-all
From: Yang Yingliang <yangyingliang@huawei.com>
Date: Thu, 12 Dec 2013 10:57:22 +0800
> It's doing a 64-bit divide which is not supported
> on 32-bit architectures in psched_ns_t2l(). The
> correct way to do this is to use do_div().
>
> It's introduced by commit cc106e441a63
> ("net: sched: tbf: fix the calculation of max_size")
>
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH resend net] sch_tbf: use do_div() for 64-bit divide
2013-12-12 2:57 ` [PATCH resend " Yang Yingliang
2013-12-12 3:54 ` David Miller
@ 2013-12-12 10:28 ` David Laight
1 sibling, 0 replies; 5+ messages in thread
From: David Laight @ 2013-12-12 10:28 UTC (permalink / raw)
To: Yang Yingliang, davem, netdev; +Cc: fengguang.wu, kbuild-all
> From: Yang Yingliang
> It's doing a 64-bit divide which is not supported
> on 32-bit architectures in psched_ns_t2l(). The
> correct way to do this is to use do_div().
The 'len' value has just been divided by 1000000000, can
it actually be larger than 32bit when the divide by 53 is done?
...
> do_div(len, NSEC_PER_SEC);
>
> - if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
> - len = (len / 53) * 48;
> + if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) {
> + do_div(len, 53);
> + len = len * 48;
> + }
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] sch_tbf: use do_div() for 64-bit divide
2013-12-12 2:22 [PATCH net] sch_tbf: use do_div() for 64-bit divide Yang Yingliang
2013-12-12 2:57 ` [PATCH resend " Yang Yingliang
@ 2013-12-12 13:21 ` Sergei Shtylyov
1 sibling, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2013-12-12 13:21 UTC (permalink / raw)
To: Yang Yingliang, davem, netdev
Hello.
On 12-12-2013 6:22, Yang Yingliang wrote:
> It's doing a 64-bit divide which is not supported
> on 32-bit architectures in psched_ns_t2l(). The
> correct way to do this is to use do_div().
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> net/sched/sch_tbf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
> index a44928c..887e672 100644
> --- a/net/sched/sch_tbf.c
> +++ b/net/sched/sch_tbf.c
> @@ -131,8 +131,10 @@ static u64 psched_ns_t2l(const struct psched_ratecfg *r,
>
> do_div(len, NSEC_PER_SEC);
>
> - if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
> - len = (len / 53) * 48;
> + if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) {
> + do_div(len, 53);
> + len = len * 48;
Why not simply len *= 48? You're coding in C, after all. :-)
WBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-12 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-12 2:22 [PATCH net] sch_tbf: use do_div() for 64-bit divide Yang Yingliang
2013-12-12 2:57 ` [PATCH resend " Yang Yingliang
2013-12-12 3:54 ` David Miller
2013-12-12 10:28 ` David Laight
2013-12-12 13:21 ` [PATCH " Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox