Files
linux/include/linux
Peter Zijlstra 11276d5306 locking/static_keys: Add a new static_key interface
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>
2015-08-03 11:34:15 +02:00
..
2015-07-17 16:39:53 -07:00
2015-06-25 11:49:31 +03:00
2014-11-24 17:24:08 -05:00
2015-05-31 13:40:53 +02:00
2015-05-13 12:04:55 -05:00
2015-07-07 22:48:25 +02:00
2015-03-25 20:28:11 -04:00
2015-06-02 08:33:34 -06:00
2015-04-17 09:03:53 -04:00
2015-06-01 14:35:56 -06:00
2013-11-15 09:32:21 +09:00
2013-11-09 00:16:29 -05:00
2015-02-12 18:54:15 -08:00
2014-12-19 22:55:06 +01:00
2015-05-05 13:35:39 -06:00
2015-01-21 19:21:30 +01:00
2014-11-10 09:27:30 -07:00
2014-01-16 10:23:02 +10:30
2014-12-31 13:06:50 -05:00
2014-10-09 11:35:48 +03:00
2015-06-24 17:49:45 -07:00
2014-10-08 16:01:41 -04:00
2014-04-18 14:20:48 +02:00
2014-08-06 18:01:24 -07:00
2015-05-12 10:46:53 +02:00
2015-06-01 14:33:35 +02:00
2015-06-19 15:18:28 +02:00
2015-03-16 21:45:54 +11:00
2014-01-16 11:15:50 +01:00
2015-05-05 13:40:42 -06:00
2014-06-06 16:08:13 -07:00
2015-01-27 11:09:13 +01:00
2014-06-02 14:56:01 -07:00
2013-12-29 16:34:25 -05:00
2015-06-25 12:06:45 +02:00
2014-03-13 12:11:00 +10:30
2015-01-15 10:34:54 +01:00
2014-07-22 21:55:45 +01:00
2015-04-29 17:17:17 -05:00
2015-01-04 23:11:43 -05:00
2013-12-11 15:52:34 +01:00
2014-05-27 17:38:11 -07:00
2013-12-26 13:29:35 -05:00
2015-04-14 16:49:05 -07:00
2015-03-25 11:44:52 +01:00
2015-06-24 17:49:41 -07:00
2014-10-09 22:25:58 -04:00
2014-03-04 13:51:06 -05:00
2014-01-27 21:02:39 -08:00
2015-06-25 04:20:04 -04:00
2015-05-09 22:15:31 -04:00
2014-01-25 03:14:05 -05:00
2015-07-04 14:04:44 -04:00
2015-06-05 10:58:34 -06:00
2015-03-11 17:56:28 -04:00
2014-11-04 13:29:38 +00:00
2014-07-09 14:58:37 +01:00
2015-04-12 21:03:31 +02:00
2015-01-25 23:17:28 -05:00
2015-06-19 01:18:14 +02:00
2013-10-17 00:36:06 +02:00
2015-06-12 11:36:30 +02:00
2015-06-10 19:14:04 +08:00
2015-05-27 12:58:04 -07:00
2015-05-26 15:23:23 +02:00
2015-06-25 01:13:43 +02:00
2015-06-23 18:01:07 -04:00
2013-12-19 19:09:38 -05:00
2014-08-08 15:57:26 -07:00
2014-08-08 15:57:31 -07:00
2015-06-29 10:49:51 -07:00
2015-02-13 21:21:41 -08:00
2015-04-11 15:53:35 -04:00
2014-06-12 00:21:11 -04:00
2015-06-25 17:00:40 -07:00
2015-05-19 09:19:59 -06:00
2014-06-04 16:53:57 -07:00
2015-06-25 17:00:39 -07:00
2014-06-04 16:53:56 -07:00
2015-05-18 14:08:58 -07:00
2015-05-29 17:21:45 -05:00
2015-04-11 22:29:44 -04:00
2014-11-28 16:08:16 +01:00
2014-04-07 16:35:53 -07:00
2015-06-12 17:26:57 -07:00
2014-06-04 16:53:57 -07:00
2015-03-24 09:48:14 -07:00
2013-10-17 15:53:09 -04:00
2015-06-25 17:00:37 -07:00
2015-04-15 16:35:20 -07:00