Re: [PATCH] i386 rw semaphore + use for mmap_sem

Manfred Spraul (manfreds@colorfullife.com)
Mon, 22 Nov 1999 20:26:58 +0100


"Benjamin C.R. LaHaise" wrote:
>
> On Sun, 21 Nov 1999, Manfred Spraul wrote:
>
> > And I don't understand your "first" handing:
> > > down_write_failed()
> > > [...]
> > > if (first) {
> > > atomic_add(RWSEM_BIAS, &sem->count);
> > > sem->writer = 0;
> > > }
>
> Okay, basically the first writer who comes along and has to wait is the
> only one who is allowed to maintain the BIAS (otherwise when a reader does
> a read_up, he won't see the result of zero indicating a wake up needs to
> be done).
>
Thanks for the explanation.

But I think the inline part of up_write() is wrong:
I think __rwsem_wake is always called:

lock is free: sem->val = RWSEM_BIAS
down_write()
sem->val is now 0.
up_write():
"addl BIAS,&sem->val" new value: 0x0100 0000
"jge slow_part"

jge means jump if SignFlag == OverflowFlag.

add from 0 to 0x01000 0000 means SF =0, OF = 0.
--> the jump is always taken.

I guess you need "jump if the old value was below zero"
this would be "jump if sign or carry", but this instruction doesn't
exist.

--
	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/