Module Name:    src
Committed By:   riastradh
Date:           Sat Aug 20 23:49:32 UTC 2022

Modified Files:
        src/sys/arch/amd64/amd64: netbsd32_machdep.c
        src/sys/arch/amd64/include: pmap.h pmap_private.h
        src/sys/arch/i386/i386: compat_16_machdep.c
        src/sys/arch/i386/include: pmap.h pmap_private.h
        src/sys/arch/x86/include: pmap.h pmap_private.h
        src/sys/arch/x86/x86: pmap.c sys_machdep.c
        src/sys/external/bsd/drm2/include/linux: shmem_fs.h

Log Message:
x86: Move definition of struct pmap to pmap_private.h.

This makes pmap_resident_count and pmap_wired_count out-of-line
functions instead of inline.  No functional change intended
otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/amd64/amd64/netbsd32_machdep.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/pmap_private.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/i386/compat_16_machdep.c
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/include/pmap_private.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/include/pmap_private.h
cvs rdiff -u -r1.419 -r1.420 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/x86/x86/sys_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/shmem_fs.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/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.140 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.141
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.140	Sat Nov  6 20:42:56 2021
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.141 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.141 2022/08/20 23:49:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include <machine/sysarch.h>
 #include <machine/userret.h>
 #include <machine/gdt.h>
+#include <machine/pmap_private.h>
 
 #include <compat/netbsd32/netbsd32.h>
 #include <compat/netbsd32/netbsd32_exec.h>

Index: src/sys/arch/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.68 src/sys/arch/amd64/include/pmap.h:1.69
--- src/sys/arch/amd64/include/pmap.h:1.68	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/amd64/include/pmap.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,3 @@
-/*	$NetBSD: pmap.h,v 1.68 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.69 2022/08/20 23:49:31 riastradh Exp $	*/
 
-#define PTP_LEVELS	4
 #include <x86/pmap.h>

Index: src/sys/arch/amd64/include/pmap_private.h
diff -u src/sys/arch/amd64/include/pmap_private.h:1.1 src/sys/arch/amd64/include/pmap_private.h:1.2
--- src/sys/arch/amd64/include/pmap_private.h:1.1	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/amd64/include/pmap_private.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.1 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -175,6 +175,8 @@ extern pt_entry_t *pte_base;
 #define NBPD_INITIALIZER	{ NBPD_L1, NBPD_L2, NBPD_L3, NBPD_L4 }
 #define PDES_INITIALIZER	{ L2_BASE, L3_BASE, L4_BASE }
 
+#define PTP_LEVELS	4
+
 /*
  * PTE_AVL usage: we make use of the ignored bits of the PTE
  */

Index: src/sys/arch/i386/i386/compat_16_machdep.c
diff -u src/sys/arch/i386/i386/compat_16_machdep.c:1.33 src/sys/arch/i386/i386/compat_16_machdep.c:1.34
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.33	Wed Oct 27 04:14:59 2021
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.33 2021/10/27 04:14:59 thorpej Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.34 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.33 2021/10/27 04:14:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.34 2022/08/20 23:49:31 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_16_ma
 #include <uvm/uvm_extern.h>
 
 #include <machine/pmap.h>
+#include <machine/pmap_private.h>
 #include <machine/vmparam.h>
 #include <x86/fpu.h>
 

Index: src/sys/arch/i386/include/pmap.h
diff -u src/sys/arch/i386/include/pmap.h:1.128 src/sys/arch/i386/include/pmap.h:1.129
--- src/sys/arch/i386/include/pmap.h:1.128	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/i386/include/pmap.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,3 @@
-/*	$NetBSD: pmap.h,v 1.128 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.129 2022/08/20 23:49:31 riastradh Exp $	*/
 
-#define PTP_LEVELS	2
 #include <x86/pmap.h>

