lkml.org 
[lkml]   [2010]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] debug_core: add a memory barrier before atomic_inc(&slaves_in_kgdb)
Date
The atomic_inc operation of slaves_in_kgdb could be executed on
multi-cpus at the same time when kgdb have more than one slave
cpu.

Due to the atomic_inc() function do not imply memory barrier,
a missing memory barrier here maybe could casue an incorrect
value of slaves_in_kgdb, then let kgdb confused.

Add a memory barrier before atomic_inc(&slaves_in_kgdb) to
avoid that potential problem.

Signed-off-by: Dongdong Deng <libfetion@gmail.com>
---
kernel/debug/debug_core.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index cefd4a1..bec8af0 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -468,10 +468,13 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
kgdb_info[ks->cpu].enter_kgdb++;
kgdb_info[ks->cpu].exception_state |= exception_state;

- if (exception_state == DCPU_WANT_MASTER)
+ if (exception_state == DCPU_WANT_MASTER) {
+ smp_mb__before_atomic_inc();
atomic_inc(&masters_in_kgdb);
- else
+ } else {
+ smp_mb__before_atomic_inc();
atomic_inc(&slaves_in_kgdb);
+ }

if (arch_kgdb_ops.disable_hw_break)
arch_kgdb_ops.disable_hw_break(regs);
--
1.6.0.4


\
 
 \ /
  Last update: 2010-11-26 09:37    [W:0.022 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site