Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/aarch64 use PMAP_PAGE_INIT() to initialize mutex in...



details:   https://anonhg.NetBSD.org/src/rev/58c7990dd5ed
branches:  trunk
changeset: 970954:58c7990dd5ed
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Apr 08 00:13:40 2020 +0000

description:
use PMAP_PAGE_INIT() to initialize mutex in pmap_page.

VM_MDPAGE_INIT() in pmap_free_pdp() had initialized pp_flags,
so it unintentionally cleared PMAP_PAGE_FLAGS_PV_TRACKED.
use PMAP_PAGE_INIT to avoid using PMAP_PAGE_FLAGS_PV_TRACKED.

pointed out by tnn@, thanks

diffstat:

 sys/arch/aarch64/aarch64/pmap.c |  20 ++++----------------
 sys/arch/aarch64/include/pmap.h |   7 +++++--
 2 files changed, 9 insertions(+), 18 deletions(-)

diffs (83 lines):

diff -r 13fa25d70f73 -r 58c7990dd5ed sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Tue Apr 07 19:17:50 2020 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Wed Apr 08 00:13:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.68 2020/03/14 14:05:42 ad Exp $     */
+/*     $NetBSD: pmap.c,v 1.69 2020/04/08 00:13:40 ryo Exp $    */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.68 2020/03/14 14:05:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.69 2020/04/08 00:13:40 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -249,12 +249,6 @@
        mutex_exit(&pm->pm_lock);
 }
 
-static inline void
-_pmap_page_init(struct pmap_page *pp)
-{
-       mutex_init(&pp->pp_pvlock, MUTEX_SPIN, IPL_VM);
-}
-
 static inline struct pmap_page *
 phys_to_pp(paddr_t pa)
 {
@@ -265,13 +259,7 @@
                return VM_PAGE_TO_PP(pg);
 
 #ifdef __HAVE_PMAP_PV_TRACK
-       struct pmap_page *pp = pmap_pv_tracked(pa);
-       if (pp != NULL && (pp->pp_flags & PMAP_PAGE_FLAGS_PV_TRACKED) == 0) {
-               /* XXX: initialize pv_tracked pmap_page. should not init here */
-               _pmap_page_init(pp);
-               pp->pp_flags |= PMAP_PAGE_FLAGS_PV_TRACKED;
-       }
-       return pp;
+       return pmap_pv_tracked(pa);
 #else
        return NULL;
 #endif /* __HAVE_PMAP_PV_TRACK */
@@ -537,7 +525,7 @@
                     pfn++) {
                        pg = PHYS_TO_VM_PAGE(ptoa(pfn));
                        md = VM_PAGE_TO_MD(pg);
-                       _pmap_page_init(&md->mdpg_pp);
+                       PMAP_PAGE_INIT(&md->mdpg_pp);
                }
        }
 }
diff -r 13fa25d70f73 -r 58c7990dd5ed sys/arch/aarch64/include/pmap.h
--- a/sys/arch/aarch64/include/pmap.h   Tue Apr 07 19:17:50 2020 +0000
+++ b/sys/arch/aarch64/include/pmap.h   Wed Apr 08 00:13:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.36 2020/02/29 21:32:22 ryo Exp $ */
+/* $NetBSD: pmap.h,v 1.37 2020/04/08 00:13:40 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -92,7 +92,6 @@
 
        /* VM_PROT_READ means referenced, VM_PROT_WRITE means modified */
        uint32_t pp_flags;
-#define PMAP_PAGE_FLAGS_PV_TRACKED     0x80000000
 };
 
 struct vm_page_md {
@@ -109,6 +108,10 @@
                (pg)->mdpage.mdpg_pp.pp_flags = 0;              \
        } while (/*CONSTCOND*/ 0)
 
+#define PMAP_PAGE_INIT(pp)                                             \
+       do {                                                            \
+               mutex_init(&(pp)->pp_pvlock, MUTEX_SPIN, IPL_VM);       \
+       } while (/*CONSTCOND*/ 0)
 
 /* saved permission bit for referenced/modified emulation */
 #define LX_BLKPAG_OS_READ              LX_BLKPAG_OS_0



Home | Main Index | Thread Index | Old Index