Index: src/sys/arch/i386/include/pmap_private.h
diff -u src/sys/arch/i386/include/pmap_private.h:1.1 src/sys/arch/i386/include/pmap_private.h:1.2
--- src/sys/arch/i386/include/pmap_private.h:1.1	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/i386/include/pmap_private.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.1 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -241,6 +241,8 @@
 #define NBPD_INITIALIZER	{ NBPD_L1, NBPD_L2 }
 #define PDES_INITIALIZER	{ L2_BASE }
 
+#define PTP_LEVELS	2
+
 /*
  * PTE_AVL usage: we make use of the ignored bits of the PTE
  */

Index: src/sys/arch/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.133 src/sys/arch/x86/include/pmap.h:1.134
--- src/sys/arch/x86/include/pmap.h:1.133	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/x86/include/pmap.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.133 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap.h,v 1.134 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -68,72 +68,8 @@
 #define	_X86_PMAP_H_
 
 #if defined(_KERNEL)
-#include <sys/kcpuset.h>
-#include <sys/rwlock.h>
 #include <x86/pmap_pv.h>
 #include <uvm/pmap/pmap_pvt.h>
-#include <uvm/uvm_object.h>
-
-/*
- * the pmap structure
- *
- * note that the pm_obj contains the lock pointer, the reference count,
- * page list, and number of PTPs within the pmap.
- *
- * pm_lock is the same as the lock for vm object 0.  Changes to
- * the other objects may only be made if that lock has been taken
- * (the other object locks are only used when uvm_pagealloc is called)
- */
-
-struct pv_page;
-
-struct pmap {
-	struct uvm_object pm_obj[PTP_LEVELS-1];/* objects for lvl >= 1) */
-	LIST_ENTRY(pmap) pm_list;	/* list of all pmaps */
-	pd_entry_t *pm_pdir;		/* VA of PD */
-	paddr_t pm_pdirpa[PDP_SIZE];	/* PA of PDs (read-only after create) */
-	struct vm_page *pm_ptphint[PTP_LEVELS-1];
-					/* pointer to a PTP in our pmap */
-	struct pmap_statistics pm_stats;  /* pmap stats */
-	struct pv_entry *pm_pve;	/* spare pv_entry */
-	LIST_HEAD(, pv_page) pm_pvp_part;
-	LIST_HEAD(, pv_page) pm_pvp_empty;
-	LIST_HEAD(, pv_page) pm_pvp_full;
-
-#if !defined(__x86_64__)
-	vaddr_t pm_hiexec;		/* highest executable mapping */
-#endif /* !defined(__x86_64__) */
-
-	union descriptor *pm_ldt;	/* user-set LDT */
-	size_t pm_ldt_len;		/* XXX unused, remove */
-	int pm_ldt_sel;			/* LDT selector */
-
-	kcpuset_t *pm_cpus;		/* mask of CPUs using pmap */
-	kcpuset_t *pm_kernel_cpus;	/* mask of CPUs using kernel part
-					 of pmap */
-	kcpuset_t *pm_xen_ptp_cpus;	/* mask of CPUs which have this pmap's
-					 ptp mapped */
-	uint64_t pm_ncsw;		/* for assertions */
-	LIST_HEAD(,vm_page) pm_gc_ptp;	/* PTPs queued for free */
-
-	/* Used by NVMM and Xen */
-	int (*pm_enter)(struct pmap *, vaddr_t, paddr_t, vm_prot_t, u_int);
-	bool (*pm_extract)(struct pmap *, vaddr_t, paddr_t *);
-	void (*pm_remove)(struct pmap *, vaddr_t, vaddr_t);
-	int (*pm_sync_pv)(struct vm_page *, vaddr_t, paddr_t, int, uint8_t *,
-	    pt_entry_t *);
-	void (*pm_pp_remove_ent)(struct pmap *, struct vm_page *, pt_entry_t,
-	    vaddr_t);
-	void (*pm_write_protect)(struct pmap *, vaddr_t, vaddr_t, vm_prot_t);
-	void (*pm_unwire)(struct pmap *, vaddr_t);
-
-	void (*pm_tlb_flush)(struct pmap *);
-	void *pm_data;
-
-	kmutex_t pm_lock		/* locks for pm_objs */
-	    __aligned(64);		/* give lock own cache line */
-	krwlock_t pm_dummy_lock;	/* ugly hack for abusing uvm_object */
-};
 
 /*
  * MD flags that we use for pmap_enter and pmap_kenter_pa:
@@ -143,9 +79,6 @@ struct pmap {
  * macros
  */
 
