Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting

2011-07-15 Thread Tobias Burnus
Jakub Jelinek wrote: Tested with libgomp testsuite and looked at performance numbers of Sho's omp_fib.c and libgomp.c/sort-1.c, unfortunately the differences looked to be in the noise. But, e.g. on omp_fib.c strace -f shows that the number of futex FUTEX_WAKE syscalls went down a lot (from ~ 750

Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting

2011-07-15 Thread Richard Henderson
On 07/15/2011 02:37 AM, Jakub Jelinek wrote: > Any comments? Can anyone see meassurable differences on some benchmark? > > 2011-07-15 Jakub Jelinek > > * config/linux/wait.h (do_spin): New inline, largely copied > from do_wait, just don't do futex_wait here, instead return true if

Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting

2011-07-15 Thread Jakub Jelinek
On Fri, Jul 15, 2011 at 12:02:06PM +0200, Paolo Bonzini wrote: > On 07/15/2011 11:37 AM, Jakub Jelinek wrote: > >While __sync_lock_test_and_set isn't a full barrier on all targets, > >I hope it doesn't matter, because the inline caller has already done one > >__sync_val_compare_and_swap which is a

Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting

2011-07-15 Thread Paolo Bonzini
On 07/15/2011 11:37 AM, Jakub Jelinek wrote: While __sync_lock_test_and_set isn't a full barrier on all targets, I hope it doesn't matter, because the inline caller has already done one __sync_val_compare_and_swap which is a full barrier. Why not take the occasion to add the __sync_swap extensi

[RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting

2011-07-15 Thread Jakub Jelinek
Hi! If lock contention is high, but all locks are held for relatively short time and no threads actually goes into futex_wait, we still completely unnecessarily do lots of futex_wake syscalls. On Linux with futex, our mutexes have 3 states: 0 - unlocked 1 - locked, uncontended 2 - locked, contend