[PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Peter Zijlstra
Change mutex contention behaviour such that it will sometimes busy wait on acquisition - moving its behaviour closer to that of spinlocks. This concept got ported to mainline from the -rt tree, where it was originally implemented for rtmutexes by Steven Rostedt, based on work by Gregory Haskins.

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Frédéric Weisbecker
2009/1/7 Peter Zijlstra pet...@infradead.org: Change mutex contention behaviour such that it will sometimes busy wait on acquisition - moving its behaviour closer to that of spinlocks. This concept got ported to mainline from the -rt tree, where it was originally implemented for rtmutexes by

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Peter Zijlstra
On Wed, 2009-01-07 at 15:50 +0100, Frédéric Weisbecker wrote: 2009/1/7 Peter Zijlstra pet...@infradead.org: Change mutex contention behaviour such that it will sometimes busy wait on acquisition - moving its behaviour closer to that of spinlocks. This concept got ported to mainline from

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Steven Rostedt
On Wed, 7 Jan 2009, Steven Rostedt wrote: On Wed, 7 Jan 2009, Peter Zijlstra wrote: --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -10,6 +10,10 @@ * Many thanks to Arjan van de Ven, Thomas Gleixner, Steven Rostedt and * David Howells for suggestions and improvements. * + * -

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Peter Zijlstra
On Wed, 2009-01-07 at 10:22 -0500, Steven Rostedt wrote: Peter, nice work! Thanks! + } + + if (!spin) { + schedstat_inc(this_rq(), mtx_sched); + __set_task_state(task, state); I still do not know why you set state here instead of in the mutex code. Yes, you

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Linus Torvalds
On Wed, 7 Jan 2009, Peter Zijlstra wrote: Change mutex contention behaviour such that it will sometimes busy wait on acquisition - moving its behaviour closer to that of spinlocks. Ok, this one looks _almost_ ok. The only problem is that I think you've lost the UP case. In UP, you

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Chris Mason
On Wed, 2009-01-07 at 08:25 -0800, Linus Torvalds wrote: On Wed, 7 Jan 2009, Peter Zijlstra wrote: Change mutex contention behaviour such that it will sometimes busy wait on acquisition - moving its behaviour closer to that of spinlocks. Ok, this one looks _almost_ ok. The only

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Linus Torvalds
On Wed, 7 Jan 2009, Chris Mason wrote: So far I haven't found any btrfs benchmarks where this is slower than mutexes without any spinning. But, it isn't quite as fast as the btrfs spin. Quite frankly, from our history with ext3 and other filesystems, using a mutex in the filesystem is

Re: [PATCH -v4][RFC]: mutex: implement adaptive spinning

2009-01-07 Thread Chris Mason
On Wed, 2009-01-07 at 09:50 -0800, Linus Torvalds wrote: On Wed, 7 Jan 2009, Chris Mason wrote: So far I haven't found any btrfs benchmarks where this is slower than mutexes without any spinning. But, it isn't quite as fast as the btrfs spin. Quite frankly, from our history with