This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting
- From: Richard Henderson <rth at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Jul 2011 08:52:25 -0700
- Subject: Re: [RFC] Avoid unnecessary futex_wake syscalls when all threads are busy waiting
- References: <20110715093744.GJ2687@tyan-ft48-01.lab.bos.redhat.com>
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 <jakub@redhat.com>
>
> * config/linux/wait.h (do_spin): New inline, largely copied
> from do_wait, just don't do futex_wait here, instead return true if
> it should be done.
> (do_wait): Implement using do_spin.
> * config/linux/mutex.h (gomp_mutex_lock_slow): Add an int argument
> to prototype.
> (gomp_mutex_lock): Use __sync_val_compare_and_swap instead of
> __sync_bool_compare_and_swap, pass the oldval to
> gomp_mutex_lock_slow.
> * config/linux/mutex.c (gomp_mutex_lock_slow): Add oldval argument.
> If all mutex contenders are just spinning and not sleeping, don't
> change state to 2 unnecessarily. Optimize the loop when state has
> already become 2 to use just one atomic operation per loop instead
> of two.
> * config/linux/ia64/mutex.h (gomp_mutex_lock_slow): Add an int argument
> to prototype.
> (gomp_mutex_lock): Use __sync_val_compare_and_swap instead of
> __sync_bool_compare_and_swap, pass the oldval to
> gomp_mutex_lock_slow.
I think that even if the only measurable difference is a
reduction in the number of syscalls, that's still an improvement.
The patch is ok.
r~