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-next>] [day] [month] [year] [list]
Date:	Wed, 15 Jul 2009 16:03:23 +0200
From:	Petr Tesarik <ptesarik@...e.cz>
To:	Andi Kleen <andi@...stfloor.org>,
	John Stultz <johnstul@...ibm.com>, george@...sta.com
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Carefully chosen CYC2NS_SCALE_FACTOR ??

Hi,

I'm having trouble understanding the rationale behind the choice for
CYC2NS_SCALE_FACTOR in arch/x86/include/asm/timer.h:

#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */

Why on Earth is this 10?

AFAICS this constant is the position of the decimal point in the
fixed-point cycle-to-nanoseconds computations. It is computed as
follows:

                *scale = (NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR)/cpu_khz;

Now, NSEC_PER_MSEC is 10^6, the size of cyc2ns is 32 bits and cpu_khz,
being an integer, cannot be less than 1. So, if I want maximum accuracy,
I should choose the maximium CYC2NS_SCALE_FACTOR such that:

10^6 * 2^CYC2NS_SCALE_FACTOR < 2^32

Which transforms to:

CYC2NS_SCALE_FACTOR = floor(log2(2^32/NSEC_PER_MSEC)) = 12

Did I miss an obvious reason for not using the scale factor of 12?

TIA,
Petr Tesarik
SUSE Linux


--
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