From nobody Thu Feb 02 17:22:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P75FD0hPFz3kNNT; Thu, 2 Feb 2023 17:22:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P75FC6NKDz3vvs; Thu, 2 Feb 2023 17:22:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675358527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1FOgRrXmCCczMr/3NUkfAtbqG7/SFInFasxA3k2CItk=; b=C7KNQrZbhnu+YQH1c+DcvNyXFbaVz6x8RKy95ZyEHYg6UjB9bB84Wn23rLDj4ZU1Bd5ZRK 9Ig8M9adjij5cAlHEh76L1RUg21hKcO9vpJwaHQ5EDG5lhMJynzE3NbmbfoYfpPwVqMRlh n9UaXxc9AilBhx4ZbKjkBpg0bWUbc903INbuCIPy6zJaF4suZCIpkndgHdwenAUMTv6BLB 7CaOSTkTX6I8HuVlXKpMMx1hgZl+OYWVrHUE7pTRNq+DM635eooIQaE784fdVMLK6wkuGh JTntVOhD65I+woY2uQ+6PfJzERPqSzHV6bZV6XAISpEphD1S2vGyr27ZFvXxHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675358527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1FOgRrXmCCczMr/3NUkfAtbqG7/SFInFasxA3k2CItk=; b=ncDYPPeCtoqYHIhcJeRvNhBsXuyyK7hqtr0ys1huviuwXdnkYeNp5/WSSFjgJ0RcL0Fdpi yoEfLDsIlrxKi4B+Ordf249iu/1OFTH2sTSaTovEXsTUDFyF4NA8J2bfnV6TC0PdZj6k8q WPG5YUCG0GR6mZvPKw59odOgu74vywawZnRoSzku1FpgD97En8BtoQRvw7/4TAYep35gqY vwGNNZXMPIyb7YlTNV2DMEkoxixPXvoqIHaU2ZxAJyWefd7JRnKUp5ow8VdY9103sxTQob 5/qfRDOV9lhlCqVJfL2umNsNhhHptp6zIvFgjCClWMocZBTNmp30ZYVeJ19shg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675358527; a=rsa-sha256; cv=none; b=avtQfwV56IPDSQapwbYz7gClDRSkLjzju+vUJDl16+ZEZ2HxroQAnb9wPwDoDH+M+3YmO4 Ec+Xqjs4K9G1MXNyGCzz7fN5Rf1IMB7C5Yp6c/3834NvylxI3CgMHJUVXuhGXtGc8aG20E 4GAdMY2bEeP56eWdp7IrzQIfK6mGiAUbilAuBrVH5f0k6vQPYVT2xdyGLygbgUjY7mX6Ft oXkYjcwjR1nGLmuNvg8Xh14P1HUjiLCyifB4+1KWKw1F5fPfE8MkVJJ1HkK94LZlbofGe5 jxf7zsKXQ8OVWWVlFR9aX9PW6R95ApSvhs6uTsHrfKbLI3r678wZJ85jZNVgtw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P75FC5T8Hz12xQ; Thu, 2 Feb 2023 17:22:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 312HM794004621; Thu, 2 Feb 2023 17:22:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312HM723004620; Thu, 2 Feb 2023 17:22:07 GMT (envelope-from git) Date: Thu, 2 Feb 2023 17:22:07 GMT Message-Id: <202302021722.312HM723004620@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6ad07a4b2bdf - main - linux(4): Microoptimize rt_sendsig() on amd64. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ad07a4b2bdf0856545ff8495a7b3396695814fa Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6ad07a4b2bdf0856545ff8495a7b3396695814fa commit 6ad07a4b2bdf0856545ff8495a7b3396695814fa Author: Dmitry Chagin AuthorDate: 2023-02-02 17:21:37 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-02 17:21:37 +0000 linux(4): Microoptimize rt_sendsig() on amd64. Drop proc lock earlier, before copying user stuff. Pointed out by: kib Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D38326 MFC after: 1 week --- sys/amd64/linux/linux_sysvec.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index c75dc6a26437..e8a22b60e66f 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -465,16 +465,29 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) LINUX_CTR4(rt_sendsig, "%p, %d, %p, %u", catcher, sig, mask, code); - /* Save user context. */ bzero(&sf, sizeof(sf)); - bsd_to_linux_sigset(mask, &sf.sf_uc.uc_sigmask); - sf.sf_uc.uc_mcontext.sc_mask = sf.sf_uc.uc_sigmask; - sf.sf_uc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); sf.sf_uc.uc_stack.ss_size = td->td_sigstk.ss_size; sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE; + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + sp = (caddr_t)td->td_sigstk.ss_sp + td->td_sigstk.ss_size; + } else + sp = (caddr_t)regs->tf_rsp - 128; + + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* Make room, keeping the stack aligned. */ + sp -= sizeof(struct l_rt_sigframe); + sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul); + + /* Save user context. */ + bsd_to_linux_sigset(mask, &sf.sf_uc.uc_sigmask); + sf.sf_uc.uc_mcontext.sc_mask = sf.sf_uc.uc_sigmask; sf.sf_uc.uc_mcontext.sc_rdi = regs->tf_rdi; sf.sf_uc.uc_mcontext.sc_rsi = regs->tf_rsi; sf.sf_uc.uc_mcontext.sc_rdx = regs->tf_rdx; @@ -498,19 +511,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) sf.sf_uc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code); sf.sf_uc.uc_mcontext.sc_cr2 = (register_t)ksi->ksi_addr; - /* Allocate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - sp = (caddr_t)td->td_sigstk.ss_sp + td->td_sigstk.ss_size; - } else - sp = (caddr_t)regs->tf_rsp - 128; - sp -= sizeof(struct l_rt_sigframe); - /* Align to 16 bytes. */ - sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul); - - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - get_fpcontext(td, &mc, NULL, NULL); KASSERT(mc.mc_fpformat != _MC_FPFMT_NODEV, ("fpu not present")); svfp = (struct savefpu *)mc.mc_fpstate;