Commit ef0da55a authored by Catalin Marinas's avatar Catalin Marinas Committed by Will Deacon

jump_labels: Allow array initialisers

The static key API is currently designed around single variable
definitions. There are cases where an array of static keys is desirable,
so extend the API to allow this rather than using the internal static
key implementation directly.

Cc: Jason Baron <jbaron@akamai.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Suggested-by: default avatarDave P Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent dae8c235
...@@ -15,6 +15,8 @@ The updated API replacements are: ...@@ -15,6 +15,8 @@ The updated API replacements are:
DEFINE_STATIC_KEY_TRUE(key); DEFINE_STATIC_KEY_TRUE(key);
DEFINE_STATIC_KEY_FALSE(key); DEFINE_STATIC_KEY_FALSE(key);
DEFINE_STATIC_KEY_ARRAY_TRUE(keys, count);
DEFINE_STATIC_KEY_ARRAY_FALSE(keys, count);
static_branch_likely() static_branch_likely()
static_branch_unlikely() static_branch_unlikely()
...@@ -140,6 +142,13 @@ static_branch_inc(), will change the branch back to true. Likewise, if the ...@@ -140,6 +142,13 @@ static_branch_inc(), will change the branch back to true. Likewise, if the
key is initialized false, a 'static_branch_inc()', will change the branch to key is initialized false, a 'static_branch_inc()', will change the branch to
true. And then a 'static_branch_dec()', will again make the branch false. true. And then a 'static_branch_dec()', will again make the branch false.
Where an array of keys is required, it can be defined as:
DEFINE_STATIC_KEY_ARRAY_TRUE(keys, count);
or:
DEFINE_STATIC_KEY_ARRAY_FALSE(keys, count);
4) Architecture level code patching interface, 'jump labels' 4) Architecture level code patching interface, 'jump labels'
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* *
* DEFINE_STATIC_KEY_TRUE(key); * DEFINE_STATIC_KEY_TRUE(key);
* DEFINE_STATIC_KEY_FALSE(key); * DEFINE_STATIC_KEY_FALSE(key);
* DEFINE_STATIC_KEY_ARRAY_TRUE(keys, count);
* DEFINE_STATIC_KEY_ARRAY_FALSE(keys, count);
* static_branch_likely() * static_branch_likely()
* static_branch_unlikely() * static_branch_unlikely()
* *
...@@ -270,6 +272,16 @@ struct static_key_false { ...@@ -270,6 +272,16 @@ struct static_key_false {
#define DEFINE_STATIC_KEY_FALSE(name) \ #define DEFINE_STATIC_KEY_FALSE(name) \
struct static_key_false name = STATIC_KEY_FALSE_INIT struct static_key_false name = STATIC_KEY_FALSE_INIT
#define DEFINE_STATIC_KEY_ARRAY_TRUE(name, count) \
struct static_key_true name[count] = { \
[0 ... (count) - 1] = STATIC_KEY_TRUE_INIT, \
}
#define DEFINE_STATIC_KEY_ARRAY_FALSE(name, count) \
struct static_key_false name[count] = { \
[0 ... (count) - 1] = STATIC_KEY_FALSE_INIT, \
}
extern bool ____wrong_branch_error(void); extern bool ____wrong_branch_error(void);
#define static_key_enabled(x) \ #define static_key_enabled(x) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment