diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2012-06-07 22:20:18 +0900 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-13 15:08:37 +0200 |
commit | 2f74759056797054122cdc70844137f70bb3f626 (patch) | |
tree | e5ccff03a7fda3be1217923d973e8ba2f405a531 /arch/x86/kernel/alternative.c | |
parent | b0a4c6f2e3fce088eb597d4b9ee2075cb6399ee1 (diff) | |
download | linux-stable-2f74759056797054122cdc70844137f70bb3f626.tar.gz linux-stable-2f74759056797054122cdc70844137f70bb3f626.tar.bz2 linux-stable-2f74759056797054122cdc70844137f70bb3f626.zip |
x86/alternatives: Use atomic_xchg() instead atomic_dec_and_test() for stop_machine_text_poke()
stop_machine_text_poke() uses atomic_dec_and_test() to select one of
the CPUs executing that function to actually modify the code.
Since the variable is initialized to 1, subsequent CPUs will make the
variable go negative. Since going negative is uncommon/unexpected in
typical dec_and_test usage change this user to atomic_xchg().
This was found using a patch that warns on dec_and_test going
negative.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
[ Rewrote changelog ]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/87zk8fgsx9.fsf@devron.myhome.or.jp
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/alternative.c')
-rw-r--r-- | arch/x86/kernel/alternative.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 1f84794f0759..53231a045d3d 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -664,7 +664,7 @@ static int __kprobes stop_machine_text_poke(void *data) struct text_poke_param *p; int i; - if (atomic_dec_and_test(&stop_machine_first)) { + if (atomic_xchg(&stop_machine_first, 0)) { for (i = 0; i < tpp->nparams; i++) { p = &tpp->params[i]; text_poke(p->addr, p->opcode, p->len); |