Re: REGRESSION: Performance regressions from switching anon_vma->lockto mutex

From: Linus Torvalds
Date: Thu Jun 16 2011 - 17:10:40 EST

On Thu, Jun 16, 2011 at 1:26 PM, Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> wrote:
> I ran exim with different kernel versions.  Using 2.6.39-vanilla
> kernel as a baseline, the results are as follow:
>                        Throughput
> 2.6.39(vanilla)         100.0%
> 2.6.39+ra-patch         166.7%  (+66.7%)        (note: tmpfs readahead patchset is merged in 3.0-rc2)
> 3.0-rc2(vanilla)         68.0%  (-32%)
> 3.0-rc2+linus           115.7%  (+15.7%)
> 3.0-rc2+linus+softirq    86.2%  (-17.3%)

Ok, so batching the semaphore operations makes more of a difference
than I would have expected.

I guess I'll cook up an improved patch that does it for the vma exit
case too, and see if that just makes the semaphores be a non-issue.

> I also notice that the run to run variations have increased quite a bit for 3.0-rc2.
> I'm using 6 runs per kernel.  Perhaps a side effect of converting the anon_vma->lock to mutex?

So the thing about using the mutexes is that heavy contention on a
spinlock is very stable: it may be *slow*, but it's reliable, nicely
queued, and has very few surprises.

On a mutex, heavy contention results in very subtle behavior, with the
adaptive spinning often - but certainly not always - making the mutex
act as a spinlock, but once you have lots of contention the adaptive
spinning breaks down. And then you have lots of random interactions
with the scheduler and 'need_resched' etc.

The only valid answer to lock contention is invariably always just
"don't do that then". We've been pretty good at getting rid of
problematic locks, but this one clearly isn't one of the ones we've
fixed ;)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at