Re: [rfc] "fair" rw spinlocks

From: Linus Torvalds
Date: Mon Nov 30 2009 - 12:18:51 EST




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