public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* RE: [BUG] Variable stopmachine_state should be volatile
@ 2005-12-08  1:37 Zhang, Yanmin
  2005-12-08 18:53 ` Luck, Tony
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zhang, Yanmin @ 2005-12-08  1:37 UTC (permalink / raw)
  To: Arjan van de Ven, Pavel Machek
  Cc: linux-kernel, Pallipadi, Venkatesh, Shah, Rajesh, linux-ia64

>>-----Original Message-----
>>From: Arjan van de Ven [mailto:arjan@infradead.org]
>>Sent: 2005Äê12ÔÂ2ÈÕ 16:04
>>To: Zhang, Yanmin
>>Cc: linux-kernel@vger.kernel.org; Pallipadi, Venkatesh; Shah, Rajesh
>>Subject: Re: [BUG] Variable stopmachine_state should be volatile
>>
>>On Wed, 2005-11-30 at 10:04 +0800, Zhang, Yanmin wrote:
>>> The model to access variable stopmachine_state is that a main thread
>>> writes it and other threads read it. Its declaration has no sign
>>> volatile. In the while loop in function stopmachine, this variable is
>>> read, and compiler might optimize it by reading it once before the loop
>>> and not reading it again in the loop, so the thread might enter dead
>>> loop.
>>
>>cpu_relax() includes a compiler barier..... so... what's wrong with the
>>compiler that it ignores such barriers?

You are right. I hit the problem when I compiled kernel 2.6.9 on IA64 by intel compiler.
cpu_relax has the compiler barrier if we use gcc, but cpu_relax becomes just ia64_hint which is null when I use intel compiler to compile kernel on ia64. file include/asm-ia64/intel_intrin.h defines ia64_hint as null.

Function stopmachine in kernel/stop_machine.c uses cpu_relax to prevent compiler from moving the reading of stopmachine_state out of the while loop. But when we use intel compiler, cpu_relax doesn't work because it is just null.

The right approach is to define ia64_hint to ia64_barrier in file include/asm-ia64/intel_intrin.h. I tested the new approach and it does work.

Thank Arjan, Pavel, and Venki.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-12-14  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-08  1:37 [BUG] Variable stopmachine_state should be volatile Zhang, Yanmin
2005-12-08 18:53 ` Luck, Tony
2005-12-12  7:06 ` Zhang, Yanmin
2005-12-12 13:39 ` Christoph Hellwig
2005-12-14  9:10 ` Zhang, Yanmin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox