public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 05/13] Linux: Simplify and fix the definition of SINGLE_THREAD_P
Date: Sun, 9 May 2021 17:42:12 -0400	[thread overview]
Message-ID: <1aa4e5bc-ddf8-de76-1e61-b84531a81e04@redhat.com> (raw)
In-Reply-To: <c6656da0ca95243eaae4bfc5988ba6a14fb211e4.1620323953.git.fweimer@redhat.com>

On 5/6/21 2:10 PM, Florian Weimer via Libc-alpha wrote:
> Always use __libc_multiple_threads if beneficial, and do not assume
> the the dynamic loader is single-threaded.  This assumption could
> become incorrect by accident once more code is moved from libpthread
> into it.  The previous commit introducing the
> NO_SYSCALL_CANCEL_CHECKING macro enables this change.
> 
> Do not hint to the compiler that multi-threaded programs are unlikely
> (which is not quite true anymore).

LGTM.

Tested on x86_64 and i686 without regression.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/single-thread.h | 36 +++++--------------------
>  1 file changed, 7 insertions(+), 29 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/single-thread.h b/sysdeps/unix/sysv/linux/single-thread.h
> index 841f8c69d5..2fac8dcc11 100644
> --- a/sysdeps/unix/sysv/linux/single-thread.h
> +++ b/sysdeps/unix/sysv/linux/single-thread.h
> @@ -32,35 +32,13 @@ extern int __libc_multiple_threads;
>  libc_hidden_proto (__libc_multiple_threads)
>  #endif
>  
> -#ifdef SINGLE_THREAD_BY_GLOBAL
> -# if IS_IN (libc)
> -#  define SINGLE_THREAD_P \
> -  __glibc_likely (__libc_multiple_threads == 0)
> -# elif IS_IN (libpthread)
> -extern int __pthread_multiple_threads;
> -#  define SINGLE_THREAD_P \
> -  __glibc_likely (__pthread_multiple_threads == 0)
> -# elif IS_IN (librt)
> -#   define SINGLE_THREAD_P					\
> -  __glibc_likely (THREAD_GETMEM (THREAD_SELF,			\
> -				 header.multiple_threads) == 0)
> -# else
> -/* For rtld, et cetera.  */
> -#  define SINGLE_THREAD_P (1)
> -# endif
> -#else /* SINGLE_THREAD_BY_GLOBAL  */
> -# if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
> -#   define SINGLE_THREAD_P					\
> -  __glibc_likely (THREAD_GETMEM (THREAD_SELF,			\
> -				 header.multiple_threads) == 0)
> -# else
> -/* For rtld, et cetera.  */
> -#  define SINGLE_THREAD_P (1)
> -# endif
> -#endif /* SINGLE_THREAD_BY_GLOBAL  */
> +#if !defined SINGLE_THREAD_BY_GLOBAL || IS_IN (rtld)
> +# define SINGLE_THREAD_P \
> +  (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0)
> +#else
> +# define SINGLE_THREAD_P (__libc_multiple_threads == 0)
> +#endif
>  
> -#define RTLD_SINGLE_THREAD_P \
> -  __glibc_likely (THREAD_GETMEM (THREAD_SELF, \
> -				 header.multiple_threads) == 0)
> +#define RTLD_SINGLE_THREAD_P SINGLE_THREAD_P
>  
>  #endif /* _SINGLE_THREAD_H  */
> 


-- 
Cheers,
Carlos.


  reply	other threads:[~2021-05-09 21:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 18:08 [PATCH 00/13] Linux: Move most stack management out of libpthread Florian Weimer
2021-05-06 18:08 ` [PATCH 01/13] scripts/versions.awk: Add strings and hashes to <first-versions.h> Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:09 ` [PATCH v2 02/13] elf, nptl: Resolve recursive lock implementation early Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-10  5:54     ` Florian Weimer
2021-05-06 18:10 ` [PATCH 03/13] nptl: Export __libc_multiple_threads from libc as an internal symbol Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:10 ` [PATCH 04/13] Linux: Explicitly disable cancellation checking in the dynamic loader Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:10 ` [PATCH 05/13] Linux: Simplify and fix the definition of SINGLE_THREAD_P Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell [this message]
2021-05-06 18:10 ` [PATCH 06/13] nptl: Eliminate __pthread_multiple_threads Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:10 ` [PATCH 07/13] elf: Introduce __tls_pre_init_tp Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:10 ` [PATCH 08/13] nptl: Move more stack management variables into _rtld_global Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:11 ` [PATCH 09/13] nptl: Simplify the change_stack_perm calling convention Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:11 ` [PATCH 10/13] nptl: Move changing of stack permissions into ld.so Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:11 ` [PATCH 11/13] nptl: Simplify resetting the in-flight stack in __reclaim_stacks Florian Weimer
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:11 ` [PATCH 12/13] nptl: Move __default_pthread_attr, __default_pthread_attr_lock into libc Florian Weimer
2021-05-09 21:41   ` Carlos O'Donell
2021-05-09 21:42   ` Carlos O'Donell
2021-05-06 18:11 ` [PATCH 13/13] Linux: Move __reclaim_stacks into the fork implementation in libc Florian Weimer
2021-05-09 21:41   ` Carlos O'Donell
2021-05-09 21:42 ` [PATCH 00/13] Linux: Move most stack management out of libpthread Carlos O'Donell

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=1aa4e5bc-ddf8-de76-1e61-b84531a81e04@redhat.com \
    --to=carlos@redhat.com \
    --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).