Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_kern.c
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | |||||
#if VM_NRESERVLEVEL > 0 | #if VM_NRESERVLEVEL > 0 | ||||
#define KVA_QUANTUM_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT) | #define KVA_QUANTUM_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT) | ||||
#else | #else | ||||
/* On non-superpage architectures we want large import sizes. */ | /* On non-superpage architectures we want large import sizes. */ | ||||
#define KVA_QUANTUM_SHIFT (8 + PAGE_SHIFT) | #define KVA_QUANTUM_SHIFT (8 + PAGE_SHIFT) | ||||
#endif | #endif | ||||
#define KVA_QUANTUM (1 << KVA_QUANTUM_SHIFT) | #define KVA_QUANTUM (1 << KVA_QUANTUM_SHIFT) | ||||
#define KVA_NUMA_IMPORT_QUANTUM (KVA_QUANTUM * 128) | |||||
extern void uma_startup2(void); | extern void uma_startup2(void); | ||||
/* | /* | ||||
* kva_alloc: | * kva_alloc: | ||||
* | * | ||||
* Allocate a virtual address range with no underlying object and | * Allocate a virtual address range with no underlying object and | ||||
* no initial mapping to physical memory. Any mapping from this | * no initial mapping to physical memory. Any mapping from this | ||||
▲ Show 20 Lines • Show All 601 Lines • ▼ Show 20 Lines | |||||
* data, bss, and all space allocated thus far (`boostrap' data). The | * data, bss, and all space allocated thus far (`boostrap' data). The | ||||
* new map will thus map the range between VM_MIN_KERNEL_ADDRESS and | * new map will thus map the range between VM_MIN_KERNEL_ADDRESS and | ||||
* `start' as allocated, and the range between `start' and `end' as free. | * `start' as allocated, and the range between `start' and `end' as free. | ||||
* Create the kernel vmem arena and its per-domain children. | * Create the kernel vmem arena and its per-domain children. | ||||
*/ | */ | ||||
void | void | ||||
kmem_init(vm_offset_t start, vm_offset_t end) | kmem_init(vm_offset_t start, vm_offset_t end) | ||||
{ | { | ||||
vm_size_t quantum; | |||||
int domain; | int domain; | ||||
vm_map_init(kernel_map, kernel_pmap, VM_MIN_KERNEL_ADDRESS, end); | vm_map_init(kernel_map, kernel_pmap, VM_MIN_KERNEL_ADDRESS, end); | ||||
kernel_map->system_map = 1; | kernel_map->system_map = 1; | ||||
vm_map_lock(kernel_map); | vm_map_lock(kernel_map); | ||||
/* N.B.: cannot use kgdb to debug, starting with this assignment ... */ | /* N.B.: cannot use kgdb to debug, starting with this assignment ... */ | ||||
(void)vm_map_insert(kernel_map, NULL, 0, | (void)vm_map_insert(kernel_map, NULL, 0, | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
Show All 13 Lines | #ifdef __amd64__ | ||||
(void)vm_map_insert(kernel_map, NULL, 0, (vm_offset_t)vm_page_array, | (void)vm_map_insert(kernel_map, NULL, 0, (vm_offset_t)vm_page_array, | ||||
(vm_offset_t)vm_page_array + round_2mpage(vm_page_array_size * | (vm_offset_t)vm_page_array + round_2mpage(vm_page_array_size * | ||||
sizeof(struct vm_page)), | sizeof(struct vm_page)), | ||||
VM_PROT_RW, VM_PROT_RW, MAP_NOFAULT); | VM_PROT_RW, VM_PROT_RW, MAP_NOFAULT); | ||||
#endif | #endif | ||||
vm_map_unlock(kernel_map); | vm_map_unlock(kernel_map); | ||||
/* | /* | ||||
* Use a large import quantum on NUMA systems. This helps minimize | |||||
* interleaving of superpages, reducing internal fragmentation within | |||||
* the per-domain arenas. | |||||
*/ | |||||
if (vm_ndomains > 1 && PMAP_HAS_DMAP) | |||||
quantum = KVA_NUMA_IMPORT_QUANTUM; | |||||
else | |||||
quantum = KVA_QUANTUM; | |||||
/* | |||||
* Initialize the kernel_arena. This can grow on demand. | * Initialize the kernel_arena. This can grow on demand. | ||||
*/ | */ | ||||
vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0); | vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0); | ||||
vmem_set_import(kernel_arena, kva_import, NULL, NULL, KVA_QUANTUM); | vmem_set_import(kernel_arena, kva_import, NULL, NULL, quantum); | ||||
for (domain = 0; domain < vm_ndomains; domain++) { | for (domain = 0; domain < vm_ndomains; domain++) { | ||||
/* | /* | ||||
* Initialize the per-domain arenas. These are used to color | * Initialize the per-domain arenas. These are used to color | ||||
* the KVA space in a way that ensures that virtual large pages | * the KVA space in a way that ensures that virtual large pages | ||||
* are backed by memory from the same physical domain, | * are backed by memory from the same physical domain, | ||||
* maximizing the potential for superpage promotion. | * maximizing the potential for superpage promotion. | ||||
*/ | */ | ||||
vm_dom[domain].vmd_kernel_arena = vmem_create( | vm_dom[domain].vmd_kernel_arena = vmem_create( | ||||
"kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); | "kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); | ||||
vmem_set_import(vm_dom[domain].vmd_kernel_arena, | vmem_set_import(vm_dom[domain].vmd_kernel_arena, | ||||
kva_import_domain, NULL, kernel_arena, KVA_QUANTUM); | kva_import_domain, NULL, kernel_arena, quantum); | ||||
/* | /* | ||||
* In architectures with superpages, maintain separate arenas | * In architectures with superpages, maintain separate arenas | ||||
* for allocations with permissions that differ from the | * for allocations with permissions that differ from the | ||||
* "standard" read/write permissions used for kernel memory, | * "standard" read/write permissions used for kernel memory, | ||||
* so as not to inhibit superpage promotion. | * so as not to inhibit superpage promotion. | ||||
* | |||||
* Use the base import quantum since this arena is rarely used. | |||||
*/ | */ | ||||
#if VM_NRESERVLEVEL > 0 | #if VM_NRESERVLEVEL > 0 | ||||
vm_dom[domain].vmd_kernel_rwx_arena = vmem_create( | vm_dom[domain].vmd_kernel_rwx_arena = vmem_create( | ||||
"kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); | "kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); | ||||
vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena, | vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena, | ||||
kva_import_domain, (vmem_release_t *)vmem_xfree, | kva_import_domain, (vmem_release_t *)vmem_xfree, | ||||
kernel_arena, KVA_QUANTUM); | kernel_arena, KVA_QUANTUM); | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |