Message ID | 20230319151017.531737-32-bugaevc@gmail.com |
---|---|
State | Committed, archived |
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 341C0392AC18 for <patchwork@sourceware.org>; Sun, 19 Mar 2023 15:15:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 341C0392AC18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679238929; bh=rXQmKXz6KAthIAyxftRLxsuDtb5rqyotVrKOeanOpIM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=DjZeseJBMU1xu+FSn9hP2Kzt+YKn1uxR3a1Jiitb4ASccOAWMfHd32FiFeL70nlsu umEwIvXuPvlrrQTs51MHRPcbvyi8pRWIGgu6P9CjXcQlF5vOuCGuJosnUOe5RfjXeW Bp99q71W6wckObBVcFyv43J+zeIMu3E3gg9Y5WLo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id DD03E385085B for <libc-alpha@sourceware.org>; Sun, 19 Mar 2023 15:11:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD03E385085B Received: by mail-lf1-x12f.google.com with SMTP id y15so12011635lfa.7 for <libc-alpha@sourceware.org>; Sun, 19 Mar 2023 08:11:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679238686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rXQmKXz6KAthIAyxftRLxsuDtb5rqyotVrKOeanOpIM=; b=HmLWVR8NfUh+By7yp9Lcxqjh8ZCFRug+P1+2krTiGFiDWowkO5d43sP09lx0iB9jOQ dx9eIOARmBkLcssmzynnNFYgvOLjjawciP8S/0WOAvCq4qE86y38M2syoVtyT24aA+Y+ mb+3w+ZcjYSXNNage0qgV3g+4QOO6c+8FMkM2/Nf0fgQUuGygwonqghAcAJWVF7HO3Bb T95feOVKx01jYsHHT0zQlq+BlCsIBJyMoO3yaD+SDTCzqBET/hXdPMOG/n4LhEYYgR04 Cqh7Xan1n9l9NoBProO48Aw39MSrLrFlRDQzaz2QiLTUyUhLNsb2mstQNAuE+xAebgay E6gA== X-Gm-Message-State: AO0yUKV4X5ewDG0kSrjWIXBTuda/dNIe9ffh1pXaxbJuqS7kY2w4kgAx caDkvGkI9sbEkJ/crTq4OcWs0cORo5OMQQ== X-Google-Smtp-Source: AK7set/oNdJOa0+s1fw6dP4RNVVewZrHLkxHn6OMW+m4xgc5Y/6ZSQeyI39luoXio4tRMYWCbuhlCQ== X-Received: by 2002:ac2:5fa9:0:b0:4dd:a788:7783 with SMTP id s9-20020ac25fa9000000b004dda7887783mr5278675lfe.61.1679238686189; Sun, 19 Mar 2023 08:11:26 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:577a:76f4:df43:5e66]) by smtp.gmail.com with ESMTPSA id m19-20020ac24253000000b004e90dee5469sm1274089lfl.157.2023.03.19.08.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 08:11:25 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault <samuel.thibault@gnu.org>, Sergey Bugaev <bugaevc@gmail.com> Subject: [RFC PATCH glibc 31/34] hurd: Microoptimize _hurd_self_sigstate () Date: Sun, 19 Mar 2023 18:10:14 +0300 Message-Id: <20230319151017.531737-32-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319151017.531737-1-bugaevc@gmail.com> References: <20230319151017.531737-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Sergey Bugaev via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Sergey Bugaev <bugaevc@gmail.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
The rest of the x86_64-gnu port
|
|
Checks
Context | Check | Description |
---|---|---|
dj/TryBot-apply_patch | success | Patch applied to master at the time it was sent |
Commit Message
Sergey Bugaev
March 19, 2023, 3:10 p.m. UTC
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 <bugaevc@gmail.com>
---
hurd/hurd/signal.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Comments
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 <bugaevc@gmail.com> > --- > 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 >
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