Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753593AbaLAOF4 (ORCPT ); Mon, 1 Dec 2014 09:05:56 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:56629 "EHLO e06smtp13.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404AbaLAOFz (ORCPT ); Mon, 1 Dec 2014 09:05:55 -0500 Date: Mon, 1 Dec 2014 15:05:47 +0100 From: Martin Schwidefsky To: Frederic Weisbecker Cc: LKML , Tony Luck , Peter Zijlstra , Heiko Carstens , Benjamin Herrenschmidt , Thomas Gleixner , Oleg Nesterov , Paul Mackerras , Wu Fengguang , Ingo Molnar , Rik van Riel Subject: Re: [RFC PATCH 03/30] cputime: Introduce nsecs_to_cputime64() Message-ID: <20141201150547.3521e8fa@mschwide> In-Reply-To: <1417199040-21044-4-git-send-email-fweisbec@gmail.com> References: <1417199040-21044-1-git-send-email-fweisbec@gmail.com> <1417199040-21044-4-git-send-email-fweisbec@gmail.com> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14120114-0013-0000-0000-0000020D107A Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Nov 2014 19:23:33 +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 > --- > include/linux/cputime.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/linux/cputime.h b/include/linux/cputime.h > index f2eb2ee..a225ab9 100644 > --- a/include/linux/cputime.h > +++ b/include/linux/cputime.h > @@ -13,4 +13,14 @@ > usecs_to_cputime((__nsecs) / NSEC_PER_USEC) > #endif > > +#ifndef nsecs_to_cputime > +# define nsecs_to_cputime(__nsecs) \ > + usecs_to_cputime((__nsecs) / NSEC_PER_USEC) > +#endif > + > +#ifndef nsecs_to_cputime64 > +# define nsecs_to_cputime64(__nsecs) \ > + ((__force cputime64_t) nsecs_to_cputime(__nsecs)) > +#endif > + > #endif /* __LINUX_CPUTIME_H */ For any architecture with a cputime_t better than a micro-second the conversion to micro seconds degrades the precision a lot. I would prefer to see the compile fail for e.g. s390 instead of silently introducing *broken* cputime values. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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/