summaryrefslogtreecommitdiff
path: root/sys/arch/m88k
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-05-02 14:32:30 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-05-02 14:32:30 +0000
commit44fd576bd42dbbec3a4e6965fe04b00fddf78c6b (patch)
treebac4fc852635b580de2139151f1dbb0d7ef7aadc /sys/arch/m88k
parent772b0c37f150c6ea557a6f0914cf713d966413c4 (diff)
Drop the pm_cpus bitmask field from struct pmap, and instead remember the
currently active userland pmap in each processors struct cpu_info. This thus skips the complete tlb flush if idle switches back to the proc previously running on this processor.
Diffstat (limited to 'sys/arch/m88k')
-rw-r--r--sys/arch/m88k/include/cpu.h7
-rw-r--r--sys/arch/m88k/include/pmap.h4
-rw-r--r--sys/arch/m88k/m88k/genassym.cf5
-rw-r--r--sys/arch/m88k/m88k/pmap.c115
-rw-r--r--sys/arch/m88k/m88k/process.S6
5 files changed, 59 insertions, 78 deletions
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h
index 5b9130d3ef9..f8d0aa987ee 100644
--- a/sys/arch/m88k/include/cpu.h
+++ b/sys/arch/m88k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.48 2009/04/19 17:56:13 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.49 2009/05/02 14:32:27 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -83,13 +83,16 @@
* Per-CPU data structure
*/
+struct pmap;
+
struct cpu_info {
u_int ci_flags;
#define CIF_ALIVE 0x01 /* cpu initialized */
#define CIF_PRIMARY 0x02 /* primary cpu */
struct proc *ci_curproc; /* current process... */
- struct pcb *ci_curpcb; /* ...and its pcb */
+ struct pcb *ci_curpcb; /* ...its pcb... */
+ struct pmap *ci_curpmap; /* ...and its pmap */
u_int ci_cpuid; /* cpu number */
diff --git a/sys/arch/m88k/include/pmap.h b/sys/arch/m88k/include/pmap.h
index bafd1b2f303..7561a9a5e78 100644
--- a/sys/arch/m88k/include/pmap.h
+++ b/sys/arch/m88k/include/pmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.h,v 1.13 2009/03/04 19:39:02 miod Exp $ */
+/* $OpenBSD: pmap.h,v 1.14 2009/05/02 14:32:27 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1991 Carnegie Mellon University
@@ -27,8 +27,6 @@ struct pmap {
sdt_entry_t *pm_stab; /* virtual pointer to sdt */
apr_t pm_apr;
int pm_count; /* reference count */
- /* cpus using of this pmap; NCPU must be <= 32 */
- u_int32_t pm_cpus;
#ifdef MULTIPROCESSOR
__cpu_simple_lock_t pm_lock;
#endif
diff --git a/sys/arch/m88k/m88k/genassym.cf b/sys/arch/m88k/m88k/genassym.cf
index 459b52777f1..ba7a29ee1da 100644
--- a/sys/arch/m88k/m88k/genassym.cf
+++ b/sys/arch/m88k/m88k/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.20 2009/03/15 20:39:53 miod Exp $
+# $OpenBSD: genassym.cf,v 1.21 2009/05/02 14:32:29 miod Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -28,7 +28,7 @@
# SUCH DAMAGE.
#
# @(#)genassym.c 7.8 (Berkeley) 5/7/91
-# $Id: genassym.cf,v 1.20 2009/03/15 20:39:53 miod Exp $
+# $Id: genassym.cf,v 1.21 2009/05/02 14:32:29 miod Exp $
#
include <sys/param.h>
@@ -63,6 +63,7 @@ export SONPROC
struct cpu_info
member ci_curproc
member ci_curpcb
+member ci_curpmap
member ci_pfsr_i0
member ci_pfsr_i1
member ci_pfsr_d0
diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c
index 5953d24c7a6..130f2f146fe 100644
--- a/sys/arch/m88k/m88k/pmap.c
+++ b/sys/arch/m88k/m88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.47 2009/04/19 17:56:13 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.48 2009/05/02 14:32:29 miod Exp $ */
/*
* Copyright (c) 2001-2004, Miodrag Vallat
* Copyright (c) 1998-2001 Steve Murphree, Jr.
@@ -71,12 +71,6 @@ extern vaddr_t avail_start;
extern vaddr_t virtual_avail, virtual_end;
extern vaddr_t last_addr;
-/*
- * Macros to operate pm_cpus field
- */
-#define SETBIT_CPUSET(cpu_number, cpuset) (*(cpuset)) |= (1 << (cpu_number));
-#define CLRBIT_CPUSET(cpu_number, cpuset) (*(cpuset)) &= ~(1 << (cpu_number));
-
#ifdef PMAPDEBUG
/*
* Static variables, functions and variables for debugging
@@ -198,24 +192,19 @@ boolean_t pmap_testbit(struct vm_page *, int);
void
flush_atc_entry(pmap_t pmap, vaddr_t va)
{
- u_int32_t users;
- boolean_t kernel;
-
- if ((users = pmap->pm_cpus) == 0)
- return;
+ struct cpu_info *ci;
+ boolean_t kernel = pmap == kernel_pmap;
- kernel = pmap == kernel_pmap;
+#ifdef MULTIPROCESSOR /* { */
+ CPU_INFO_ITERATOR cpu;
-#ifdef MULTIPROCESSOR
/*
* On 88100, we take action immediately.
*/
if (CPU_IS88100) {
- int cpu;
-
- while ((cpu = ff1(users)) != 32) {
- cmmu_flush_tlb(cpu, kernel, va, 1);
- users ^= 1 << cpu;
+ CPU_INFO_FOREACH(cpu, ci) {
+ if (kernel || pmap == ci->ci_curpmap)
+ cmmu_flush_tlb(ci->ci_cpuid, kernel, va, 1);
}
}
@@ -224,23 +213,24 @@ flush_atc_entry(pmap_t pmap, vaddr_t va)
* and wait for pmap_update() to do it.
*/
if (CPU_IS88110) {
- struct cpu_info *ci;
- CPU_INFO_ITERATOR cpu;
-
CPU_INFO_FOREACH(cpu, ci) {
- if (ISSET(users, 1 << ci->ci_cpuid))
- ci->ci_pmap_ipi |= kernel ?
- CI_IPI_TLB_FLUSH_KERNEL :
- CI_IPI_TLB_FLUSH_USER;
+ if (kernel)
+ ci->ci_pmap_ipi |= CI_IPI_TLB_FLUSH_KERNEL;
+ else if (pmap == ci->ci_curpmap)
+ ci->ci_pmap_ipi |= CI_IPI_TLB_FLUSH_USER;
}
}
-#else /* MULTIPROCESSOR */
- if (CPU_IS88100)
- cmmu_flush_tlb(cpu_number(), kernel, va, 1);
- if (CPU_IS88110)
- curcpu()->ci_pmap_ipi |= kernel ?
- CI_IPI_TLB_FLUSH_KERNEL : CI_IPI_TLB_FLUSH_USER;
-#endif /* MULTIPROCESSOR */
+#else /* MULTIPROCESSOR */ /* } { */
+ ci = curcpu();
+
+ if (kernel || pmap == ci->ci_curpmap) {
+ if (CPU_IS88100)
+ cmmu_flush_tlb(ci->ci_cpuid, kernel, va, 1);
+ if (CPU_IS88110)
+ ci->ci_pmap_ipi |= kernel ?
+ CI_IPI_TLB_FLUSH_KERNEL : CI_IPI_TLB_FLUSH_USER;
+ }
+#endif /* MULTIPROCESSOR */ /* } */
}
#ifdef M88110
@@ -612,7 +602,6 @@ pmap_bootstrap(vaddr_t load_start)
* Initialize kernel_pmap structure
*/
kernel_pmap->pm_count = 1;
- kernel_pmap->pm_cpus = 0;
kmap = (sdt_entry_t *)(avail_start);
kernel_pmap->pm_stab = (sdt_entry_t *)virtual_avail;
kmapva = virtual_avail;
@@ -788,7 +777,7 @@ pmap_bootstrap_cpu(cpuid_t cpu)
#ifdef PMAPDEBUG
printf("cpu%d: running virtual\n", cpu);
#endif
- SETBIT_CPUSET(cpu, &kernel_pmap->pm_cpus);
+ curcpu()->ci_curpmap = NULL;
}
/*
@@ -936,7 +925,6 @@ pmap_create(void)
#ifdef MULTIPROCESSOR
__cpu_simple_lock_init(&pmap->pm_lock);
#endif
- pmap->pm_cpus = 0;
return pmap;
}
@@ -2023,28 +2011,21 @@ void
pmap_activate(struct proc *p)
{
pmap_t pmap = vm_map_pmap(&p->p_vmspace->vm_map);
- int cpu = cpu_number();
+ struct cpu_info *ci = curcpu();
#ifdef PMAPDEBUG
if (pmap_debug & CD_ACTIVATE)
printf("pmap_activate(%p) pmap %p\n", p, pmap);
#endif
- if (pmap != kernel_pmap) {
- /*
- * Lock the pmap to put this cpu in its active set.
- */
- PMAP_LOCK(pmap);
-
- cmmu_set_uapr(pmap->pm_apr);
- cmmu_flush_tlb(cpu, FALSE, 0, -1);
-
- /*
- * Mark that this cpu is using the pmap.
- */
- SETBIT_CPUSET(cpu, &(pmap->pm_cpus));
-
- PMAP_UNLOCK(pmap);
+ if (pmap == kernel_pmap) {
+ ci->ci_curpmap = NULL;
+ } else {
+ if (pmap != ci->ci_curpmap) {
+ cmmu_set_uapr(pmap->pm_apr);
+ cmmu_flush_tlb(ci->ci_cpuid, FALSE, 0, -1);
+ ci->ci_curpmap = pmap;
+ }
}
}
@@ -2060,17 +2041,9 @@ pmap_activate(struct proc *p)
void
pmap_deactivate(struct proc *p)
{
- pmap_t pmap = vm_map_pmap(&p->p_vmspace->vm_map);
- int cpu = cpu_number();
+ struct cpu_info *ci = curcpu();
- if (pmap != kernel_pmap) {
- /*
- * We expect the spl to already have been raised to sched level.
- */
- PMAP_LOCK(pmap);
- CLRBIT_CPUSET(cpu, &(pmap->pm_cpus));
- PMAP_UNLOCK(pmap);
- }
+ ci->ci_curpmap = NULL;
}
/*
@@ -2607,16 +2580,22 @@ pmap_proc_iflush(struct proc *p, vaddr_t va, vsize_t len)
pmap_t pmap = vm_map_pmap(&p->p_vmspace->vm_map);
paddr_t pa;
vsize_t count;
- u_int32_t users;
- int cpu;
+ struct cpu_info *ci;
while (len != 0) {
count = min(len, PAGE_SIZE - (va & PAGE_MASK));
if (pmap_extract(pmap, va, &pa)) {
- users = pmap->pm_cpus;
- while ((cpu = ff1(users)) != 32) {
- cmmu_flush_inst_cache(cpu, pa, count);
- users &= ~(1 << cpu);
+#ifdef MULTIPROCESSOR
+ CPU_INFO_ITERATOR cpu;
+
+ CPU_INFO_FOREACH(cpu, ci)
+#else
+ ci = curcpu();
+#endif
+ /* CPU_INFO_FOREACH(cpu, ci) */ {
+ if (ci->ci_curpmap == pmap)
+ cmmu_flush_inst_cache(ci->ci_cpuid,
+ pa, count);
}
}
va += count;
diff --git a/sys/arch/m88k/m88k/process.S b/sys/arch/m88k/m88k/process.S
index 6b67249fda5..3a37fe83722 100644
--- a/sys/arch/m88k/m88k/process.S
+++ b/sys/arch/m88k/m88k/process.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: process.S,v 1.23 2009/02/13 23:28:55 miod Exp $ */
+/* $OpenBSD: process.S,v 1.24 2009/05/02 14:32:29 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -55,9 +55,9 @@ ENTRY(cpu_switchto)
bsr _ASM_LABEL(__savectx)
/* note that we don't need to recover r1 at this point */
+ /* inline pmap_deactivate(oldproc) */
ldcr r11, CPU
- bsr.n _C_LABEL(pmap_deactivate) /* pmap_deactivate(oldproc) */
- ld r2, r11, CI_CURPROC
+ st r0, r11, CI_CURPMAP
1:
ldcr r2, PSR