summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2021-05-30 13:34:21 +0000
committerthorpej <thorpej@NetBSD.org>2021-05-30 13:34:21 +0000
commit3c755ab3ef5b5a3564b100bbfc0bcdee101e7e2a (patch)
treeabd8358c69a778d9e2338423f9b14ef57d7bc178
parent6eb5992ab9aba9cc34a9b1d7141830d47aa8e1a4 (diff)
Keep track of a pmap's PV entries with a list hanging off the pmap.
-rw-r--r--sys/arch/alpha/alpha/pmap.c14
-rw-r--r--sys/arch/alpha/include/pmap.h7
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c
index 4871fd000e4..94872141f0b 100644
--- a/sys/arch/alpha/alpha/pmap.c
+++ b/sys/arch/alpha/alpha/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1384,6 +1384,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids)
*/
memset(pmap_kernel(), 0, sizeof(struct pmap));
LIST_INIT(&pmap_kernel()->pm_ptpages);
+ LIST_INIT(&pmap_kernel()->pm_pvents);
atomic_store_relaxed(&pmap_kernel()->pm_count, 1);
/* Kernel pmap does not have per-CPU info. */
TAILQ_INSERT_TAIL(&pmap_all_pmaps, pmap_kernel(), pm_list);
@@ -1568,6 +1569,7 @@ pmap_create(void)
pmap = pool_cache_get(&pmap_pmap_cache, PR_WAITOK);
memset(pmap, 0, sizeof(*pmap));
LIST_INIT(&pmap->pm_ptpages);
+ LIST_INIT(&pmap->pm_pvents);
atomic_store_relaxed(&pmap->pm_count, 1);
@@ -3278,6 +3280,7 @@ pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t va, pt_entry_t *pte,
uintptr_t const attrs = md->pvh_listx & PGA_ATTRS;
newpv->pv_next = (struct pv_entry *)(md->pvh_listx & ~PGA_ATTRS);
md->pvh_listx = (uintptr_t)newpv | attrs;
+ LIST_INSERT_HEAD(&pmap->pm_pvents, newpv, pv_link);
if (dolock) {
mutex_exit(lock);
@@ -3316,8 +3319,15 @@ pmap_pv_remove(pmap_t pmap, struct vm_page *pg, vaddr_t va, bool dolock,
KASSERT(pv != NULL);
+ /*
+ * The page attributes are in the lower 2 bits of the first
+ * PV entry pointer. Rather than comparing the pointer address
+ * and branching, we just always preserve what might be there
+ * (either attribute bits or zero bits).
+ */
*pvp = (pv_entry_t)((uintptr_t)pv->pv_next |
(((uintptr_t)*pvp) & PGA_ATTRS));
+ LIST_REMOVE(pv, pv_link);
if (dolock) {
mutex_exit(lock);
diff --git a/sys/arch/alpha/include/pmap.h b/sys/arch/alpha/include/pmap.h
index 0fd316a2777..0e33d17af4d 100644
--- a/sys/arch/alpha/include/pmap.h
+++ b/sys/arch/alpha/include/pmap.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.93 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.94 2021/05/30 13:34:21 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -151,7 +151,7 @@ struct pmap { /* pmaps are aligned to COHERENCY_UNIT boundaries */
unsigned int pm_count; /* [24] reference count */
unsigned int __pm_spare0; /* [28] spare field */
struct pmap_pagelist pm_ptpages; /* [32] list of PT pages */
- unsigned long __pm_spare1; /* [40] spare field */
+ LIST_HEAD(, pv_entry) pm_pvents; /* [40] list of PV entries */
TAILQ_ENTRY(pmap) pm_list; /* [48] list of all pmaps */
/* -- COHERENCY_UNIT boundary -- */
struct pmap_percpu pm_percpu[]; /* [64] per-CPU data */
@@ -171,7 +171,8 @@ struct pmap { /* pmaps are aligned to COHERENCY_UNIT boundaries */
* mappings of that page. An entry is a pv_entry_t, the list is pv_table.
*/
typedef struct pv_entry {
- struct pv_entry *pv_next; /* next pv_entry on list */
+ struct pv_entry *pv_next; /* next pv_entry on page list */
+ LIST_ENTRY(pv_entry) pv_link; /* link on owning pmap's list */
struct pmap *pv_pmap; /* pmap where mapping lies */
vaddr_t pv_va; /* virtual address for mapping */
pt_entry_t *pv_pte; /* PTE that maps the VA */