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:	Wed, 22 Feb 2012 08:54:41 -0500
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	"H. Peter Anvin" <hpa@...or.com>, Jason Baron <jbaron@...hat.com>,
	a.p.zijlstra@...llo.nl, mathieu.desnoyers@...icios.com,
	davem@...emloft.net, ddaney.cavm@...il.com,
	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 00/10] jump label: introduce very_[un]likely + cleanups
 + docs

On Wed, 2012-02-22 at 14:34 +0100, Ingo Molnar wrote:
> * Steven Rostedt <rostedt@...dmis.org> wrote:
> 
> > I like the blue shed, but anyway...
> > 
> > On Wed, 2012-02-22 at 09:06 +0100, Ingo Molnar wrote:
> > > * H. Peter Anvin <hpa@...or.com> wrote:
> > > 
> > > > Not arguing that, but the static aspect is still key... or 
> > > > people will read it as another version of likely/unlikely.  
> > > 
> > > They can *read* it as such, that as is very much intentional! 
> > 
> > I mentioned this thread on irc and the first comment I received was:
> > 
> > "is that a new attempt at trying to guide the compiler?"
> 
> It essentially is, implemented partly via compiler help, 
> combined with runtime code patching, as an extended run-time arm 
> of the compiler in essence, to make out of line slowpaths even 
> cheaper to have around - to make the fast-path even faster.

Actually, I was partly under the impression that we didn't care if it
was in the fast path. Maybe we need three versions. Let me explain.

We have cases where we want it default disabled and the code called when
enabled should be as out of line as possible. Tracing definitely falls
in this pattern. But we could push a "unlikely(static_branch())" for
such a case (or keep it as very_unlikely()).

Then we have cases where it is default enabled, where we can insert the
code in the fast path. Or do we even care how the compiler places it?
Because this leads us to the third use...

The third use is the case were we don't know the branch should be taken
or not until boot. We don't want the compiler to optimize the paths at
all. This example is for things like CPU features or types (as HPA
explained the "if (very_unlikely(cpu_vendor_amd))". This is the category
that we want to have an efficient system for the running hardware. We
can't bias one way or the other at compile time because frankly, we
don't know the answer until run time. This could also be used by modules
that are drivers for several types of hardware, and it can dynamically
change itself to suit the hardware it is driving.

> 
> > I personally find the very_unlikely() confusing, but then 
> > again I like the blue shed over the pink one.
> 
> Confusing in what way?

Because it really just looks like a stronger "unlikely()" and
fundamentally it really isn't. For tracing, sure that can be the way we
look at it, but for the more general case, it is a "We don't know which
way this branch should go most of the time, lets just pick one then
optimize later".

Again, maybe we need a "very_unlikely()" for the tracing case, maybe
even a "very_likely()", but then keep a static_branch() or whatever for
those cases you do not want to optimize at compile time.

-- Steve


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