Module Name: src
Committed By: chs
Date: Sun Nov 4 00:32:47 UTC 2012
Modified Files:
src/sys/arch/sparc/sparc: locore.s pmap.c
Log Message:
in cpu_switchto(), remove the MP-unsafe code to mark a pmap active on a CPU,
pmap_activate() already does this. add MP locking to pmap_activate()
and pmap_deactivate(). move flushing of user windows and virtual caches
from pamp_activate() to pmap_deactivate().
To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/arch/sparc/sparc/locore.s
cvs rdiff -u -r1.348 -r1.349 src/sys/arch/sparc/sparc/pmap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.267 src/sys/arch/sparc/sparc/locore.s:1.268
--- src/sys/arch/sparc/sparc/locore.s:1.267 Fri Nov 2 00:01:19 2012
+++ src/sys/arch/sparc/sparc/locore.s Sun Nov 4 00:32:47 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.267 2012/11/02 00:01:19 chs Exp $ */
+/* $NetBSD: locore.s,v 1.268 2012/11/04 00:32:47 chs Exp $ */
/*
* Copyright (c) 1996 Paul Kranenburg
@@ -4935,19 +4935,6 @@ Lnosaveoldlwp:
/*
* Now running p.
*/
-#if defined(MULTIPROCESSOR)
- ld [%g3 + L_PROC], %o2 ! p = l->l_proc;
- ld [%o2 + P_VMSPACE], %o3 ! vm = p->p_vmspace;
- ld [%o3 + VM_PMAP], %o4 ! pm = vm->vm_map.vm_pmap;
- /* Add this CPU to the pmap's CPU set */
- sethi %hi(CPUINFO_VA + CPUINFO_CPUNO), %o0
- ld [%o0 + %lo(CPUINFO_VA + CPUINFO_CPUNO)], %o1
- mov 1, %o2
- ld [%o4 + PMAP_CPUSET], %o0
- sll %o2, %o1, %o2
- or %o0, %o2, %o0 ! pm->pm_cpuset |= cpu_number();
- st %o0, [%o4 + PMAP_CPUSET]
-#endif
/*
* Check for restartable atomic sequences (RAS)
Index: src/sys/arch/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.348 src/sys/arch/sparc/sparc/pmap.c:1.349
--- src/sys/arch/sparc/sparc/pmap.c:1.348 Sun Jan 29 11:49:58 2012
+++ src/sys/arch/sparc/sparc/pmap.c Sun Nov 4 00:32:47 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.348 2012/01/29 11:49:58 para Exp $ */
+/* $NetBSD: pmap.c,v 1.349 2012/11/04 00:32:47 chs Exp $ */
/*
* Copyright (c) 1996
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.348 2012/01/29 11:49:58 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.349 2012/11/04 00:32:47 chs Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -7440,31 +7440,19 @@ void
pmap_activate(struct lwp *l)
{
pmap_t pm = l->l_proc->p_vmspace->vm_map.pmap;
- int s;
- /*
- * This is essentially the same thing that happens in cpu_switch()
- * when the newly selected process is about to run, except that we
- * have to make sure to clean the register windows before we set
- * the new context.
- */
+ if (pm == pmap_kernel() || l != curlwp) {
+ return;
+ }
- s = splvm();
- if (l == curlwp) {
- write_user_windows();
- if (pm->pm_ctx == NULL) {
- ctx_alloc(pm); /* performs setcontext() */
- } else {
- /* Do any cache flush needed on context switch */
- (*cpuinfo.pure_vcache_flush)();
- setcontext(pm->pm_ctxnum);
- }
-#if defined(MULTIPROCESSOR)
- if (pm != pmap_kernel())
- PMAP_SET_CPUSET(pm, &cpuinfo);
-#endif
+ PMAP_LOCK();
+ if (pm->pm_ctx == NULL) {
+ ctx_alloc(pm); /* performs setcontext() */
+ } else {
+ setcontext(pm->pm_ctxnum);
}
- splx(s);
+ PMAP_SET_CPUSET(pm, &cpuinfo);
+ PMAP_UNLOCK();
}
/*
@@ -7473,22 +7461,27 @@ pmap_activate(struct lwp *l)
void
pmap_deactivate(struct lwp *l)
{
-#if defined(MULTIPROCESSOR)
- pmap_t pm;
- struct proc *p;
+ struct proc *p = l->l_proc;
+ pmap_t pm = p->p_vmspace->vm_map.pmap;
+
+ if (pm == pmap_kernel() || l != curlwp) {
+ return;
+ }
+
+ write_user_windows();
+ PMAP_LOCK();
+ if (pm->pm_ctx) {
+ (*cpuinfo.pure_vcache_flush)();
- p = l->l_proc;
- if (p->p_vmspace &&
- (pm = p->p_vmspace->vm_map.pmap) != pmap_kernel()) {
#if defined(SUN4M) || defined(SUN4D)
- if (pm->pm_ctx && CPU_HAS_SRMMU)
+ if (CPU_HAS_SRMMU)
sp_tlb_flush(0, pm->pm_ctxnum, ASI_SRMMUFP_L0);
#endif
-
- /* we no longer need broadcast tlb flushes for this pmap. */
- PMAP_CLR_CPUSET(pm, &cpuinfo);
}
-#endif
+
+ /* we no longer need broadcast tlb flushes for this pmap. */
+ PMAP_CLR_CPUSET(pm, &cpuinfo);
+ PMAP_UNLOCK();
}
#ifdef DEBUG