Yes what you are saying is also right, since in order to prevent the ordering all the pending memory operations should have completed <div>hence as you mentioned processor stops and make sure all the memory operations are completed.<br>
<br><div class="gmail_quote">On Tue, Mar 8, 2011 at 11:59 AM, Mulyadi Santosa <span dir="ltr"><<a href="mailto:mulyadi.santosa@gmail.com">mulyadi.santosa@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, Mar 6, 2011 at 21:02, loody <<a href="mailto:miloody@gmail.com">miloody@gmail.com</a>> wrote:<br>
> hi all:<br>
> I grep kernel source and found cpu_relax is defined as<br>
> __memory_barrier(), which seems not defined in kernel source.<br>
> At beginning I think it may be the gcc build-in functions, but I<br>
> cannot find in the gcc document.<br>
> Where and what is that used for?<br>
<br>
</div>Hi..<br>
<br>
are you sure it's memory barrier? I check the source in <a href="http://lxr.linux.no" target="_blank">lxr.linux.no</a><br>
(2.6.37.3) and cpu_relax is expanded as 'rep' and 'nop' asm<br>
instruction<br>
<br>
but speaking about __memory_barrier(), I find it in<br>
<a href="http://lxr.linux.no/#linux+v2.6.37.3/include/linux/compiler-intel.h#L19...meaning...(at" target="_blank">http://lxr.linux.no/#linux+v2.6.37.3/include/linux/compiler-intel.h#L19...meaning...(at</a><br>
least for me), it's a macro specificly defined in Intel C compiler<br>
(not gcc which we usually uses).<br>
<br>
IMHO, it does the same as barrier everywhere....processor stop a while<br>
and it make sure any memory operation (especially write) has been<br>
done....<br>
<font color="#888888"><br>
--<br>
regards,<br>
<br>
Mulyadi Santosa<br>
Freelance Linux trainer and consultant<br>
<br>
blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>
training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a><br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</div></div></blockquote></div><br></div>