lkml.org 
[lkml]   [1999]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: tutorial question: where mb() is needed?
Date
In article <Pine.LNX.3.96.990107212450.1261B-100000@laser.bogus>,
Andrea Arcangeli <andrea@e-mind.com> wrote:
>On Wed, 6 Jan 1999, Ryan Moore wrote:
>
>> Presumably all of this code isn't in a locked section for performance
>> reasons. Instead, the scheduler is relying on the fact that the scheduler
>> on another processor won't mess with this current process unless the
>> has_cpu is zero.
>
>Understood. But so what about spinlocks? Should we run a mb() a bit before
>releasing every spinlock?

No. The spinlocks themselves contain the required SMP memory
synchronization points internally: otherwise they wouldn't be very
useful as locking primitives. For example, on intel any locked memory
reference (and the spinlocks do them) will act as a memory barrier, and
that's why you don't see any extra code in asm-i386/spinlocks.h - on
other architectures the spinlocks do other things to get the same goal.

See for example the asm-alpha/spinlocks.h file, which has the proper
explicit mb() calls (on the alpha, and any other sane SMP architecture,
the memory barrier issue is separate from any issue of atomicity).

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.045 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site