Re: spin_unlock optimization(i386)

Andrea Arcangeli (
Wed, 24 Nov 1999 23:34:47 +0100 (CET)

On Wed, 24 Nov 1999, Manfred Spraul wrote:

>What's the definition of a read memory barrier?

That's not the point. What you should tell me is that I can't reimplement
rmb() without a lock on the bus because the minium common divisor of a
spin_unlock() in pseudocode is not like in the Alpha implementation:

spinlock.lock = 0;

as I basically stated (I was thinking wrong) in my previous email.

On Alpha the spin_unlock can't be more finegrined because there's no way
you can _only_ avoid memory accesses before the barrier to be executed
after the barrier and letting accesses after the barrier to be executed
before the barrier.

I didn't understood well what IA32 enforces in a write: I thought the
write was enforcing order in both directions (up and down).

>AFAICS, the rmb() during set_current_state() is still required:

Not only the rmb() as it's common code (on i386 the rmb would be enough of
course). mb() is necessary instead.

BTW, In the example you provide below moving add_wait_queue in the middle
would remove the need of the barrier as an add_wait_queue executes both
the spin_lock and spin_unlock so it will sobstitute an mb() no matter how
the spin_lock/unlock are implemented.

>if(inode->i_state & I_LOCK) {
> schedule();



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at