pmap_growkernel: Use VM_ALLOC_NOFREE when allocating pagetable pages

This patch modifies pmap_growkernel in all pmaps to use VM_ALLOC_NOFREE
when allocating new pagetable pages. This should help reduce longterm
fragmentation as these pages are never released after
they are allocated.

Differential Revision:	https://reviews.freebsd.org/D45998
Reviewed by:	alc, markj, kib, mhorne
Tested by:	alc
This commit is contained in:
Bojan Novković 2024-07-16 17:12:25 +02:00
parent 3f32a7e4ee
commit ddc09a10ea
6 changed files with 16 additions and 15 deletions

View File

@ -5156,8 +5156,8 @@ pmap_growkernel(vm_offset_t addr)
pdpe = pmap_pdpe(kernel_pmap, end); pdpe = pmap_pdpe(kernel_pmap, end);
if ((*pdpe & X86_PG_V) == 0) { if ((*pdpe & X86_PG_V) == 0) {
nkpg = pmap_alloc_pt_page(kernel_pmap, nkpg = pmap_alloc_pt_page(kernel_pmap,
pmap_pdpe_pindex(end), VM_ALLOC_WIRED | pmap_pdpe_pindex(end), VM_ALLOC_INTERRUPT |
VM_ALLOC_INTERRUPT | VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
paddr = VM_PAGE_TO_PHYS(nkpg); paddr = VM_PAGE_TO_PHYS(nkpg);
@ -5176,7 +5176,8 @@ pmap_growkernel(vm_offset_t addr)
} }
nkpg = pmap_alloc_pt_page(kernel_pmap, pmap_pde_pindex(end), nkpg = pmap_alloc_pt_page(kernel_pmap, pmap_pde_pindex(end),
VM_ALLOC_WIRED | VM_ALLOC_INTERRUPT | VM_ALLOC_ZERO); VM_ALLOC_INTERRUPT | VM_ALLOC_NOFREE | VM_ALLOC_WIRED |
VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
paddr = VM_PAGE_TO_PHYS(nkpg); paddr = VM_PAGE_TO_PHYS(nkpg);

View File

@ -2067,7 +2067,7 @@ pmap_growkernel(vm_offset_t addr)
* Install new PT2s page into kernel PT2TAB. * Install new PT2s page into kernel PT2TAB.
*/ */
m = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | m = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_WIRED | VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (m == NULL) if (m == NULL)
panic("%s: no memory to grow kernel", __func__); panic("%s: no memory to grow kernel", __func__);
m->pindex = pte1_index(kernel_vm_end) & ~PT2PG_MASK; m->pindex = pte1_index(kernel_vm_end) & ~PT2PG_MASK;

View File

@ -2959,7 +2959,7 @@ pmap_growkernel(vm_offset_t addr)
if (pmap_load(l1) == 0) { if (pmap_load(l1) == 0) {
/* We need a new PDP entry */ /* We need a new PDP entry */
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_WIRED | VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L1_SHIFT; nkpg->pindex = kernel_vm_end >> L1_SHIFT;
@ -2978,8 +2978,8 @@ pmap_growkernel(vm_offset_t addr)
continue; continue;
} }
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L2_SHIFT; nkpg->pindex = kernel_vm_end >> L2_SHIFT;

View File

@ -2264,8 +2264,8 @@ __CONCAT(PMTYPE, growkernel)(vm_offset_t addr)
continue; continue;
} }
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> PDRSHIFT; nkpg->pindex = kernel_vm_end >> PDRSHIFT;

View File

@ -3580,7 +3580,7 @@ mmu_radix_growkernel(vm_offset_t addr)
if ((be64toh(*l2e) & PG_V) == 0) { if ((be64toh(*l2e) & PG_V) == 0) {
/* We need a new PDP entry */ /* We need a new PDP entry */
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_WIRED | VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L2_PAGE_SIZE_SHIFT; nkpg->pindex = kernel_vm_end >> L2_PAGE_SIZE_SHIFT;
@ -3598,8 +3598,8 @@ mmu_radix_growkernel(vm_offset_t addr)
continue; continue;
} }
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = pmap_l3e_pindex(kernel_vm_end); nkpg->pindex = pmap_l3e_pindex(kernel_vm_end);

View File

@ -1832,7 +1832,7 @@ pmap_growkernel(vm_offset_t addr)
if (pmap_load(l1) == 0) { if (pmap_load(l1) == 0) {
/* We need a new PDP entry */ /* We need a new PDP entry */
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_WIRED | VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L1_SHIFT; nkpg->pindex = kernel_vm_end >> L1_SHIFT;
@ -1857,8 +1857,8 @@ pmap_growkernel(vm_offset_t addr)
continue; continue;
} }
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED | nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_ZERO); VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL) if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel"); panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L2_SHIFT; nkpg->pindex = kernel_vm_end >> L2_SHIFT;