linux/arch/sparc
Peter Zijlstra 2ca8c2cccc locking/static_keys: Add a new static_key interface
commit 11276d5306 upstream.

There are various problems and short-comings with the current
static_key interface:

 - static_key_{true,false}() read like a branch depending on the key
   value, instead of the actual likely/unlikely branch depending on
   init value.

 - static_key_{true,false}() are, as stated above, tied to the
   static_key init values STATIC_KEY_INIT_{TRUE,FALSE}.

 - we're limited to the 2 (out of 4) possible options that compile to
   a default NOP because that's what our arch_static_branch() assembly
   emits.

So provide a new static_key interface:

  DEFINE_STATIC_KEY_TRUE(name);
  DEFINE_STATIC_KEY_FALSE(name);

Which define a key of different types with an initial true/false
value.

Then allow:

   static_branch_likely()
   static_branch_unlikely()

to take a key of either type and emit the right instruction for the
case.

This means adding a second arch_static_branch_jump() assembly helper
which emits a JMP per default.

In order to determine the right instruction for the right state,
encode the branch type in the LSB of jump_entry::key.

This is the final step in removing the naming confusion that has led to
a stream of avoidable bugs such as:

  a833581e37 ("x86, perf: Fix static_key bug in load_mm_cr4()")

... but it also allows new static key combinations that will give us
performance enhancements in the subsequent patches.

Tested-by: Rabin Vincent <rabin@rab.in> # arm
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> # ppc
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # s390
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
[bwh: Backported to 3.16:
 - For s390, use the 31-bit-compatible macros in arch_static_branch_jump()
 - 
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2019-05-22 23:15:05 +01:00
..
boot sparc: Fix piggyback with newer binutils. 2012-12-03 11:24:25 -08:00
configs perf: Remove PERF_COUNTERS config option 2012-04-26 13:52:52 +02:00
crypto crypto: hash - annotate algorithms taking optional key 2018-06-16 22:21:51 +01:00
include locking/static_keys: Add a new static_key interface 2019-05-22 23:15:05 +01:00
kernel jump_label: Rename JUMP_LABEL_{EN,DIS}ABLE to JUMP_LABEL_{JMP,NOP} 2019-05-22 23:15:03 +01:00
lib sparc64: Fix userspace FPU register corruptions. 2015-08-20 15:33:39 +01:00
math-emu arch/sparc/math-emu/math_32.c: drop stray break operator 2014-08-14 10:09:44 +08:00
mm sparc64: Take ctx_alloc_lock properly in hugetlb_setup(). 2017-10-12 15:28:13 +01:00
net net: filter: make JITs zero A for SKF_AD_ALU_XOR_X 2016-01-25 10:44:05 +00:00
oprofile sparc: using HZ needs an include of linux/param.h 2009-10-05 00:46:08 -07:00
power nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 10:24:18 +01:00
prom sparc64: Fix register corruption in top-most kernel stack frame during boot. 2014-10-30 09:40:21 -07:00
Kbuild sparc64: Add SHA1 driver making use of the 'sha1' instruction. 2012-08-20 15:08:49 -07:00
Kconfig sparc64: sparse irq 2014-10-30 09:40:21 -07:00
Kconfig.debug lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
Makefile sparc64: Hibernation support 2013-03-20 11:06:54 -07:00