Re: [question] Linux read/write spinlocks and readers starving awriter

From: Manfred Spraul (manfred@colorfullife.com)
Date: Mon Jun 26 2000 - 12:55:18 EST


Ben LaHaise wrote:
>
> On Mon, 26 Jun 2000, Tigran Aivazian wrote:
>
> > I know that Linux read-write semaphores implementation is quite clever
> > with respect to putting the new readers to queue behind the waiting
> > writer. Now, is something similar true for read-write spinlocks also?
>
> Not at present. Right now what happens for the contended lock case is
> that the writer will release its bias of the lock and wait for the lock to
> be released by all readers before attempting to reaquire the lock. Is
> this the right thing to do? I'm not certain.
>
But I'm certain :-(

The "no writer in interrupt" rule for rw spinlocks forces us to release
the bias, and without that rule we would need to add lots of _irqsave()
calls.

CPU1: CPU2
read_lock(&tasklist_lock);
                        write_lock_irq(&tasklist_lock);
                        * spins
interrupt
within interrupt
read_lock(&tasklist_lock);

And IIRC your initial rw lock rewrite also held the lock bias, and you
had to change it. Perhaps you should add a comment?

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



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:09 EST