Re: [rfc] "fair" rw spinlocks

From: Paul E. McKenney
Date: Sat Nov 28 2009 - 10:20:31 EST


On Sat, Nov 28, 2009 at 12:15:07PM +0100, Andi Kleen wrote:
> "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> writes:
> >
> > The usual trick would be to keep per-fair-rwlock state in per-CPU
> > variables. If it is forbidden to read-acquire one nestable fair rwlock
> > while read-holding another, then this per-CPU state can be a single
> > pointer and a nesting count. On the other hand, if it is permitted to
> > read-acquire one nestable fair rwlock while holding another, then one
> > can use a small per-CPU array of pointer/count pairs.
>
> The problem is that in preemptible kernels kernel threads can switch
> CPUs all the time. How would you sync the per CPU state then?

In preemptible kernels, put the state into the task structure. Perhaps do
this in non-preemptible kernels too, just to save a bit of source code.

Thanx, Paul
--
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/