-#define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
-#define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
-
 #define pmap_clear_modify(pg)		pmap_clear_attrs(pg, PP_ATTRS_D)
 #define pmap_clear_reference(pg)	pmap_clear_attrs(pg, PP_ATTRS_A)
 #define pmap_copy(DP,SP,D,L,S)		__USE(L)

Index: src/sys/arch/x86/include/pmap_private.h
diff -u src/sys/arch/x86/include/pmap_private.h:1.1 src/sys/arch/x86/include/pmap_private.h:1.2
--- src/sys/arch/x86/include/pmap_private.h:1.1	Sat Aug 20 23:48:50 2022
+++ src/sys/arch/x86/include/pmap_private.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_private.h,v 1.1 2022/08/20 23:48:50 riastradh Exp $	*/
+/*	$NetBSD: pmap_private.h,v 1.2 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -74,13 +74,16 @@
 #include <sys/param.h>
 #include <sys/types.h>
 
+#include <sys/kcpuset.h>
 #include <sys/mutex.h>
 #include <sys/pool.h>
 #include <sys/queue.h>
+#include <sys/rwlock.h>
 
 #include <machine/pte.h>
 #include <machine/vmparam.h>
 
+#include <uvm/uvm_object.h>
 #include <uvm/uvm_pmap.h>
 
 struct pmap;
@@ -154,6 +157,67 @@ extern kmutex_t pmaps_lock;    /* protec
  */
 extern struct pool_cache pmap_cache;
 
