As of r257209, all architectures have defined VM_KMEM_SIZE_SCALE. In other
words, every architecture is now auto-sizing the kmem arena. This revision changes kmeminit() so that the definition of VM_KMEM_SIZE_SCALE becomes mandatory and the definition of VM_KMEM_SIZE becomes optional. Replace or eliminate all existing definitions of VM_KMEM_SIZE. With auto-sizing enabled, VM_KMEM_SIZE effectively became an alternate spelling for VM_KMEM_SIZE_MIN on most architectures. Use VM_KMEM_SIZE_MIN for clarity. Change kmeminit() so that the effect of defining VM_KMEM_SIZE is similar to that of setting the tunable vm.kmem_size. Whereas the macros VM_KMEM_SIZE_{MAX,MIN,SCALE} have had the same effect as the tunables vm.kmem_size_{max,min,scale}, the effects of VM_KMEM_SIZE and vm.kmem_size have been distinct. In particular, whereas VM_KMEM_SIZE was overridden by VM_KMEM_SIZE_{MAX,MIN,SCALE} and vm.kmem_size_{max,min,scale}, vm.kmem_size was not. Remedy this inconsistency. Now, VM_KMEM_SIZE can be used to set the size of the kmem arena at compile-time without that value being overridden by auto-sizing. Update the nearby comments to reflect the kmem submap being replaced by the kmem arena. Stop duplicating the auto-sizing formula in every machine- dependent vmparam.h and place it in kmeminit() where auto-sizing takes place. Reviewed by: kib (an earlier version) Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
fba3cde907
commit
c70af4875e
@ -178,23 +178,16 @@
|
||||
#define PHYS_TO_DMAP(x) ((x) | DMAP_MIN_ADDRESS)
|
||||
#define DMAP_TO_PHYS(x) ((x) & ~DMAP_MIN_ADDRESS)
|
||||
|
||||
/* virtual sizes (bytes) for various kernel submaps */
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
|
||||
* VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on amount of kmem_map kva space.
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 60% of the
|
||||
* kernel map.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \
|
||||
|
@ -165,17 +165,22 @@
|
||||
#define VM_MAX_KERNEL_ADDRESS (vm_max_kernel_address)
|
||||
|
||||
/*
|
||||
* Virtual size (bytes) for various kernel submaps.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12*1024*1024)
|
||||
#endif
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on the size of the kmem submap: 40% of the kernel map.
|
||||
* Optional floor (in bytes) on the size of the kmem arena.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MIN
|
||||
#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
|
||||
* kernel map.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX ((vm_max_kernel_address - \
|
||||
|
@ -164,24 +164,23 @@
|
||||
#define VM_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI)
|
||||
#define VM_MIN_ADDRESS ((vm_offset_t)0)
|
||||
|
||||
/* virtual sizes (bytes) for various kernel submaps */
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
|
||||
* VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on the amount of kmem_map KVA space: 40% of the entire KVA space
|
||||
* rounded to the nearest multiple of the superpage size.
|
||||
* Optional floor (in bytes) on the size of the kmem arena.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MIN
|
||||
#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
|
||||
* kernel map rounded to the nearest multiple of the superpage size.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX (((((VM_MAX_KERNEL_ADDRESS - \
|
||||
|
@ -189,19 +189,11 @@
|
||||
#define USRSTACK VM_MAXUSER_ADDRESS
|
||||
#define IA64_BACKINGSTORE (USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE)
|
||||
|
||||
/* virtual sizes (bytes) for various kernel submaps */
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
|
||||
* VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (4) /* XXX 8192 byte pages */
|
||||
#define VM_KMEM_SIZE_SCALE (4)
|
||||
#endif
|
||||
|
||||
/* initial pagein size of beginning of executable file */
|
||||
|
@ -684,41 +684,47 @@ kmem_reclaim(vmem_t *vm, int flags)
|
||||
pagedaemon_wakeup();
|
||||
}
|
||||
|
||||
CTASSERT(VM_KMEM_SIZE_SCALE >= 1);
|
||||
|
||||
/*
|
||||
* Initialize the kernel memory arena.
|
||||
* Initialize the kernel memory (kmem) arena.
|
||||
*/
|
||||
void
|
||||
kmeminit(void)
|
||||
{
|
||||
u_long mem_size, tmp;
|
||||
|
||||
|
||||
/*
|
||||
* Try to auto-tune the kernel memory size, so that it is
|
||||
* more applicable for a wider range of machine sizes. The
|
||||
* VM_KMEM_SIZE_MAX is dependent on the maximum KVA space
|
||||
* available.
|
||||
* Calculate the amount of kernel virtual address (KVA) space that is
|
||||
* preallocated to the kmem arena. In order to support a wide range
|
||||
* of machines, it is a function of the physical memory size,
|
||||
* specifically,
|
||||
*
|
||||
* Note that the kmem arena is also used by the zone allocator,
|
||||
* so make sure that there is enough space.
|
||||
* min(max(physical memory size / VM_KMEM_SIZE_SCALE,
|
||||
* VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
|
||||
*
|
||||
* Every architecture must define an integral value for
|
||||
* VM_KMEM_SIZE_SCALE. However, the definitions of VM_KMEM_SIZE_MIN
|
||||
* and VM_KMEM_SIZE_MAX, which represent respectively the floor and
|
||||
* ceiling on this preallocation, are optional. Typically,
|
||||
* VM_KMEM_SIZE_MAX is itself a function of the available KVA space on
|
||||
* a given architecture.
|
||||
*/
|
||||
vm_kmem_size = VM_KMEM_SIZE;
|
||||
mem_size = cnt.v_page_count;
|
||||
|
||||
#if defined(VM_KMEM_SIZE_SCALE)
|
||||
vm_kmem_size_scale = VM_KMEM_SIZE_SCALE;
|
||||
#endif
|
||||
TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale);
|
||||
if (vm_kmem_size_scale > 0 &&
|
||||
(mem_size / vm_kmem_size_scale) > (vm_kmem_size / PAGE_SIZE))
|
||||
vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE;
|
||||
if (vm_kmem_size_scale < 1)
|
||||
vm_kmem_size_scale = VM_KMEM_SIZE_SCALE;
|
||||
|
||||
vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE;
|
||||
|
||||
#if defined(VM_KMEM_SIZE_MIN)
|
||||
vm_kmem_size_min = VM_KMEM_SIZE_MIN;
|
||||
#endif
|
||||
TUNABLE_ULONG_FETCH("vm.kmem_size_min", &vm_kmem_size_min);
|
||||
if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) {
|
||||
if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min)
|
||||
vm_kmem_size = vm_kmem_size_min;
|
||||
}
|
||||
|
||||
#if defined(VM_KMEM_SIZE_MAX)
|
||||
vm_kmem_size_max = VM_KMEM_SIZE_MAX;
|
||||
@ -727,15 +733,17 @@ kmeminit(void)
|
||||
if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max)
|
||||
vm_kmem_size = vm_kmem_size_max;
|
||||
|
||||
/* Allow final override from the kernel environment */
|
||||
TUNABLE_ULONG_FETCH("vm.kmem_size", &vm_kmem_size);
|
||||
|
||||
/*
|
||||
* Limit kmem virtual size to twice the physical memory.
|
||||
* This allows for kmem map sparseness, but limits the size
|
||||
* to something sane. Be careful to not overflow the 32bit
|
||||
* ints while doing the check or the adjustment.
|
||||
* Alternatively, the amount of KVA space that is preallocated to the
|
||||
* kmem arena can be set statically at compile-time or manually
|
||||
* through the kernel environment. However, it is still limited to
|
||||
* twice the physical memory size, which has been sufficient to handle
|
||||
* the most severe cases of external fragmentation in the kmem arena.
|
||||
*/
|
||||
#if defined(VM_KMEM_SIZE)
|
||||
vm_kmem_size = VM_KMEM_SIZE;
|
||||
#endif
|
||||
TUNABLE_ULONG_FETCH("vm.kmem_size", &vm_kmem_size);
|
||||
if (vm_kmem_size / 2 / PAGE_SIZE > mem_size)
|
||||
vm_kmem_size = 2 * mem_size * PAGE_SIZE;
|
||||
|
||||
|
@ -108,22 +108,23 @@
|
||||
#define VM_NRESERVLEVEL 0
|
||||
#endif
|
||||
|
||||
/* virtual sizes (bytes) for various kernel submaps */
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on the amount of kmem_map KVA space: 40% of the entire KVA space.
|
||||
* Optional floor (in bytes) on the size of the kmem arena.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MIN
|
||||
#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
|
||||
* kernel map.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \
|
||||
|
@ -172,21 +172,23 @@ struct pmap_physseg {
|
||||
#define SGROWSIZ (128UL*1024) /* amount to grow stack */
|
||||
#endif
|
||||
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#define VM_KMEM_SIZE_SCALE (3)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on the amount of kmem_map KVA space: 40% of the entire KVA space.
|
||||
* Optional floor (in bytes) on the size of the kmem arena.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MIN
|
||||
#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
|
||||
* usable KVA space.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \
|
||||
|
@ -198,24 +198,22 @@
|
||||
#define USRSTACK (VM_MAX_USER_ADDRESS)
|
||||
|
||||
/*
|
||||
* Virtual size (bytes) for various kernel submaps.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE
|
||||
#define VM_KMEM_SIZE (16*1024*1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How many physical pages per KVA page allocated.
|
||||
* min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
|
||||
* VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
|
||||
* is the total KVA space allocated for kmem_map.
|
||||
* How many physical pages per kmem arena virtual page.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_SCALE
|
||||
#define VM_KMEM_SIZE_SCALE (tsb_kernel_ldd_phys == 0 ? 3 : 2)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ceiling on amount of kmem_map kva space.
|
||||
* Optional floor (in bytes) on the size of the kmem arena.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MIN
|
||||
#define VM_KMEM_SIZE_MIN (16 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional ceiling (in bytes) on the size of the kmem arena: 60% of the
|
||||
* kernel map.
|
||||
*/
|
||||
#ifndef VM_KMEM_SIZE_MAX
|
||||
#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \
|
||||
|
Loading…
Reference in New Issue
Block a user