where is __memory_barrier in kernel ?

Mulyadi Santosa mulyadi.santosa at gmail.com
Tue Mar 8 01:29:23 EST 2011


On Sun, Mar 6, 2011 at 21:02, loody <miloody at gmail.com> wrote:
> hi all:
> I grep kernel source and found cpu_relax is defined as
> __memory_barrier(), which seems not defined in kernel source.
> At beginning I think it may be the gcc build-in functions, but I
> cannot find in the gcc document.
> Where and what is that used for?

Hi..

are you sure it's memory barrier? I check the source in lxr.linux.no
(2.6.37.3) and cpu_relax is expanded as 'rep' and 'nop' asm
instruction

but speaking about __memory_barrier(), I find it in
http://lxr.linux.no/#linux+v2.6.37.3/include/linux/compiler-intel.h#L19...meaning...(at
least for me), it's a macro specificly defined in Intel C compiler
(not gcc which we usually uses).

IMHO, it does the same as barrier everywhere....processor stop a while
and it make sure any memory operation (especially write) has been
done....

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list