From nobody Thu Feb 09 07:56:48 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 4PC8Mj5B3Jz3myTV; Thu, 9 Feb 2023 07:56:49 +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 4PC8Mj1TdMz4583; Thu, 9 Feb 2023 07:56:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929409; 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=9rbyhyqciJ863dxRV4iIqyLXswfcZ8flt78rngL/K8U=; b=L1xn57e5n/fYoKetFrII0aGhf6LO2+JLkt7uy7oFPD85kpEQpN80Si4ZpBkZBObkZsXYJ+ XOPPzyh/HSubT1DHlAFyfd0D6y36MOJioFqWdw+WraOQTyUSIlovBoC/QqZEyXh8dBcOC9 GxMaPmed8YnqXbvCXx5LG9+n0AYRhJz9hX2rCKT6jESteClgKklbeeIxSUAhRGjChQzx8M X3Rv/DYsKUb2JDLcdATOWKQyjH5KCNwWavBojhR4im6fYjsJN9zN/WpKR45YckjvvimWPo Qd5lTq1iLGZEZC5TRag+avq5ZKXXKjop2QIM6HWjPSWNCKY8Di7WwHhsn0JHcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929409; 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=9rbyhyqciJ863dxRV4iIqyLXswfcZ8flt78rngL/K8U=; b=ZdA9PKowdkKDJjCPo9a6sA29/v1O1dePH5Cx/HVI02sQ+IUl5Gt/RNCd/c7oVS7DHX5IN6 40h31L5Pl+004jROZQHBhb3ozj1E9AkIjWWS1MbIYcDKWAjsIVmkj3Hxy+Rw2aKX21tdGO TWqhhPo8Dc5Ilx7bmAgkxwG9+AuPXzvZ52HDSH9/idOWo3Yi9B7wCFWzmEib/arRm3SL28 fpaSWBurjvDYRajxv7c25Jd8eUh7SeH7ZL17x/MZvs9zjHawGhbeBv8eZSJSHrfS1pYtOW CEQu2qCa0sot8f982u0RgaX32BULkPVJY1f1ZwaIFfs3MrA/9oEWXzDlZ2EzGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675929409; a=rsa-sha256; cv=none; b=g0FxBLiODQaPyEze1Dl0lq8b3/W4dcgqEg35mW+86b7W2ZZiDwkO86Jdns2wbahZCLtb2d d52p6omKtVWh1l0wWctbZ7xMvtT++ctgS4o6QIWF14izsNjiENhVlMURN5to6/DX36auFo ygA/TxfIYfkrosbiGCYJPr110wTztC1xbfBULWuz1GcgmJYA6tUR9oYl3gOXG8CFurwFA9 /oT3fN3kxpXe/Z6sguriaNgpBCcJwSZe/pomzkmhbjvwjFn30oxCNP3X8vYlTnJF8bWdx1 xFCRZPywBDGnoTrXI4N8oc+sxfxbEVFKFAXesbA67Y5oEOmPYcDLG8q0sch2zg== 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 4PC8Mh6g6nzVHj; Thu, 9 Feb 2023 07:56:48 +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 3197umUv093024; Thu, 9 Feb 2023 07:56:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3197umDM093023; Thu, 9 Feb 2023 07:56:48 GMT (envelope-from git) Date: Thu, 9 Feb 2023 07:56:48 GMT Message-Id: <202302090756.3197umDM093023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: b69b287a0969 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: b69b287a0969b9dd27a3184b2141e9a580a64535 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b69b287a0969b9dd27a3184b2141e9a580a64535 commit b69b287a0969b9dd27a3184b2141e9a580a64535 Author: Dmitry Chagin AuthorDate: 2023-02-02 17:21:37 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-09 07:55:24 +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 (cherry picked from commit 6ad07a4b2bdf0856545ff8495a7b3396695814fa) --- 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 9e36f8739556..d7e33ccb8b70 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -464,16 +464,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; @@ -497,19 +510,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;