lkml.org 
[lkml]   [1999]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: spin_unlock optimization(i386)
Andrea Arcangeli wrote:
> So we could reimplement a rmb() (and in turn an mb()) that scales in SMP?
> Something like:
>
> #define rmb() ... "movb $0, ZERO_PAGE+32*smp_processor_id()"
>
>
> Am I missing something?
>
> Andrea
What's the definition of a read memory barrier?
IA32 allows that reads are executed before a following read, and before
a following write call, but everything else is prohibited.

read a
write b <<<<<< end of the spinlock protected area
read c
read d

could be reordered as
read a
read d
read c
write b <<<<<<<< end of the spinlock protected area

this is acceptable for a spinlock: the CPU executes additional
instructions, but never _fewer_ instructions, within the protected area.

The only operation which must not happen is that "read a" is executed
_after_ write b, and this doesn't happen.

---------
AFAICS, the rmb() during set_current_state() is still required:
__wait_on_inode()
add_wait_queue();
current->state=TASK_UNINTERRUPTIBLE;
if(inode->i_state & I_LOCK) {
schedule();

without rmb(), current->state=TASK_UNINTERRUPTIBLE would be a normal
write, and thus the following read for inode->i_state could be executed
_before_ setting state -> wake-up is lost.

--
Manfred

-
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:55    [from the cache]
©2003-2011 Jasper Spaans