Skip to content

Commit 8eedce9

Browse files
jibaronIngo Molnar
authored andcommitted
static keys: Inline the static_key_enabled() function
In the jump label enabled case, calling static_key_enabled() results in a function call. The function returns the results of a compare, so it really doesn't need the overhead of a full function call. Let's make it 'static inline' for both the jump label enabled and disabled cases. Signed-off-by: Jason Baron <jbaron@redhat.com> Cc: a.p.zijlstra@chello.nl Cc: rostedt@goodmis.org Cc: mathieu.desnoyers@polymtl.ca Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/201202281849.q1SIn1p2023270@int-mx10.intmail.prod.int.phx2.redhat.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent a706d4f commit 8eedce9

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎include/linux/jump_label.h‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ extern int jump_label_text_reserved(void *start, void *end);
127127
extern void static_key_slow_inc(struct static_key *key);
128128
extern void static_key_slow_dec(struct static_key *key);
129129
extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
130-
extern bool static_key_enabled(struct static_key *key);
131130
extern void jump_label_apply_nops(struct module *mod);
132131
extern void
133132
jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
@@ -198,11 +197,6 @@ static inline int jump_label_text_reserved(void *start, void *end)
198197
static inline void jump_label_lock(void) {}
199198
static inline void jump_label_unlock(void) {}
200199

201-
static inline bool static_key_enabled(struct static_key *key)
202-
{
203-
return (atomic_read(&key->enabled) > 0);
204-
}
205-
206200
static inline int jump_label_apply_nops(struct module *mod)
207201
{
208202
return 0;
@@ -224,4 +218,9 @@ jump_label_rate_limit(struct static_key_deferred *key,
224218
#define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
225219
#define jump_label_enabled static_key_enabled
226220

221+
static inline bool static_key_enabled(struct static_key *key)
222+
{
223+
return (atomic_read(&key->enabled) > 0);
224+
}
225+
227226
#endif /* _LINUX_JUMP_LABEL_H */

‎kernel/jump_label.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ void jump_label_unlock(void)
2929
mutex_unlock(&jump_label_mutex);
3030
}
3131

32-
bool static_key_enabled(struct static_key *key)
33-
{
34-
return (atomic_read(&key->enabled) > 0);
35-
}
36-
EXPORT_SYMBOL_GPL(static_key_enabled);
37-
3832
static int jump_label_cmp(const void *a, const void *b)
3933
{
4034
const struct jump_entry *jea = a;

0 commit comments

Comments
 (0)