Re: [RFC/RFT/PATCH] i386 rw semaphore/spinlocks + use for mmap_sem

Manfred Spraul (manfreds@colorfullife.com)
Fri, 26 Nov 1999 11:46:26 +0100


"Benjamin C.R. LaHaise" wrote:
>
> 'loo folks,
>
> Okay, here's take two (actually 6) on the rw semaphores, with the same
> technique used for rw spinlocks,

1) you have removed one optimization: the old code needed _no_ register
if the spinlock was stored global variable (such as the tasklist_lock),
now you always clobber the %%eax register.

This might increase the register pressure, but I don't know if egcs
actually uses the %%eax register across "asm volatile".

2) the rw spinlock must starve writers, or you risk a lock-up with
interrupts:

CPU1: CPU2:
read_lock(&lock);
write_lock_irq(&lock);
<hardware interrupt>
<within hardware interrupt:>
read_lock(&lock);
; lock-up! write_lock() must release the lock before spinning.

AFAICS, you hold the lock while spinning.

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