Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha Define a pmap_pagelist LIST_HEAD and use it w...



details:   https://anonhg.NetBSD.org/src/rev/f9f7e2d5f3ee
branches:  trunk
changeset: 983582:f9f7e2d5f3ee
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun May 30 00:34:27 2021 +0000

description:
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.

diffstat:

 sys/arch/alpha/alpha/pmap.c   |  33 ++++++++++++++++++++++-----------
 sys/arch/alpha/include/pmap.h |   5 ++++-
 2 files changed, 26 insertions(+), 12 deletions(-)

diffs (96 lines):

diff -r 12c28bc7ad8a -r f9f7e2d5f3ee sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Sun May 30 00:19:08 2021 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Sun May 30 00:34:27 2021 +0000
@@ -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 @@
 #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 @@
 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 @@
        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_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;
diff -r 12c28bc7ad8a -r f9f7e2d5f3ee sys/arch/alpha/include/pmap.h
--- a/sys/arch/alpha/include/pmap.h     Sun May 30 00:19:08 2021 +0000
+++ b/sys/arch/alpha/include/pmap.h     Sun May 30 00:34:27 2021 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index