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 B95C33858D1E for ; Tue, 18 Apr 2023 14:21:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B95C33858D1E 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 1pomD0-00038E-VS; Tue, 18 Apr 2023 10:21:28 -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=+rlm/9slrtNPNVL/MB5lbcsY7pz5wdFgscpET4+VAWw=; b=knqWgwX4liOrkTDy1O49 p2mN3x/s7uyby1Li/2O5UF9EKXOufXbUinWcs4vu+yBZbpFd5o7XFC+xA+s5nUuZhz4Eh50rt/PhJ DxJqHc5Yi9X4Zdh7XEUiJJLBcpirBi2I4vRrCh6mcN3V0H29GEQVl0XYvlX/8gQ1Y+1mg5XhE3vCp 6wC3bYKwMsBN2v3UxoR6TiKtptCLCPOKqCJhTkOZOIZBFi1OlbW45TH1UioKy/x4l+Oa8bW70Tadg PiN0uLjbk/oedesGtFXqlMuQn8PvGB7rHkEZIZYD8VtbxoWeCVcrIEJyPUaDteQ844vOBX8o7wugn X29zqHfnu2Bq1A==; Received: from [109.190.253.11] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pomD0-0004TA-P5; Tue, 18 Apr 2023 10:21:26 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pomCu-00C8ba-2x; Tue, 18 Apr 2023 16:21:20 +0200 Date: Tue, 18 Apr 2023 16:21:20 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [PATCH 2/5] hurd: Microoptimize sigreturn Message-ID: <20230418142120.k2lvnv6oukc2yfht@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230417232353.5w4fhwtgimjjif7r@begin> <20230418102150.10261-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230418102150.10261-1-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_SBL_CSS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Sergey Bugaev, le mar. 18 avril 2023 13:21:50 +0300, a ecrit: > (Git managed to eat my email -- it both sent an empty one *and* > truncated my local file (what?); so retyping and resending this.) > > On Tue, Apr 18, 2023 at 2:23 AM Samuel Thibault wrote: > > That doesn't seem to be true, we get segfaults with this patch applied > > in these tests: > > > > ./htl/tst-kill6.test-result:FAIL: htl/tst-kill6 > > ./htl/tst-pt-tls2.test-result:FAIL: htl/tst-pt-tls2 > > > > #0 0x0105a7c2 in sigstate_is_global_rcv (ss=0x0) at hurdsig.c:183 > > 183 && (ss->actions[0].sa_handler == SIG_IGN); > > (gdb) bt > > #0 0x0105a7c2 in sigstate_is_global_rcv (ss=0x0) at hurdsig.c:183 > > #1 __GI__hurd_sigstate_lock (ss=0x0) at hurdsig.c:192 > > #2 0x0108bb17 in __sigreturn (scp=0x2104bec) at ../sysdeps/mach/hurd/i386/sigreturn.c:94 > > #3 0x010602f6 in trampoline () from ./libc.so.0.3 > > Interesting; so while the sigstate for the thread must have been > initialized, it seems it has never been installed into the > tcb->_hurd_sigstate slot, because the thread has never called > _hurd_self_sigstate (). So we have to make the full call to > _hurd_self_sigstate () the first time, to find the sigstate and > install it into the slot. > > Please try this: That one works fine, applied, thanks! > Sergey > > ---- >8 ---- > > > From 94fc9499390b4de9fbe10c3014d473ac42878c6a Mon Sep 17 00:00:00 2001 > From: Sergey Bugaev > Date: Fri, 14 Apr 2023 16:32:45 +0300 > Subject: [PATCH] hurd: Microoptimize sigreturn > > Signed-off-by: Sergey Bugaev > --- > sysdeps/mach/hurd/i386/sigreturn.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c > index a0fc8891..1686734d 100644 > --- a/sysdeps/mach/hurd/i386/sigreturn.c > +++ b/sysdeps/mach/hurd/i386/sigreturn.c > @@ -29,7 +29,12 @@ static void > __sigreturn2 (int *usp, struct sigcontext *scp) > { > mach_port_t reply_port; > - struct hurd_sigstate *ss = _hurd_self_sigstate (); > + struct hurd_sigstate *ss; > + > + /* We know the sigstate must be initialized by the call below, but the > + compiler does not. Help it out a little bit by eliding the check that > + _hurd_self_sigstate makes otherwise. */ > + ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate); > _hurd_sigstate_unlock (ss); > > /* Destroy the MiG reply port used by the signal handler, and restore the > @@ -44,7 +49,7 @@ __sigreturn2 (int *usp, struct sigcontext *scp) > do. */ > reply_port = THREAD_GETMEM (THREAD_SELF, reply_port); > THREAD_SETMEM (THREAD_SELF, reply_port, MACH_PORT_DEAD); > - if (MACH_PORT_VALID (reply_port)) > + if (__glibc_likely (MACH_PORT_VALID (reply_port))) > (void) __mach_port_mod_refs (__mach_task_self (), reply_port, > MACH_PORT_RIGHT_RECEIVE, -1); > THREAD_SETMEM (THREAD_SELF, reply_port, scp->sc_reply_port); > @@ -69,6 +74,7 @@ __sigreturn2 (int *usp, struct sigcontext *scp) > /* Firewall. */ > A (hlt); > #undef A > + __builtin_unreachable (); > } > > int > @@ -77,7 +83,7 @@ __sigreturn (struct sigcontext *scp) > struct hurd_sigstate *ss; > struct hurd_userlink *link = (void *) &scp[1]; > > - if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK)) > + if (__glibc_unlikely (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))) > { > errno = EINVAL; > return -1; > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.