mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
once: switch to new jump label API
Switch the DO_ONCE() macro from the deprecated jump label API to the new one. The new one is more readable, and for DO_ONCE() it also makes the generated code more icache-friendly: now the one-time initialization code is placed out-of-line at the jump target, rather than at the inline fallthrough case. Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d93fa2ba64
commit
cf4c950b87
2 changed files with 7 additions and 7 deletions
|
@ -5,7 +5,7 @@
|
||||||
#include <linux/jump_label.h>
|
#include <linux/jump_label.h>
|
||||||
|
|
||||||
bool __do_once_start(bool *done, unsigned long *flags);
|
bool __do_once_start(bool *done, unsigned long *flags);
|
||||||
void __do_once_done(bool *done, struct static_key *once_key,
|
void __do_once_done(bool *done, struct static_key_true *once_key,
|
||||||
unsigned long *flags);
|
unsigned long *flags);
|
||||||
|
|
||||||
/* Call a function exactly once. The idea of DO_ONCE() is to perform
|
/* Call a function exactly once. The idea of DO_ONCE() is to perform
|
||||||
|
@ -38,8 +38,8 @@ void __do_once_done(bool *done, struct static_key *once_key,
|
||||||
({ \
|
({ \
|
||||||
bool ___ret = false; \
|
bool ___ret = false; \
|
||||||
static bool ___done = false; \
|
static bool ___done = false; \
|
||||||
static struct static_key ___once_key = STATIC_KEY_INIT_TRUE; \
|
static DEFINE_STATIC_KEY_TRUE(___once_key); \
|
||||||
if (static_key_true(&___once_key)) { \
|
if (static_branch_unlikely(&___once_key)) { \
|
||||||
unsigned long ___flags; \
|
unsigned long ___flags; \
|
||||||
___ret = __do_once_start(&___done, &___flags); \
|
___ret = __do_once_start(&___done, &___flags); \
|
||||||
if (unlikely(___ret)) { \
|
if (unlikely(___ret)) { \
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
struct once_work {
|
struct once_work {
|
||||||
struct work_struct work;
|
struct work_struct work;
|
||||||
struct static_key *key;
|
struct static_key_true *key;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void once_deferred(struct work_struct *w)
|
static void once_deferred(struct work_struct *w)
|
||||||
|
@ -14,11 +14,11 @@ static void once_deferred(struct work_struct *w)
|
||||||
|
|
||||||
work = container_of(w, struct once_work, work);
|
work = container_of(w, struct once_work, work);
|
||||||
BUG_ON(!static_key_enabled(work->key));
|
BUG_ON(!static_key_enabled(work->key));
|
||||||
static_key_slow_dec(work->key);
|
static_branch_disable(work->key);
|
||||||
kfree(work);
|
kfree(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void once_disable_jump(struct static_key *key)
|
static void once_disable_jump(struct static_key_true *key)
|
||||||
{
|
{
|
||||||
struct once_work *w;
|
struct once_work *w;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ bool __do_once_start(bool *done, unsigned long *flags)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__do_once_start);
|
EXPORT_SYMBOL(__do_once_start);
|
||||||
|
|
||||||
void __do_once_done(bool *done, struct static_key *once_key,
|
void __do_once_done(bool *done, struct static_key_true *once_key,
|
||||||
unsigned long *flags)
|
unsigned long *flags)
|
||||||
__releases(once_lock)
|
__releases(once_lock)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue