On Tue, May 22, 2018 at 2:17 PM Peter Zijlstra <pet...@infradead.org> wrote:
> qrwlock is a fair lock and should not exhibit writer starvation. We actually have a special rule to make it *not* be fair, in that interrupts are allowed to take the read lock if there are readers - even if there are waiting writers. I'm not sure how much of an fairness effect this has, but it's required because of our rule that you can take it for reading without disabling interrupts. See void queued_read_lock_slowpath(struct qrwlock *lock) in kernel/locking/qrwlock.c. > You basically want to spin-wait with interrupts enabled, right? That was the intent of my (untested) pseudo-code. It should work fine. Note that I used write_trylock() only, so there is no queueing (which also implies no fairness). I'm not saying it's a _good_ idea. I'm saying it might work if all you worry about is the irq-disabled part. Linus