* kmem_init: * * Create the kernel map; insert a mapping covering kernel text, * data, bss, and all space allocated thus far (`boostrap' data). The * 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. * Create the kernel vmem arena and its per-domain children. */
| 744 | * Create the kernel vmem arena and its per-domain children. |
| 745 | */ |
| 746 | void |
| 747 | kmem_init(vm_offset_t start, vm_offset_t end) |
| 748 | { |
| 749 | vm_size_t quantum; |
| 750 | int domain; |
| 751 | |
| 752 | vm_map_init(kernel_map, kernel_pmap, VM_MIN_KERNEL_ADDRESS, end); |
| 753 | kernel_map->system_map = 1; |
| 754 | vm_map_lock(kernel_map); |
| 755 | /* N.B.: cannot use kgdb to debug, starting with this assignment ... */ |
| 756 | (void)vm_map_insert(kernel_map, NULL, 0, |
| 757 | #ifdef __amd64__ |
| 758 | KERNBASE, |
| 759 | #else |
| 760 | VM_MIN_KERNEL_ADDRESS, |
| 761 | #endif |
| 762 | start, VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT); |
| 763 | /* ... and ending with the completion of the above `insert' */ |
| 764 | |
| 765 | #ifdef __amd64__ |
| 766 | /* |
| 767 | * Mark KVA used for the page array as allocated. Other platforms |
| 768 | * that handle vm_page_array allocation can simply adjust virtual_avail |
| 769 | * instead. |
| 770 | */ |
| 771 | (void)vm_map_insert(kernel_map, NULL, 0, (vm_offset_t)vm_page_array, |
| 772 | (vm_offset_t)vm_page_array + round_2mpage(vm_page_array_size * |
| 773 | sizeof(struct vm_page)), |
| 774 | VM_PROT_RW, VM_PROT_RW, MAP_NOFAULT); |
| 775 | #endif |
| 776 | vm_map_unlock(kernel_map); |
| 777 | |
| 778 | /* |
| 779 | * Use a large import quantum on NUMA systems. This helps minimize |
| 780 | * interleaving of superpages, reducing internal fragmentation within |
| 781 | * the per-domain arenas. |
| 782 | */ |
| 783 | if (vm_ndomains > 1 && PMAP_HAS_DMAP) |
| 784 | quantum = KVA_NUMA_IMPORT_QUANTUM; |
| 785 | else |
| 786 | quantum = KVA_QUANTUM; |
| 787 | |
| 788 | /* |
| 789 | * Initialize the kernel_arena. This can grow on demand. |
| 790 | */ |
| 791 | vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0); |
| 792 | vmem_set_import(kernel_arena, kva_import, NULL, NULL, quantum); |
| 793 | |
| 794 | for (domain = 0; domain < vm_ndomains; domain++) { |
| 795 | /* |
| 796 | * Initialize the per-domain arenas. These are used to color |
| 797 | * the KVA space in a way that ensures that virtual large pages |
| 798 | * are backed by memory from the same physical domain, |
| 799 | * maximizing the potential for superpage promotion. |
| 800 | */ |
| 801 | vm_dom[domain].vmd_kernel_arena = vmem_create( |
| 802 | "kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); |
| 803 | vmem_set_import(vm_dom[domain].vmd_kernel_arena, |
no test coverage detected