From owner-svn-src-head@freebsd.org Fri Oct 20 03:30:04 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84861E4E611; Fri, 20 Oct 2017 03:30:04 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 608406583B; Fri, 20 Oct 2017 03:30:04 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9K3U3D7012719; Fri, 20 Oct 2017 03:30:03 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9K3U3kO012713; Fri, 20 Oct 2017 03:30:03 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201710200330.v9K3U3kO012713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 20 Oct 2017 03:30:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324785 - in head/sys/amd64: amd64 ia32 linux linux32 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys/amd64: amd64 ia32 linux linux32 X-SVN-Commit-Revision: 324785 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 03:30:04 -0000 Author: mjg Date: Fri Oct 20 03:30:02 2017 New Revision: 324785 URL: https://svnweb.freebsd.org/changeset/base/324785 Log: amd64: avoid acquiring dt lock if possible (which is the common case) Discussed with: kib MFC after: 1 week Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/sys_machdep.c head/sys/amd64/amd64/vm_machdep.c head/sys/amd64/ia32/ia32_signal.c head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux32_sysvec.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/amd64/machdep.c Fri Oct 20 03:30:02 2017 (r324785) @@ -581,12 +581,9 @@ exec_setregs(struct thread *td, struct image_params *i struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; - mtx_lock(&dt_lock); if (td->td_proc->p_md.md_ldt != NULL) user_ldt_free(td); - else - mtx_unlock(&dt_lock); - + update_pcb_bases(pcb); pcb->pcb_fsbase = 0; pcb->pcb_gsbase = 0; Modified: head/sys/amd64/amd64/sys_machdep.c ============================================================================== --- head/sys/amd64/amd64/sys_machdep.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/amd64/sys_machdep.c Fri Oct 20 03:30:02 2017 (r324785) @@ -500,7 +500,7 @@ user_ldt_free(struct thread *td) struct mdproc *mdp = &p->p_md; struct proc_ldt *pldt; - mtx_assert(&dt_lock, MA_OWNED); + mtx_lock(&dt_lock); if ((pldt = mdp->md_ldt) == NULL) { mtx_unlock(&dt_lock); return; Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/amd64/vm_machdep.c Fri Oct 20 03:30:02 2017 (r324785) @@ -299,11 +299,8 @@ cpu_exit(struct thread *td) /* * If this process has a custom LDT, release it. */ - mtx_lock(&dt_lock); - if (td->td_proc->p_md.md_ldt != 0) + if (td->td_proc->p_md.md_ldt != NULL) user_ldt_free(td); - else - mtx_unlock(&dt_lock); } void Modified: head/sys/amd64/ia32/ia32_signal.c ============================================================================== --- head/sys/amd64/ia32/ia32_signal.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/ia32/ia32_signal.c Fri Oct 20 03:30:02 2017 (r324785) @@ -937,12 +937,9 @@ ia32_setregs(struct thread *td, struct image_params *i { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; - - mtx_lock(&dt_lock); + if (td->td_proc->p_md.md_ldt != NULL) user_ldt_free(td); - else - mtx_unlock(&dt_lock); #ifdef COMPAT_43 setup_lcall_gate(); #endif Modified: head/sys/amd64/linux/linux_sysvec.c ============================================================================== --- head/sys/amd64/linux/linux_sysvec.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/linux/linux_sysvec.c Fri Oct 20 03:30:02 2017 (r324785) @@ -453,11 +453,8 @@ linux_exec_setregs(struct thread *td, struct image_par struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; - mtx_lock(&dt_lock); if (td->td_proc->p_md.md_ldt != NULL) user_ldt_free(td); - else - mtx_unlock(&dt_lock); pcb->pcb_fsbase = 0; pcb->pcb_gsbase = 0; Modified: head/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysvec.c Fri Oct 20 03:13:31 2017 (r324784) +++ head/sys/amd64/linux32/linux32_sysvec.c Fri Oct 20 03:30:02 2017 (r324785) @@ -804,11 +804,8 @@ exec_linux_setregs(struct thread *td, struct image_par struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; - mtx_lock(&dt_lock); if (td->td_proc->p_md.md_ldt != NULL) user_ldt_free(td); - else - mtx_unlock(&dt_lock); critical_enter(); wrmsr(MSR_FSBASE, 0);