+/*
+ * the pmap structure
+ *
+ * note that the pm_obj contains the lock pointer, the reference count,
+ * page list, and number of PTPs within the pmap.
+ *
+ * pm_lock is the same as the lock for vm object 0.  Changes to
+ * the other objects may only be made if that lock has been taken
+ * (the other object locks are only used when uvm_pagealloc is called)
+ */
+
+struct pv_page;
+
+struct pmap {
+	struct uvm_object pm_obj[PTP_LEVELS-1];/* objects for lvl >= 1) */
+	LIST_ENTRY(pmap) pm_list;	/* list of all pmaps */
+	pd_entry_t *pm_pdir;		/* VA of PD */
+	paddr_t pm_pdirpa[PDP_SIZE];	/* PA of PDs (read-only after create) */
+	struct vm_page *pm_ptphint[PTP_LEVELS-1];
+					/* pointer to a PTP in our pmap */
+	struct pmap_statistics pm_stats;  /* pmap stats */
+	struct pv_entry *pm_pve;	/* spare pv_entry */
+	LIST_HEAD(, pv_page) pm_pvp_part;
+	LIST_HEAD(, pv_page) pm_pvp_empty;
+	LIST_HEAD(, pv_page) pm_pvp_full;
+
+#if !defined(__x86_64__)
+	vaddr_t pm_hiexec;		/* highest executable mapping */
+#endif /* !defined(__x86_64__) */
+
+	union descriptor *pm_ldt;	/* user-set LDT */
+	size_t pm_ldt_len;		/* XXX unused, remove */
+	int pm_ldt_sel;			/* LDT selector */
+
+	kcpuset_t *pm_cpus;		/* mask of CPUs using pmap */
+	kcpuset_t *pm_kernel_cpus;	/* mask of CPUs using kernel part
+					 of pmap */
+	kcpuset_t *pm_xen_ptp_cpus;	/* mask of CPUs which have this pmap's
+					 ptp mapped */
+	uint64_t pm_ncsw;		/* for assertions */
+	LIST_HEAD(,vm_page) pm_gc_ptp;	/* PTPs queued for free */
+
+	/* Used by NVMM and Xen */
+	int (*pm_enter)(struct pmap *, vaddr_t, paddr_t, vm_prot_t, u_int);
+	bool (*pm_extract)(struct pmap *, vaddr_t, paddr_t *);
+	void (*pm_remove)(struct pmap *, vaddr_t, vaddr_t);
+	int (*pm_sync_pv)(struct vm_page *, vaddr_t, paddr_t, int, uint8_t *,
+	    pt_entry_t *);
+	void (*pm_pp_remove_ent)(struct pmap *, struct vm_page *, pt_entry_t,
+	    vaddr_t);
+	void (*pm_write_protect)(struct pmap *, vaddr_t, vaddr_t, vm_prot_t);
+	void (*pm_unwire)(struct pmap *, vaddr_t);
+
+	void (*pm_tlb_flush)(struct pmap *);
+	void *pm_data;
+
+	kmutex_t pm_lock		/* locks for pm_objs */
+	    __aligned(64);		/* give lock own cache line */
+	krwlock_t pm_dummy_lock;	/* ugly hack for abusing uvm_object */
+};
+
 /* macro to access pm_pdirpa slots */
 #ifdef PAE
 #define pmap_pdirpa(pmap, index) \

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.419 src/sys/arch/x86/x86/pmap.c:1.420
--- src/sys/arch/x86/x86/pmap.c:1.419	Sat Aug 20 23:48:51 2022
+++ src/sys/arch/x86/x86/pmap.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.419 2022/08/20 23:48:51 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.420 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.419 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.420 2022/08/20 23:49:31 riastradh Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -528,6 +528,20 @@ static void pmap_alloc_level(struct pmap
 static void pmap_load1(struct lwp *, struct pmap *, struct pmap *);
 static void pmap_reactivate(struct pmap *);
 
+long
+pmap_resident_count(struct pmap *pmap)
+{
+
+	return pmap->pm_stats.resident_count;
+}
+
+long
+pmap_wired_count(struct pmap *pmap)
+{
+
+	return pmap->pm_stats.wired_count;
+}
+
 /*
  * p m a p   h e l p e r   f u n c t i o n s
  */

Index: src/sys/arch/x86/x86/sys_machdep.c
diff -u src/sys/arch/x86/x86/sys_machdep.c:1.57 src/sys/arch/x86/x86/sys_machdep.c:1.58
--- src/sys/arch/x86/x86/sys_machdep.c:1.57	Thu Oct  7 12:52:27 2021
+++ src/sys/arch/x86/x86/sys_machdep.c	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_machdep.c,v 1.57 2021/10/07 12:52:27 msaitoh Exp $	*/
+/*	$NetBSD: sys_machdep.c,v 1.58 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2009, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.57 2021/10/07 12:52:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.58 2022/08/20 23:49:31 riastradh Exp $");
 
 #include "opt_mtrr.h"
 #include "opt_user_ldt.h"
@@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: sys_machdep.
 #include <machine/reg.h>
 #include <machine/sysarch.h>
 #include <machine/mtrr.h>
+#include <machine/pmap_private.h>
 
 #if defined(__x86_64__) || defined(XENPV)
 #undef	IOPERM	/* not implemented */

Index: src/sys/external/bsd/drm2/include/linux/shmem_fs.h
diff -u src/sys/external/bsd/drm2/include/linux/shmem_fs.h:1.4 src/sys/external/bsd/drm2/include/linux/shmem_fs.h:1.5
--- src/sys/external/bsd/drm2/include/linux/shmem_fs.h:1.4	Sun Dec 19 12:13:08 2021
+++ src/sys/external/bsd/drm2/include/linux/shmem_fs.h	Sat Aug 20 23:49:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: shmem_fs.h,v 1.4 2021/12/19 12:13:08 riastradh Exp $	*/
+/*	$NetBSD: shmem_fs.h,v 1.5 2022/08/20 23:49:31 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 #include <lib/libkern/libkern.h>
 
 #include <uvm/uvm_extern.h>
+#include <uvm/uvm_object.h>
 
 #include <linux/err.h>
 #include <linux/gfp.h>

Reply via email to