From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 4585F3951848 for ; Sun, 9 May 2021 21:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4585F3951848 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-uhALebZ2P9ad0ot_Z_b0WA-1; Sun, 09 May 2021 17:42:14 -0400 X-MC-Unique: uhALebZ2P9ad0ot_Z_b0WA-1 Received: by mail-qv1-f72.google.com with SMTP id l61-20020a0c84430000b02901a9a7e363edso10977264qva.16 for ; Sun, 09 May 2021 14:42:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Ss/6kSdeTW3yqaPGamR1u5Eb3Qxp2TwXYCmqVPy8vvE=; b=BL+BN9PlTGkTXt5fRkes8jNPn1hm2lP0yTWWePSqoPL845PpLPcaHmWsELj/xPbso4 SnIO9UQ00xidAl4ZeDSuX7CICQ3DBwNS5lEzjpoQyogxym2ivhDOPu7Td3MofR83yyCx KRv6UJwb4Wrv4uJx2nF2DWQNXMEe4PpualkFYUkxCa2239IBJEUwWGGc4EC5A2naF4ft uG3HlgeIjxxTORhscqj8t/r1l6wKQdOCyPbZ+RiXWL7VJpoUz1n9yeI6ScIGsG7UjOOP YVUqxhreWKc61VZH9J9PzUcTKT8Q9fcXxZktHlCcfSS6D1QhQKNUCpze3s4wy0/N1a4J V0lQ== X-Gm-Message-State: AOAM532iAqSsmp3ARoTtzsNwAno3YnJZuEPwJ90vpbAuAGl3PKghPvYo 0Cbt7Ui0Ojl5ijJkaf+2UIUJZSAFGaBuztSzEanCahD8EhY3nMbEl7QONIupWRhW2FvgYtpQdk9 6ZFaIGvAqrrvGl4ztMVKkFGHwqQ6fZbCVUXpHoExS8ph+JJmu2Ku19V/vqgzlz6YlIlP2rA== X-Received: by 2002:ac8:1014:: with SMTP id z20mr19646071qti.65.1620596533935; Sun, 09 May 2021 14:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLXCkLXro3W6F1txpLxt+livIlaTgOrVHX9jlt/QXVo4gsMy9Vs3GHspCSR8TuV0CpWohflA== X-Received: by 2002:ac8:1014:: with SMTP id z20mr19646057qti.65.1620596533718; Sun, 09 May 2021 14:42:13 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id w7sm9968772qtn.91.2021.05.09.14.42.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 May 2021 14:42:13 -0700 (PDT) Subject: Re: [PATCH 05/13] Linux: Simplify and fix the definition of SINGLE_THREAD_P To: Florian Weimer , libc-alpha@sourceware.org References: From: Carlos O'Donell Organization: Red Hat Message-ID: <1aa4e5bc-ddf8-de76-1e61-b84531a81e04@redhat.com> Date: Sun, 9 May 2021 17:42:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 May 2021 21:42:18 -0000 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 Reviewed-by: Carlos O'Donell > --- > 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.