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: <20150729084906.GH19282@twins.programming.kicks-ass.net>
Date:	Wed, 29 Jul 2015 10:49:06 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Vlastimil Babka <vbabka@...e.cz>
Cc:	linux-kernel@...r.kernel.org, mingo@...nel.org,
	jasonbaron0@...il.com, bp@...en8.de, luto@...capital.net,
	tglx@...utronix.de, rostedt@...dmis.org, will.deacon@....com,
	liuj97@...il.com, rabin@....in, ralf@...ux-mips.org,
	ddaney@...iumnetworks.com, benh@...nel.crashing.org,
	michael@...erman.id.au, heiko.carstens@...ibm.com,
	davem@...emloft.net
Subject: Re: [PATCH -v2 6/8] jump_label: Add a new static_key interface

On Wed, Jul 29, 2015 at 09:19:22AM +0200, Vlastimil Babka wrote:

> How would one define a static key that's e.g. expected to be mostly false, but
> with initial value of true, e.g. during boot?

DEFINE_STATIC_KEY_TRUE(blah);

will get you the true at boot time.

You'll then want to use:

	if (static_branch_unlikely(&blah)) {
		/* code that mostly doesn't happen */
	}

To indicate you expect it to be false most of the time. And you'll flip
it to false at runtime using:

	static_branch_disable(&blah);

If GCC co-operates, the body of the branch will be placed out-of-line,
we'll emit a jump to it by default, but once you disable it, we'll nop
the jump and fall straight through.
--
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