lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141201122452.GE4074@osiris>
Date:	Mon, 1 Dec 2014 13:24:52 +0100
From:	Heiko Carstens <heiko.carstens@...ibm.com>
To:	Frederic Weisbecker <fweisbec@...il.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Tony Luck <tony.luck@...el.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Oleg Nesterov <oleg@...hat.com>,
	Paul Mackerras <paulus@...ba.org>,
	Wu Fengguang <fengguang.wu@...el.com>,
	Ingo Molnar <mingo@...nel.org>, Rik van Riel <riel@...hat.com>,
	Martin Schwidefsky <schwidefsky@...ibm.com>
Subject: Re: [RFC PATCH 06/30] s390: Introduce cputime64_to_nsecs()

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 <benh@...nel.crashing.org>
> Cc: Heiko Carstens <heiko.carstens@...ibm.com>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: Martin Schwidefsky <schwidefsky@...ibm.com>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Paul Mackerras <paulus@...ba.org>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Rik van Riel <riel@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Tony Luck <tony.luck@...el.com>
> Cc: Wu Fengguang <fengguang.wu@...el.com>
> Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
> ---
>  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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