pmd_alloc_one(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 β€” the mm_struct of 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:

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