Messages in this thread | | | Date | Thu, 11 Nov 2010 19:00:24 +0800 | From | DDD <> | Subject | Re: [PATCH] x86: avoid calling arch_trigger_all_cpu_backtrace() at the same time on SMP |
| |
Ingo Molnar wrote: > * DDD <dongdong.deng@windriver.com> wrote: > >> 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. :-) ) > > No, test_and_set_bit() is SMP safe and is an implicit barrier as well - so no > smp_wmb() or other barriers are needed.
Yep, the spin_lock of test_and_set_bit() could make sure that.
Thank you very much, I will send out the new patch quickly. :-)
Dongdong
> > Thanks, > > Ingo >
| |