svn commit: r324785 - in head/sys/amd64: amd64 ia32 linux linux32
Mateusz Guzik
mjg at FreeBSD.org
Fri Oct 20 03:30:04 UTC 2017
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);
More information about the svn-src-all
mailing list