* [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity
@ 2015-09-23 6:15 Chao Yu
2015-09-30 16:18 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2015-09-23 6:15 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel
div_u64 can only handle 32-bits divisor, if our divisor is with type of
64-bits, we should use div64_u64 instead, otherwise value of divisor will
be cast to 32-bits, resulting in wrong calculation.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9176f7c..ee268ef 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6086,7 +6086,7 @@ static unsigned long scale_rt_capacity(int cpu)
total = sched_avg_period() + delta;
- used = div_u64(avg, total);
+ used = div64_u64(avg, total);
if (likely(used < SCHED_CAPACITY_SCALE))
return SCHED_CAPACITY_SCALE - used;
--
2.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity
2015-09-23 6:15 [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity Chao Yu
@ 2015-09-30 16:18 ` Peter Zijlstra
0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2015-09-30 16:18 UTC (permalink / raw)
To: Chao Yu; +Cc: mingo, linux-kernel
On Wed, Sep 23, 2015 at 02:15:51PM +0800, Chao Yu wrote:
> div_u64 can only handle 32-bits divisor, if our divisor is with type of
> 64-bits, we should use div64_u64 instead, otherwise value of divisor will
> be cast to 32-bits, resulting in wrong calculation.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9176f7c..ee268ef 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6086,7 +6086,7 @@ static unsigned long scale_rt_capacity(int cpu)
>
> total = sched_avg_period() + delta;
>
> - used = div_u64(avg, total);
> + used = div64_u64(avg, total);
total here should not exceed 2*sched_avg_period() 'much', with the
defaults this would end up being around 1e9.
So unless you prod at sysctl_sched_time_avg it should all work out fine
with the 32bit divisor.
Have you seen problems here?
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity
@ 2015-09-29 1:41 Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2015-09-29 1:41 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel
Ping.
> -----Original Message-----
> From: Chao Yu [mailto:chao2.yu@samsung.com]
> Sent: Wednesday, September 23, 2015 2:16 PM
> To: 'mingo@redhat.com'; 'peterz@infradead.org'
> Cc: 'linux-kernel@vger.kernel.org'
> Subject: [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity
>
> div_u64 can only handle 32-bits divisor, if our divisor is with type of
> 64-bits, we should use div64_u64 instead, otherwise value of divisor will
> be cast to 32-bits, resulting in wrong calculation.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> kernel/sched/fair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9176f7c..ee268ef 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6086,7 +6086,7 @@ static unsigned long scale_rt_capacity(int cpu)
>
> total = sched_avg_period() + delta;
>
> - used = div_u64(avg, total);
> + used = div64_u64(avg, total);
>
> if (likely(used < SCHED_CAPACITY_SCALE))
> return SCHED_CAPACITY_SCALE - used;
> --
> 2.5.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-30 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-23 6:15 [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity Chao Yu
2015-09-30 16:18 ` Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2015-09-29 1:41 Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox