Skip to content

Commit

Permalink
jump_label: Move CPU hotplug locking
Browse files Browse the repository at this point in the history
As we're about to rework the locking, let's move the taking and
release of the CPU hotplug lock to locations that will make its
reworking completely obvious.

Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Marc Zyngier authored and Ingo Molnar committed Aug 10, 2017
1 parent d0646a6 commit b70cecf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/jump_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void static_key_slow_inc(struct static_key *key)
{
int v, v1;

cpus_read_lock();
STATIC_KEY_CHECK_USE();

/*
Expand All @@ -99,11 +100,12 @@ void static_key_slow_inc(struct static_key *key)
*/
for (v = atomic_read(&key->enabled); v > 0; v = v1) {
v1 = atomic_cmpxchg(&key->enabled, v, v + 1);
if (likely(v1 == v))
if (likely(v1 == v)) {
cpus_read_unlock();
return;
}
}

cpus_read_lock();
jump_label_lock();
if (atomic_read(&key->enabled) == 0) {
atomic_set(&key->enabled, -1);
Expand Down

0 comments on commit b70cecf

Please sign in to comment.