Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lockacquisition

From: Tim Chen
Date: Mon Jun 24 2013 - 17:30:46 EST


On Mon, 2013-06-24 at 16:48 -0400, Peter Hurley wrote:

>
> Also, I haven't given a lot of thought to if preemption must be disabled
> before calling rwsem_can_spin_on_owner(). If so, wouldn't you just drop
> rwsem_can_spin_on_owner() (because the conditions tested in the loop are
> equivalent)?
>

Not totally equivalent. If we drop the call to rwsem_can_spin_on_owner,
we will spin when readers are holding the lock (owner is null).
Right now we only allow writers to spin when other writers are
holding the lock by adding the rwsem_can_spin_on_owner check.
Letting spinning on readers held lock is tricky as
we could have a reader that sleeps and if we don't detect the case. We
could spin for too long.

Thanks.

Tim


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/