[v3,18/37] nptl: Invoke the set_robust_list system call directly in fork

Message ID e954c4c896fbb2ba837b29be5332dce7a18c4fc4.1615914632.git.fweimer@redhat.com
State Superseded
Delegated to: Adhemerval Zanella Netto
Headers
Series libpthread removal: NPTL forwarders are gone |

Commit Message

Florian Weimer March 16, 2021, 5:29 p.m. UTC
  This removes one of the pthread forwarder functions.
---
 nptl/nptl-init.c                 | 21 ---------------------
 sysdeps/nptl/fork.c              | 11 ++---------
 sysdeps/nptl/pthread-functions.h |  1 -
 3 files changed, 2 insertions(+), 31 deletions(-)
  

Comments

Adhemerval Zanella Netto March 18, 2021, 12:54 p.m. UTC | #1
On 16/03/2021 14:29, Florian Weimer via Libc-alpha wrote:
> This removes one of the pthread forwarder functions.

LGTM.

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

> ---
>  nptl/nptl-init.c                 | 21 ---------------------
>  sysdeps/nptl/fork.c              | 11 ++---------
>  sysdeps/nptl/pthread-functions.h |  1 -
>  3 files changed, 2 insertions(+), 31 deletions(-)
> 
> diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
> index 49d811aed7..de64e34783 100644
> --- a/nptl/nptl-init.c
> +++ b/nptl/nptl-init.c
> @@ -60,14 +60,6 @@ int __set_robust_list_avail;
>  /* Version of the library, used in libthread_db to detect mismatches.  */
>  static const char nptl_version[] __attribute_used__ = VERSION;
>  
> -
> -#ifdef SHARED
> -static
> -#else
> -extern
> -#endif
> -void __nptl_set_robust (struct pthread *);
> -
>  #ifdef SHARED
>  static const struct pthread_functions pthread_functions =
>    {
> @@ -92,25 +84,12 @@ static const struct pthread_functions pthread_functions =
>      .ptr___pthread_getspecific = __pthread_getspecific,
>      .ptr___pthread_setspecific = __pthread_setspecific,
>      .ptr__nptl_setxid = __nptl_setxid,
> -    .ptr_set_robust = __nptl_set_robust
>    };
>  # define ptr_pthread_functions &pthread_functions
>  #else
>  # define ptr_pthread_functions NULL
>  #endif
>  
> -
> -#ifdef SHARED
> -static
> -#endif
> -void
> -__nptl_set_robust (struct pthread *self)
> -{
> -  INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
> -			 sizeof (struct robust_list_head));
> -}
> -
> -
>  /* For asynchronous cancellation we use a signal.  This is the handler.  */
>  static void
>  sigcancel_handler (int sig, siginfo_t *si, void *ctx)

Ok.

> diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
> index ffc8f9d041..a2a0643a1d 100644
> --- a/sysdeps/nptl/fork.c
> +++ b/sysdeps/nptl/fork.c
> @@ -104,15 +104,8 @@ __libc_fork (void)
>        self->robust_prev = &self->robust_head;
>  #endif
>        self->robust_head.list = &self->robust_head;
> -#ifdef SHARED
> -      if (__builtin_expect (__libc_pthread_functions_init, 0))
> -	PTHFCT_CALL (ptr_set_robust, (self));
> -#else
> -      extern __typeof (__nptl_set_robust) __nptl_set_robust
> -	__attribute__((weak));
> -      if (__builtin_expect (__nptl_set_robust != NULL, 0))
> -	__nptl_set_robust (self);
> -#endif
> +      INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
> +			     sizeof (struct robust_list_head));
>  
>        /* Reset the lock state in the multi-threaded case.  */
>        if (multiple_threads)

Ok.

> diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h
> index 2092ecef07..844838cd49 100644
> --- a/sysdeps/nptl/pthread-functions.h
> +++ b/sysdeps/nptl/pthread-functions.h
> @@ -53,7 +53,6 @@ struct pthread_functions
>    void *(*ptr___pthread_getspecific) (pthread_key_t);
>    int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
>    int (*ptr__nptl_setxid) (struct xid_command *);
> -  void (*ptr_set_robust) (struct pthread *);
>  };
>  
>  /* Variable in libc.so.  */
> 

Ok.
  

Patch

diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 49d811aed7..de64e34783 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -60,14 +60,6 @@  int __set_robust_list_avail;
 /* Version of the library, used in libthread_db to detect mismatches.  */
 static const char nptl_version[] __attribute_used__ = VERSION;
 
-
-#ifdef SHARED
-static
-#else
-extern
-#endif
-void __nptl_set_robust (struct pthread *);
-
 #ifdef SHARED
 static const struct pthread_functions pthread_functions =
   {
@@ -92,25 +84,12 @@  static const struct pthread_functions pthread_functions =
     .ptr___pthread_getspecific = __pthread_getspecific,
     .ptr___pthread_setspecific = __pthread_setspecific,
     .ptr__nptl_setxid = __nptl_setxid,
-    .ptr_set_robust = __nptl_set_robust
   };
 # define ptr_pthread_functions &pthread_functions
 #else
 # define ptr_pthread_functions NULL
 #endif
 
-
-#ifdef SHARED
-static
-#endif
-void
-__nptl_set_robust (struct pthread *self)
-{
-  INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
-			 sizeof (struct robust_list_head));
-}
-
-
 /* For asynchronous cancellation we use a signal.  This is the handler.  */
 static void
 sigcancel_handler (int sig, siginfo_t *si, void *ctx)
diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index ffc8f9d041..a2a0643a1d 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -104,15 +104,8 @@  __libc_fork (void)
       self->robust_prev = &self->robust_head;
 #endif
       self->robust_head.list = &self->robust_head;
-#ifdef SHARED
-      if (__builtin_expect (__libc_pthread_functions_init, 0))
-	PTHFCT_CALL (ptr_set_robust, (self));
-#else
-      extern __typeof (__nptl_set_robust) __nptl_set_robust
-	__attribute__((weak));
-      if (__builtin_expect (__nptl_set_robust != NULL, 0))
-	__nptl_set_robust (self);
-#endif
+      INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
+			     sizeof (struct robust_list_head));
 
       /* Reset the lock state in the multi-threaded case.  */
       if (multiple_threads)
diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h
index 2092ecef07..844838cd49 100644
--- a/sysdeps/nptl/pthread-functions.h
+++ b/sysdeps/nptl/pthread-functions.h
@@ -53,7 +53,6 @@  struct pthread_functions
   void *(*ptr___pthread_getspecific) (pthread_key_t);
   int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
   int (*ptr__nptl_setxid) (struct xid_command *);
-  void (*ptr_set_robust) (struct pthread *);
 };
 
 /* Variable in libc.so.  */