From mboxrd@z Thu Jan 1 00:00:00 1970 From: mulyadi.santosa@gmail.com (Mulyadi Santosa) Date: Tue, 8 Mar 2011 13:29:23 +0700 Subject: where is __memory_barrier in kernel ? In-Reply-To: References: Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Sun, Mar 6, 2011 at 21:02, loody 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