Re: [rfc] "fair" rw spinlocks

Linus Torvalds
2009-11-30T17:18:41Z

On Mon, 30 Nov 2009, Nick Piggin wrote:
>
> Two questions. Firstly, does tasklist_lock benefit much from read
> side paralellism? Looking at some of the critical sections some seem
> to hold it for quite a while (over task and thread iterations). So
> it might not be the right thing to convert it to a spinlock?

I do agree that it's a potential problem.

> Secondly:
>
> > static void tasklist_read_lock(void)
> > {
> > preempt_disable();
> > if (!current->tasklist_count++)
>
> What happens if an interrupt and nested tasklist_read_lock() happens
> here?

You're right. We'd still need to disable hardware interrupts. Very
annoying, because that is pretty much _guaranteed_ to eat up any advantage
of the faster spin_unlock path.

So scratch that approach. My earlier suggestion still looks technically
correct, but has all the performance disadvantages.

The best option really would be to try to make it all use RCU, rather than
paper over things. That _really_ should improve performance.

Linus