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
This commit is contained in:
Konstantin Belousov 2019-01-18 13:35:06 +00:00
parent 6465f3158a
commit f2a496d667
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=343145
3 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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[];

View File

@ -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)