This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/9] Add the low level infrastructure for pthreads lock elision with TSX
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Andi Kleen <andi at firstfloor dot org>
- Cc: libc-alpha at sourceware dot org, Andi Kleen <ak at linux dot intel dot com>
- Date: Tue, 14 May 2013 03:55:55 -0400
- Subject: Re: [PATCH 2/9] Add the low level infrastructure for pthreads lock elision with TSX
- References: <1368225725-14283-1-git-send-email-andi at firstfloor dot org> <1368225725-14283-3-git-send-email-andi at firstfloor dot org>
On 05/10/2013 06:41 PM, Andi Kleen wrote:
> new file mode 100644
> index 0000000..b9a9402
> --- /dev/null
> +++ b/nptl/sysdeps/unix/sysv/linux/x86/elision-conf.h
> @@ -0,0 +1,52 @@
> +/* elision-conf.h: Lock elision tunable parameters.
> + Copyright (C) 2013 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +#ifndef _ELISION_CONF_H
> +#define _ELISION_CONF_H 1
> +
> +#include <pthread.h>
> +#include <cpuid.h>
> +#include <time.h>
> +
> +/* Should make sure there is no false sharing on this */
> +
> +struct elision_config
> +{
> + int retry_lock_busy;
> + int retry_lock_internal_abort;
> + int retry_try_xbegin;
> + int retry_trylock_internal_abort;
> +};
> +
> +extern struct elision_config __elision_aconf attribute_hidden;
> +
> +extern int __rwlock_rtm_enabled;
> +extern int __elision_available;
> +
> +extern int __pthread_mutex_timedlock_nortm (pthread_mutex_t *mutex, const struct timespec *);
> +extern int __pthread_mutex_timedlock_rtm (pthread_mutex_t *mutex, const struct timespec *);
> +extern int __pthread_mutex_timedlock (pthread_mutex_t *mutex, const struct timespec *);
> +extern int __pthread_mutex_lock_nortm (pthread_mutex_t *mutex);
> +extern int __pthread_mutex_lock_rtm (pthread_mutex_t *mutex);
> +extern int __pthread_mutex_lock (pthread_mutex_t *mutex);
> +extern int __pthread_mutex_trylock_nortm (pthread_mutex_t *);
> +extern int __pthread_mutex_trylock_rtm (pthread_mutex_t *);
> +extern int __pthread_mutex_trylock (pthread_mutex_t *);
> +
> +#define SUPPORTS_ELISION 1
Please make this HAVE_ELISION 1. Add a comment explaining it means that
glibc has elision support for mutex and rwlocks.
Convention is either HAVE_*, NEED_* or USE_*.
HAVE_* - You support the feature at compile time.
NEED_* - You need that feature to be enabled at compile time.
USE_* - You have been configured to use this feature (as opposed to another).
For example you would define HAVE_ELISION to 1 to indicate to any other
code that elision support is present.
In generic code that doesn't know if elision is enabled you might write:
#define NEED_ELISION 1
...
#include <elision-conf.h>
To express that you need this support available.
Then in other code which has two distinct paths, one for elision and one
without, you might write:
#if USE_ELISION
/* Code that uses xabort, xbegin, xend ... */
#else
/* Normal non-elision-aware code. */
#endif
Cheers,
Carlos.