Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1231167 > unrolled thread

[PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity

Started byChao Yu <chao2.yu@samsung.com>
First post2015-09-23 08:20 +0200
Last post2015-09-30 18:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] sched/fair: fix incorrect calculation of capacity in  scale_rt_capacity Chao Yu <chao2.yu@samsung.com> - 2015-09-23 08:20 +0200
    Re: [PATCH] sched/fair: fix incorrect calculation of capacity in  scale_rt_capacity Peter Zijlstra <peterz@infradead.org> - 2015-09-30 18:30 +0200

#1231167 — [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity

FromChao Yu <chao2.yu@samsung.com>
Date2015-09-23 08:20 +0200
Subject[PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity
Message-ID<qbLzj-4fg-5@gated-at.bofh.it>
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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1236514

FromPeter Zijlstra <peterz@infradead.org>
Date2015-09-30 18:30 +0200
Message-ID<qesqu-1Sg-29@gated-at.bofh.it>
In reply to#1231167
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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web