Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbaLAMZD (ORCPT ); Mon, 1 Dec 2014 07:25:03 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:58578 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044AbaLAMZA (ORCPT ); Mon, 1 Dec 2014 07:25:00 -0500 Date: Mon, 1 Dec 2014 13:24:52 +0100 From: Heiko Carstens To: Frederic Weisbecker Cc: LKML , Tony Luck , Peter Zijlstra , Benjamin Herrenschmidt , Thomas Gleixner , Oleg Nesterov , Paul Mackerras , Wu Fengguang , Ingo Molnar , Rik van Riel , Martin Schwidefsky Subject: Re: [RFC PATCH 06/30] s390: Introduce cputime64_to_nsecs() Message-ID: <20141201122452.GE4074@osiris> References: <1417199040-21044-1-git-send-email-fweisbec@gmail.com> <1417199040-21044-7-git-send-email-fweisbec@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1417199040-21044-7-git-send-email-fweisbec@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14120112-0009-0000-0000-000002355DE2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 28, 2014 at 07:23:36PM +0100, Frederic Weisbecker wrote: > This will be needed for the conversion of kernel stat to nsecs. > > Cc: Benjamin Herrenschmidt > Cc: Heiko Carstens > Cc: Ingo Molnar > Cc: Martin Schwidefsky > Cc: Oleg Nesterov > Cc: Paul Mackerras > Cc: Peter Zijlstra > Cc: Rik van Riel > Cc: Thomas Gleixner > Cc: Tony Luck > Cc: Wu Fengguang > Signed-off-by: Frederic Weisbecker > --- > arch/s390/include/asm/cputime.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h > index 820b38a..75ba96f 100644 > --- a/arch/s390/include/asm/cputime.h > +++ b/arch/s390/include/asm/cputime.h > @@ -59,6 +59,11 @@ static inline cputime64_t jiffies64_to_cputime64(const u64 jif) > return (__force cputime64_t)(jif * (CPUTIME_PER_SEC / HZ)); > } > > +static inline u64 cputime64_to_nsecs(cputime64_t cputime) > +{ > + return (__force u64)cputime * CPUTIME_PER_USEC * NSEC_PER_USEC; > +} > + This is incorrect. You probably wanted to write something like return (__force u64)cputime / CPUTIME_PER_USEC * NSEC_PER_USEC; ? However we would still lose a lot of precision. The correct algorithm to convert from cputime to nanoseconds can be found in tod_to_ns() - see arch/s390/include/asm/timex.h And if you see that rather complex algorithm, I doubt we want to have the changes you propose. We need to have that calculation three times for each irq (user, system and steal time) and would still have worse precision than we have right now. Not talking about the additional wasted cpu cycles... But I guess Martin wanted to comment on your patches anyway ;) -- 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/