git: 6ad07a4b2bdf - main - linux(4): Microoptimize rt_sendsig() on amd64.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Feb 2023 17:22:07 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6ad07a4b2bdf0856545ff8495a7b3396695814fa commit 6ad07a4b2bdf0856545ff8495a7b3396695814fa Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2023-02-02 17:21:37 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> 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;