public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 1/4] nptl: Use internal low-level lock type for !IS_IN (libc)
Date: Tue, 6 Jul 2021 16:24:37 -0300	[thread overview]
Message-ID: <2876f56d-8e5b-4f8c-050f-a7baa9d56a8b@linaro.org> (raw)
In-Reply-To: <12e42ea241149b8c10e43e60e8087ab4bc0ba01c.1625591725.git.fweimer@redhat.com>



On 06/07/2021 14:22, Florian Weimer via Libc-alpha wrote:
> This avoids an ABI hazard (types changing between different modules
> of glibc) without introducing linknamespace issues. In particular,
> NSS modules now call __lll_lock_wait_private@@GLIBC_PRIVATE to wait
> on internal locks (the unlock path is inlined and performs a direct
> system call).

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/nptl/libc-lockP.h | 51 ++++-----------------------------------
>  1 file changed, 5 insertions(+), 46 deletions(-)
> 
> diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h
> index ef88a3e533..b66c938e44 100644
> --- a/sysdeps/nptl/libc-lockP.h
> +++ b/sysdeps/nptl/libc-lockP.h
> @@ -33,18 +33,8 @@
>  #include <lowlevellock.h>
>  #include <tls.h>
>  
> -#if IS_IN (libpthread)
> -/* This gets us the declarations of the __pthread_* internal names,
> -   and hidden_proto for them.  */
> -# include <pthreadP.h>
> -#endif
> -
>  /* Mutex type.  */
> -#if !IS_IN (libc) && !IS_IN (libpthread)
> -typedef pthread_mutex_t __libc_lock_t;
> -#else
>  typedef int __libc_lock_t;
> -#endif
>  typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t;
>  typedef pthread_rwlock_t __libc_rwlock_t;
>  
> @@ -108,56 +98,25 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0");
>  
>  /* Initialize the named lock variable, leaving it in a consistent, unlocked
>     state.  */
> -#if IS_IN (libc) || IS_IN (libpthread)
> -# define __libc_lock_init(NAME) \
> -  ((void) ((NAME) = LLL_LOCK_INITIALIZER))
> -#else
> -# define __libc_lock_init(NAME) __pthread_mutex_init (&(NAME))
> -#endif
> +#define __libc_lock_init(NAME) ((void) ((NAME) = LLL_LOCK_INITIALIZER))
>  #define __libc_rwlock_init(NAME) __pthread_rwlock_init (&(NAME), NULL)
>  
>  /* Finalize the named lock variable, which must be locked.  It cannot be
>     used again until __libc_lock_init is called again on it.  This must be
>     called on a lock variable before the containing storage is reused.  */
> -#if IS_IN (libc) || IS_IN (libpthread)
> -# define __libc_lock_fini(NAME) ((void) 0)
> -#else
> -# define __libc_lock_fini(NAME) __pthread_mutex_destroy (&(NAME))
> -#endif
> +#define __libc_lock_fini(NAME) ((void) 0)
>  #define __libc_rwlock_fini(NAME) ((void) 0)
>  
>  /* Lock the named lock variable.  */
> -#if IS_IN (libc) || IS_IN (libpthread)
> -# ifndef __libc_lock_lock
> -#  define __libc_lock_lock(NAME) \
> -  ({ lll_lock (NAME, LLL_PRIVATE); 0; })
> -# endif
> -#else
> -# undef __libc_lock_lock
> -# define __libc_lock_lock(NAME) __pthread_mutex_lock (&(NAME))
> -#endif
> +#define __libc_lock_lock(NAME) ({ lll_lock (NAME, LLL_PRIVATE); 0; })
>  #define __libc_rwlock_rdlock(NAME) __pthread_rwlock_rdlock (&(NAME))
>  #define __libc_rwlock_wrlock(NAME) __pthread_rwlock_wrlock (&(NAME))
>  
>  /* Try to lock the named lock variable.  */
> -#if IS_IN (libc) || IS_IN (libpthread)
> -# ifndef __libc_lock_trylock
> -#  define __libc_lock_trylock(NAME) \
> -  lll_trylock (NAME)
> -# endif
> -#else
> -# undef __libc_lock_trylock
> -# define __libc_lock_trylock(NAME) \
> -  __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
> -#endif
> +#define __libc_lock_trylock(NAME) lll_trylock (NAME)
>  
>  /* Unlock the named lock variable.  */
> -#if IS_IN (libc) || IS_IN (libpthread)
> -# define __libc_lock_unlock(NAME) \
> -  lll_unlock (NAME, LLL_PRIVATE)
> -#else
> -# define __libc_lock_unlock(NAME) __pthread_mutex_unlock (&(NAME))
> -#endif
> +#define __libc_lock_unlock(NAME) lll_unlock (NAME, LLL_PRIVATE)
>  #define __libc_rwlock_unlock(NAME) __pthread_rwlock_unlock (&(NAME))
>  
>  #if IS_IN (rtld)
> 

  reply	other threads:[~2021-07-06 19:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 17:22 [PATCH 0/4] GLIBC_PRIVATE ABI cleanups Florian Weimer
2021-07-06 17:22 ` [PATCH 1/4] nptl: Use internal low-level lock type for !IS_IN (libc) Florian Weimer
2021-07-06 19:24   ` Adhemerval Zanella [this message]
2021-07-06 17:22 ` [PATCH 2/4] nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock, __pthread_mutex_unlock Florian Weimer
2021-07-06 19:25   ` Adhemerval Zanella
2021-07-06 17:22 ` [PATCH 3/4] nptl: Reduce the GLIBC_PRIVATE ABI Florian Weimer
2021-07-06 19:26   ` Adhemerval Zanella
2021-07-06 17:22 ` [PATCH 4/4] elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols Florian Weimer
2021-07-06 19:30   ` Adhemerval Zanella
2021-07-07  6:42     ` Florian Weimer
2021-07-07 10:56 ` [PATCH 0/4] GLIBC_PRIVATE ABI cleanups Szabolcs Nagy
2021-07-07 11:04   ` Florian Weimer
2021-07-07 11:53     ` Szabolcs Nagy
2021-07-07 12:44       ` Florian Weimer
2021-07-07 12:53         ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2876f56d-8e5b-4f8c-050f-a7baa9d56a8b@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).