lkml.org 
[lkml]   [2010]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86: avoid calling arch_trigger_all_cpu_backtrace() at the same time on SMP
Ingo Molnar wrote:
> * Dongdong Deng <dongdong.deng@windriver.com> wrote:
>
>> +static int backtrace_flag;
>
>> + if (cmpxchg(&backtrace_flag, 0, 1) != 0)
>
> Sorry to be a PITA, but i asked for test_and_set() because that's the simplest
> primitive. cmpxchg() semantics is not nearly as obvious and people regularly get it
> wrong :-/

As the 'backtrace_flag' could be accessed by multi-cpus on SMP at the
same time, I use cmpxchg() for getting a atomic/memory barrier operation
for 'backtrace_flag' variable.

If we use test_and_set, maybe we need smp_wmb() after test_and_set. (If
I wrong, please correct me, thanks. :-) )

Should we still need to use test_and_set?
If need, I will use test_and_set at my next patch.

>
> Also, variables that cmpxchg or test_and_set operates on need to be long, not int.

Got it, I will change it to 'unsigned long' type.

Thanks for your teaching.

Dongdong


>
> Ingo
>



\
 
 \ /
  Last update: 2010-11-11 10:53    [W:0.163 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site