Skip to content

Commit

Permalink
jump_label: jump_label_inc may return before the code is patched
Browse files Browse the repository at this point in the history
If cpu A calls jump_label_inc() just after atomic_add_return() is
called by cpu B, atomic_inc_not_zero() will return value greater then
zero and jump_label_inc() will return to a caller before jump_label_update()
finishes its job on cpu B.

Link: http://lkml.kernel.org/r/[email protected]

Cc: [email protected]
Cc: Peter Zijlstra <[email protected]>
Acked-by: Jason Baron <[email protected]>
Signed-off-by: Gleb Natapov <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
Gleb Natapov authored and rostedt committed Dec 5, 2011
1 parent c7c6ec8 commit bbbf7af
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/jump_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ void jump_label_inc(struct jump_label_key *key)
return;

jump_label_lock();
if (atomic_add_return(1, &key->enabled) == 1)
if (atomic_read(&key->enabled) == 0)
jump_label_update(key, JUMP_LABEL_ENABLE);
atomic_inc(&key->enabled);
jump_label_unlock();
}

Expand Down

0 comments on commit bbbf7af

Please sign in to comment.