Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/sparc in cpu_switchto(), remove the MP-unsafe...
details: https://anonhg.NetBSD.org/src/rev/89dc3b8c07a7
branches: trunk
changeset: 782473:89dc3b8c07a7
user: chs <chs%NetBSD.org@localhost>
date: Sun Nov 04 00:32:47 2012 +0000
description:
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().
diffstat:
sys/arch/sparc/sparc/locore.s | 15 +--------
sys/arch/sparc/sparc/pmap.c | 73 +++++++++++++++++++-----------------------
2 files changed, 34 insertions(+), 54 deletions(-)
diffs (133 lines):
diff -r 7e7f74d31227 -r 89dc3b8c07a7 sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s Sat Nov 03 23:42:27 2012 +0000
+++ b/sys/arch/sparc/sparc/locore.s Sun Nov 04 00:32:47 2012 +0000
@@ -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 @@
/*
* 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)
diff -r 7e7f74d31227 -r 89dc3b8c07a7 sys/arch/sparc/sparc/pmap.c
--- a/sys/arch/sparc/sparc/pmap.c Sat Nov 03 23:42:27 2012 +0000
+++ b/sys/arch/sparc/sparc/pmap.c Sun Nov 04 00:32:47 2012 +0000
@@ -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 @@
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.
- */
-
- 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
- }
- splx(s);
+
+ if (pm == pmap_kernel() || l != curlwp) {
+ return;
+ }
+
+ PMAP_LOCK();
+ if (pm->pm_ctx == NULL) {
+ ctx_alloc(pm); /* performs setcontext() */
+ } else {
+ setcontext(pm->pm_ctxnum);
+ }
+ PMAP_SET_CPUSET(pm, &cpuinfo);
+ PMAP_UNLOCK();
}
/*
@@ -7473,22 +7461,27 @@
void
pmap_deactivate(struct lwp *l)
{
-#if defined(MULTIPROCESSOR)
- pmap_t pm;
- struct proc *p;
-
- p = l->l_proc;
- if (p->p_vmspace &&
- (pm = p->p_vmspace->vm_map.pmap) != pmap_kernel()) {
+ 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)();
+
#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
Home |
Main Index |
Thread Index |
Old Index