pmd_alloc_one(9)
β¨ pmd_alloc_one(9) β¨
okay so real quick β this is a page from the Kernel API Manual, bestie, and it's all about one very specific little function: pmd_alloc_one. she allocates memory for a PMD-level page table. that's her whole job. icon behavior. π
πΈ NAME πΈ
pmd_alloc_one β allocate memory for a PMD-level page table
yes that's literally it, that's the whole vibe. no cap.
π SYNOPSIS π
pmd_t * pmd_alloc_one (struct mm_struct *mm , unsigned long addr );
look at her. two arguments. one pointer out. a whole little diva. β¨
π¦ ARGUMENTS π¦
mmβ themm_structof the current context. like, whose memory map are we talking about here. bestie's whole address space, basically. π«Άaddrβ-- undescribed --
okay so about addrβ¦ the docs literally just say -- undescribed --. not me making this up, that's genuinely what's written. so like. nobody documented it. it's giving mysterious. it's giving main character with no backstory. π we respect the silence. (please don't come for me, i'm just the messenger.)
π DESCRIPTION π
so what does she actually do? she allocates memory for a page table and a ptdesc, and then she runs pagetable_pmd_ctor. that's the whole routine. get the memory, run the constructor, slay. π₯
as for which allocation flavour she uses, it depends on context, and this part is important so pay attention:
- in user context, allocations use
GFP_PGTABLE_USER - in kernel context, allocations use
GFP_PGTABLE_KERNEL
that's the vibe check on her memory flags. correct flag for the correct context, always. periodt. π
β RETURN β
she returns a pointer to the allocated memory β or NULL on error. so like, always check the return value, bestie. NULL is her way of saying "not today". π
π SEE ALSO π
if you're obsessed with this one (and honestly why wouldn't you be), the lore continues in the kernel file ./include/asm-generic/pgalloc.h, plus these iconic little friends:
__pte_alloc_one_kernel(9)pte_alloc_one_kernel(9)pte_free_kernel(9)__pte_alloc_one(9)pte_alloc_one(9)pte_free(9)pud_alloc_one(9)
go read them. iykyk. π§
and that's the whole page, fr fr π it lives over in ./include/asm-generic and it's dated October 2026, so like, future-flavoured documentation. signed off with love and also pmd_alloc_one(9) β 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