This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 04/14] Disable elision for any pthread_mutexattr_settype call


On 06/28/2013 01:51 AM, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> PTHREAD_MUTEX_NORMAL requires deadlock for nesting, DEFAULT
> does not. Since glibc uses the same value (0) disable elision
> for any call to pthread_mutexattr_settype() with a 0 value.
> This implies that a program can disable elision by doing
> pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL)

This patch looks good.

It disables elision for NORMAL-type locks which is what we want.

This patch doesn't expose any new ABI or API.

This should be OK to checkin IMO.

Please let me review patch 5 before we do anything.

> Based on a original proposal by Rich Felker.
> 
> nptl/:
> 2013-06-27  Andi Kleen  <ak@linux.intel.com>
> 
> 	* pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
> 	Disable elision for PTHREAD_MUTEX_DEFAULT.
> ---
>  nptl/pthread_mutexattr_settype.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/nptl/pthread_mutexattr_settype.c b/nptl/pthread_mutexattr_settype.c
> index 7b476e9..a85cdcb 100644
> --- a/nptl/pthread_mutexattr_settype.c
> +++ b/nptl/pthread_mutexattr_settype.c
> @@ -30,6 +30,11 @@ __pthread_mutexattr_settype (attr, kind)
>    if (kind < PTHREAD_MUTEX_NORMAL || kind > PTHREAD_MUTEX_ADAPTIVE_NP)
>      return EINVAL;
>  
> +  /* Cannot distinguish between DEFAULT and NORMAL. So any settype
> +     call disables elision for now.  */
> +  if (kind == PTHREAD_MUTEX_DEFAULT)
> +    kind |= PTHREAD_MUTEX_NO_ELISION_NP;
> +

Looks good to me and it's the minimal change required.

>    iattr = (struct pthread_mutexattr *) attr;
>  
>    iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;
> 

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]