From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 665953858CDB for ; Sun, 2 Apr 2023 23:26:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 665953858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj75I-000569-0F; Sun, 02 Apr 2023 19:26:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=YS9Zo/23DI151qPon9Tj5AY9qPeKkILlroJQxQMngec=; b=hkhvwK4VRKFlpW7QzHWC ebWEJyDsymWaGXMfYV54AkXSs5pldt+PPSriLU37fgLqQiI5pI/nxgn5UM53rjIfNlHc7ZfoMEW6F KAq1VNWzWXgRNmIcKJBl9X3eg3FxbWkmsEvFTv6FvsvKCSqRbTmakmRFNnPv2f4pik0UhmLrEDnor JmoqY8wbkl2Ew7NMqLgjYB0pcFHgqP1aAELGU/eL5JCPbr2hAzqPOeg40w3zGQVBEhLumzxu1CgzZ 3U8bjcCSuzLFIPM3XJeImlhh7JNy2W5SnpydM8P6C7GDlVsjsz3QRpI4ehYt2Z+0CyHlwfscGlThF GecUnvAdzedqdQ==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj75H-0001Rj-QW; Sun, 02 Apr 2023 19:26:03 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pj75G-00AtqD-2G; Mon, 03 Apr 2023 01:26:02 +0200 Date: Mon, 3 Apr 2023 01:26:02 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [RFC PATCH glibc 31/34] hurd: Microoptimize _hurd_self_sigstate () Message-ID: <20230402232602.p44cuiu4kq2ks5vo@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230319151017.531737-1-bugaevc@gmail.com> <20230319151017.531737-32-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230319151017.531737-32-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Sergey Bugaev, le dim. 19 mars 2023 18:10:14 +0300, a ecrit: > When THREAD_GETMEM is defined with inline assembly, the compiler may not > optimize away the two reads of _hurd_sigstate. Help it out a little bit > by only reading it once. This also makes for a slightly cleaner code. > > Signed-off-by: Sergey Bugaev > --- > hurd/hurd/signal.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h > index c33f974b..662e955e 100644 > --- a/hurd/hurd/signal.h > +++ b/hurd/hurd/signal.h > @@ -166,13 +166,15 @@ extern void _hurd_sigstate_delete (thread_t thread); > _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * > _hurd_self_sigstate (void) > { > - if (THREAD_GETMEM (THREAD_SELF, _hurd_sigstate) == NULL) > + struct hurd_sigstate *ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate); > + if (__glibc_unlikely (ss == NULL)) > { > thread_t self = __mach_thread_self (); > - THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, _hurd_thread_sigstate (self)); > + ss = _hurd_thread_sigstate (self); > + THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, ss); > __mach_port_deallocate (__mach_task_self (), self); > } > - return THREAD_GETMEM (THREAD_SELF, _hurd_sigstate); > + return ss; > } > # endif > #endif > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.