Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755498Ab3DKSWM (ORCPT ); Thu, 11 Apr 2013 14:22:12 -0400 Received: from mail-qa0-f50.google.com ([209.85.216.50]:43735 "EHLO mail-qa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298Ab3DKSWK (ORCPT ); Thu, 11 Apr 2013 14:22:10 -0400 Date: Thu, 11 Apr 2013 20:22:03 +0200 From: Frederic Weisbecker To: Peter Zijlstra Cc: Linus Torvalds , Stanislaw Gruszka , Linux Kernel Mailing List , Ingo Molnar , "H. Peter Anvin" , Steven Rostedt , Andrew Morton , Thomas Gleixner , linux-tip-commits@vger.kernel.org Subject: Re: [tip:sched/core] sched: Lower chances of cputime scaling overflow Message-ID: <20130411182201.GE17129@somewhere.redhat.com> References: <20130326140147.GB2029@redhat.com> <1365687946.8824.3.camel@laptop> <1365703670.10217.10.camel@laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1365703670.10217.10.camel@laptop> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1488 Lines: 36 On Thu, Apr 11, 2013 at 08:07:50PM +0200, Peter Zijlstra wrote: > On Thu, 2013-04-11 at 08:38 -0700, Linus Torvalds wrote: > > On Thu, Apr 11, 2013 at 6:45 AM, Peter Zijlstra wrote: > > > On Tue, 2013-03-26 at 15:01 +0100, Stanislaw Gruszka wrote: > > >> Thoughts? > > > > > > Would something like the below work? > > > > Ugh, this is hard to think about, it's also fairly inefficient. > > > > > static cputime_t scale_stime(u64 stime, u64 rtime, u64 total) > > > { > > > - u64 rem, res, scaled; > > > + int stime_fls = fls64(stime); > > > + int total_fls = fls64(total); > > > + int rtime_fls = fls64(rtime); > > > > Doing "fls64()" unconditionally is quite expensive on some > > architectures, > > Oh, I (wrongly it appears) assumed that fls was something cheap :/ > > > and if I am not mistaken, the *common* case (by far) is > > that all these values fit in 32 bits, no? > > It depends on if we use cputime_jiffies.h or cputime_nsec.h and I'm > completely lost as to which we default to atm. But we sure can reduce > to 32 bits in most cases without too much problems. We default to the jiffies. The nsecs case is used only for full dynticks accounting and ia64 precise accounting. -- 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/