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: <alpine.DEB.2.21.1806201231030.10546@nanos.tec.linutronix.de>
Date:   Wed, 20 Jun 2018 12:42:40 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Peter Zijlstra <peterz@...radead.org>
cc:     Pavel Tatashin <pasha.tatashin@...cle.com>,
        steven.sistare@...cle.com, daniel.m.jordan@...cle.com,
        linux@...linux.org.uk, schwidefsky@...ibm.com,
        heiko.carstens@...ibm.com, john.stultz@...aro.org,
        sboyd@...eaurora.org, x86@...nel.org, linux-kernel@...r.kernel.org,
        mingo@...hat.com, hpa@...or.com, douly.fnst@...fujitsu.com,
        prarit@...hat.com, feng.tang@...el.com, pmladek@...e.com,
        gnomes@...rguk.ukuu.org.uk
Subject: Re: [PATCH v10 7/7] x86/tsc: use tsc early

On Wed, 20 Jun 2018, Peter Zijlstra wrote:

> On Wed, Jun 20, 2018 at 01:52:10AM +0200, Thomas Gleixner wrote:
> >  u64 native_sched_clock(void)
> >  {
> > +	if (static_branch_likely(&__use_tsc))
> > +		return cycles_2_ns(rdtsc());
> >  
> > +	if (static_branch_unlikely(&tsc_early_enabled)) {
> > +		if (tsc_early_sched_clock)
> > +			return cycles_2_ns(rdtsc());
> >  	}
> 
> I'm still puzzled by the entire need for tsc_early_enabled and all that.
> Esp. since both branches do the exact same thing:
> 
> 	return cycles_2_ns(rdtsc());

Right. But up to the point where the real sched_clock initialization can be
done and the static keys can be flipped, there must be a way to
conditinally use TSC depending on availablility and early initialization.

We cannot make the __use_tsc key TRUE at conmpile timeunless we add an
extra conditional into that codepath which makes the whole static key moot.

So the second static key for the early stuff is TRUE and has the extra
conditional:

	if (tsc_early_sched_clock)
		return cycles_2_ns(rdtsc());

And that code path gets nuked with flipping the key to FALSE in the later
init code, so that in case of jiffies we do not have the extra conditional
in every sched_clock() invocation.

You might argue, that we shouldn't care becasue the jiffies case is just
the worst case fallback anyway. I wouldn't even disagree as those old
machines which have TSC varying with the CPU frequency really should not
matter anymore. Pavel might disagree of course.

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