From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754657AbbI3QYA (ORCPT ); Wed, 30 Sep 2015 12:24:00 -0400 Received: from casper.infradead.org ([85.118.1.10]:38012 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753526AbbI3QX5 (ORCPT ); Wed, 30 Sep 2015 12:23:57 -0400 Date: Wed, 30 Sep 2015 18:18:34 +0200 From: Peter Zijlstra To: Chao Yu Cc: mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: fix incorrect calculation of capacity in scale_rt_capacity Message-ID: <20150930161834.GQ3604@twins.programming.kicks-ass.net> References: <011101d0f5c7$638b1260$2aa13720$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <011101d0f5c7$638b1260$2aa13720$@samsung.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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?