Module Name: src
Committed By: thorpej
Date: Sun May 30 00:34:27 UTC 2021
Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h
Log Message:
Define a pmap_pagelist LIST_HEAD and use it where we used ad hoc LIST_HEADs
of vm_page structures. Define and use a generic routine to free such a list
back to UVM.
In pmap_remove_internal(), KASSERT that no PT pages are queued up to be
freed when removing mappings from the kernel pmap.
To generate a diff of this commit:
cvs rdiff -u -r1.281 -r1.282 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/alpha/include/pmap.h
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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.281 src/sys/arch/alpha/alpha/pmap.c:1.282
--- src/sys/arch/alpha/alpha/pmap.c:1.281 Sat May 29 23:27:22 2021
+++ src/sys/arch/alpha/alpha/pmap.c Sun May 30 00:34:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.281 2021/05/29 23:27:22 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 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.281 2021/05/29 23:27:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -432,6 +432,21 @@ pmap_activation_lock(pmap_t const pmap)
#endif /* MULTIPROCESSOR */
/*
+ * Generic routine for freeing pages on a pmap_pagelist back to
+ * the system.
+ */
+static void
+pmap_pagelist_free(struct pmap_pagelist * const list)
+{
+ struct vm_page *pg;
+
+ while ((pg = LIST_FIRST(list)) != NULL) {
+ LIST_REMOVE(pg, pageq.list);
+ uvm_pagefree(pg);
+ }
+}
+
+/*
* TLB management.
*
* TLB invalidations need to be performed on local and remote CPUs
@@ -526,7 +541,7 @@ pmap_activation_lock(pmap_t const pmap)
struct pmap_tlb_context {
uintptr_t t_addrdata[TLB_CTX_MAXVA];
pmap_t t_pmap;
- LIST_HEAD(, vm_page) t_freeptq;
+ struct pmap_pagelist t_freeptq;
};
static struct {
@@ -1082,15 +1097,10 @@ pmap_tlb_physpage_free(paddr_t const ptp
LIST_INSERT_HEAD(&tlbctx->t_freeptq, pg, pageq.list);
}
-static void
+static __inline void
pmap_tlb_ptpage_drain(struct pmap_tlb_context * const tlbctx)
{
- struct vm_page *pg;
-
- while ((pg = LIST_FIRST(&tlbctx->t_freeptq)) != NULL) {
- LIST_REMOVE(pg, pageq.list);
- uvm_pagefree(pg);
- }
+ pmap_pagelist_free(&tlbctx->t_freeptq);
}
/*
@@ -1720,7 +1730,8 @@ pmap_remove_internal(pmap_t pmap, vaddr_
PMAP_MAP_TO_HEAD_UNLOCK();
PMAP_UNLOCK(pmap);
pmap_tlb_shootnow(tlbctx);
- pmap_tlb_ptpage_drain(tlbctx);
+ /* kernel PT pages are never freed. */
+ KASSERT(LIST_EMPTY(&tlbctx->t_freeptq));
TLB_COUNT(reason_remove_kernel);
return;
Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.88 src/sys/arch/alpha/include/pmap.h:1.89
--- src/sys/arch/alpha/include/pmap.h:1.88 Sat May 29 23:27:22 2021
+++ src/sys/arch/alpha/include/pmap.h Sun May 30 00:34:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.88 2021/05/29 23:27:22 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.89 2021/05/30 00:34:27 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -131,6 +131,9 @@
* allocate any ASN info for the kernel pmap at all.
* arrays which hold enough for ALPHA_MAXPROCS.
*/
+
+LIST_HEAD(pmap_pagelist, vm_page);
+
struct pmap_percpu {
unsigned int pmc_asn; /* address space number */
unsigned int pmc_pad0;