aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-01-18 13:35:06 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-01-18 13:35:06 +0000
commitf2a496d667f3c4500b68dc6c751a0e103d56a447 (patch)
tree9734b780a0e01530be3030996a1f091eef65151f
parent6465f3158abc1b252ab2b324f9f3fe88bab6d41e (diff)
downloadsrc-f2a496d667f3c4500b68dc6c751a0e103d56a447.tar.gz
src-f2a496d667f3c4500b68dc6c751a0e103d56a447.zip
MI VM: Make it possible to set size of superpage at boot instead of compile time.
In order to allow single kernel to use PAE pagetables on i386 if hardware supports it, and fall back to classic two-level paging structures if not, superpage code should be able to adopt to either 2M or 4M superpages size. There I make MI VM structures large enough to track the biggest possible superpage, by allowing architecture to define VM_NFREEORDER_MAX and VM_LEVEL_0_ORDER_MAX constants. Corresponding VM_NFREEORDER and VM_LEVEL_0_ORDER symbols can be defined as runtime values and must be less than the _MAX constants. If architecture does not define _MAXs, it is assumed that _MAX == normal constant. Reviewed by: markj Tested by: pho (as part of the larger patch) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18853
Notes
Notes: svn path=/head/; revision=343145
-rw-r--r--sys/vm/vm_phys.c3
-rw-r--r--sys/vm/vm_phys.h6
-rw-r--r--sys/vm/vm_reserv.c8
3 files changed, 14 insertions, 3 deletions
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 5908c6df0696..bc7b2ae3f7e9 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -106,7 +106,8 @@ static struct rwlock_padalign vm_phys_fictitious_reg_lock;
MALLOC_DEFINE(M_FICT_PAGES, "vm_fictitious", "Fictitious VM pages");
static struct vm_freelist __aligned(CACHE_LINE_SIZE)
- vm_phys_free_queues[MAXMEMDOM][VM_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER];
+ vm_phys_free_queues[MAXMEMDOM][VM_NFREELIST][VM_NFREEPOOL]
+ [VM_NFREEORDER_MAX];
static int __read_mostly vm_nfreelists;
diff --git a/sys/vm/vm_phys.h b/sys/vm/vm_phys.h
index 08c1a92d25f8..b8d3657c2f16 100644
--- a/sys/vm/vm_phys.h
+++ b/sys/vm/vm_phys.h
@@ -42,6 +42,10 @@
#ifdef _KERNEL
+#ifndef VM_NFREEORDER_MAX
+#define VM_NFREEORDER_MAX VM_NFREEORDER
+#endif
+
/* Domains must be dense (non-sparse) and zero-based. */
struct mem_affinity {
vm_paddr_t start;
@@ -63,7 +67,7 @@ struct vm_phys_seg {
vm_paddr_t end;
vm_page_t first_page;
int domain;
- struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER];
+ struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX];
};
extern struct vm_phys_seg vm_phys_segs[];
diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
index 0cfc69f57e21..49ee4ca1f9e8 100644
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -77,10 +77,15 @@ __FBSDID("$FreeBSD$");
#if VM_NRESERVLEVEL > 0
+#ifndef VM_LEVEL_0_ORDER_MAX
+#define VM_LEVEL_0_ORDER_MAX VM_LEVEL_0_ORDER
+#endif
+
/*
* The number of small pages that are contained in a level 0 reservation
*/
#define VM_LEVEL_0_NPAGES (1 << VM_LEVEL_0_ORDER)
+#define VM_LEVEL_0_NPAGES_MAX (1 << VM_LEVEL_0_ORDER_MAX)
/*
* The number of bits by which a physical address is shifted to obtain the
@@ -114,6 +119,7 @@ typedef u_long popmap_t;
* The number of population map entries in a reservation
*/
#define NPOPMAP howmany(VM_LEVEL_0_NPAGES, NBPOPMAP)
+#define NPOPMAP_MAX howmany(VM_LEVEL_0_NPAGES_MAX, NBPOPMAP)
/*
* Number of elapsed ticks before we update the LRU queue position. Used
@@ -191,7 +197,7 @@ struct vm_reserv {
uint16_t popcnt; /* (r) # of pages in use */
int lasttick; /* (r) last pop update tick. */
char inpartpopq; /* (d) */
- popmap_t popmap[NPOPMAP]; /* (r) bit vector, used pages */
+ popmap_t popmap[NPOPMAP_MAX]; /* (r) bit vector, used pages */
};
#define vm_reserv_lockptr(rv) (&(rv)->lock)