[lkml]   [2005]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: question on memory barrier

--- Andy Isaacson <> a écrit :

> The first register write will be completed before the second register
> write because you use writel, which is defined to have the semantics you
> want. (It uses a platform-specific method to guarantee this, possibly
> "volatile" or "asm("eieio")" or whatever method your platform requires.)

I'm compiling Linux kernel for a MIPS32 cpu. On my platform, writel seems
expand to:

static inline writel(u32 val, volatile void __iomem *mem)
volatile u32 *__mem;
u32 __val;

__mem = (void *)((unsigned long)(mem));
__val = val;

*__mem = __val;

I don't see the magic in it since "volatile" keyword do not handle memory
ordering constraints...Linus wrote on volatile keyword, see

> The sequence points, by themselves, do not make any requirements on the
> externally visible behavior of the program. Nor does the fact that
> there's an inline function involved. It's just the writel() that
> contains the magic to force in-order execution.
> You might benefit by running your source code through gcc -E and seeing
> what the writel() expands to. (I do something like "rm drivers/mydev.o;
> make V=1" and then copy-n-paste the gcc line, replacing the "-c -o mydev.o"
> options with -E.)

make drivers/mydev.i should do the job but preprocessor doesn't expand inline
functions. So I won't be able to see the expanded writel function.

> The sequence point argument is obviously wrong, BTW - if it were the
> case that a mere sequence point required the compiler to have completed
> all externally-visible side effects, then almost every optimization that
> gcc does with -O2 would be impossible. CSE, loop splitting, etc.
> -andy

Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-08-25 11:16    [W:0.071 / U:8.664 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site