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]
Date:	Fri, 21 Aug 2015 09:46:57 +0300
From:	Adrian Hunter <adrian.hunter@...el.com>
To:	Thomas Gleixner <tglx@...utronix.de>
CC:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Andy Lutomirski <luto@...capital.net>,
	linux-kernel@...r.kernel.org,
	Stephane Eranian <eranian@...gle.com>,
	Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH V2] perf: x86: Improve accuracy of perf/sched clock

On 20/08/15 22:31, Thomas Gleixner wrote:
> On Wed, 29 Jul 2015, Adrian Hunter wrote:
>> @@ -239,6 +239,8 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
>>  	unsigned long long tsc_now, ns_now;
>>  	struct cyc2ns_data *data;
>>  	unsigned long flags;
>> +	u64 mult;
>> +	u32 shft = 32;
>>  
>>  	local_irq_save(flags);
>>  	sched_clock_idle_sleep_event();
>> @@ -256,12 +258,17 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
>>  	 * time function is continuous; see the comment near struct
>>  	 * cyc2ns_data.
>>  	 */
>> -	data->cyc2ns_mul =
>> -		DIV_ROUND_CLOSEST(NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR,
>> -				  cpu_khz);
>> -	data->cyc2ns_shift = CYC2NS_SCALE_FACTOR;
>> +	mult = (u64)NSEC_PER_MSEC << 32;
>> +	mult += cpu_khz / 2;
>> +	do_div(mult, cpu_khz);
>> +	while (mult > U32_MAX) {
>> +		mult >>= 1;
>> +		shft -= 1;
>> +	}
> 
> This is an open coded variant of clocks_calc_mult_shift(). Can we
> please use that one?

Sure.  clocks_calc_mult_shift() does a division on each shift which is a bit
slower (avoids a 1-bit rounding error but that will never be more than 1 in
2^32 in this case), and the 'maxsec' functionality is not needed because
mul_u64_u32_shr() is used to avoid 64-bit overflow.

I will send V3.

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