free_pgtables(9)
π free_pgtables(9)
okay so this is one of those kernel API manual pages β section 9, bestie, we're in the deep internals now π«Ά β and it's literally about freeing a range of page tables. yes, the actual page tables. the scaffolding under the scaffolding. we love a cleanup arc β¨
πΈ NAME πΈ
free_pgtables β frees a range of page tables, no cap, that's the whole job π
β SYNOPSIS β
void free_pgtables (struct mmu_gather *tlb , struct unmap_desc *unmap );
like, that's it. that's the whole signature. void return, two pointers in, page tables out (of existence) π₯
π ARGUMENTS π
tlbβ the mmu gather. yes, that mmu gather. the lil collection bag of things-to-be-flushed π§Ίunmapβ theunmap_desc. it's giving "the descriptor of what we're unmapping" and honestly? iconic π
π¦ NOTE π¦
okay so here's the tea, and you actually need this part β
pg_start and pg_end are provided to indicate the absolute range of the page tables that should be removed. and listen β this range can differ from the vma mappings on some archs, specifically archs that may have mappings that need to be removed outside the vmas π so don't just assume the vmas tell the whole story, bestie.
also, prev->vm_end and next->vm_start are often used. not always, but often. iykyk π
and then there's this one: vma_end differs from pg_end when a dup_mmap failed and the tree has unrelated data to the mm_struct being torn down π so if you're sitting there like "why don't these match", that's why. it's not a bug, it's the failure path, and she is messy π
π SEE ALSO π
kernel file ./mm/memory.c, plus this absolutely stacked cast of characters β genuinely a group chat worth joining π«Ά
free_pgd_range(9)__vm_normal_page(9)vm_normal_page(9)vm_normal_folio(9)vm_normal_page_pmd(9)vm_normal_folio_pmd(9)vm_normal_page_pud(9)restore_exclusive_pte(9)cond_install_uffd_wp_ptes(9)zap_vma_for_reaping(9)unmap_vmas(9)zap_vma_range_batched(9)zap_vma_range(9)zap_special_vma_range(9)vm_insert_pages(9)vm_insert_page(9)vm_map_pages(9)vm_map_pages_zero(9)vmf_insert_pfn_prot(9)vmf_insert_pfn(9)remap_pfn_range(9)vm_iomap_memory(9)__vmf_anon_prepare(9)finish_mkwrite_fault(9)unmap_mapping_folio(9)unmap_mapping_pages(9)unmap_mapping_range(9)set_pte_range(9)finish_fault(9)mm_account_fault(9)follow_pfnmap_start(9)follow_pfnmap_end(9)generic_access_phys(9)access_remote_vm(9)copy_remote_vm_str(9)folio_zero_user(9)
and that's the page, bestie π this one lives in ./mm, dated October 2026, and it's filed as free_pgtables(9) β go forth and free those page tables responsibly, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms