mmget(9)
π mmget(9) β a Kernel API Manual moment π
okay so bestie, you found the mmget(9) page from the Kernel API Manual and honestly? it's a little baddie. let's get into it π«Ά
β¨ NAME β¨
mmget β pin the address space associated with a &struct mm_struct.
like, you're literally telling that address space "you're not going anywhere, bestie" π
β¨ SYNOPSIS β¨
void mmget (struct mm_struct *mm );
β¨ ARGUMENTS β¨
mmβ the address space you wanna pin. that's it, that's the whole arg πΈ
β¨ DESCRIPTION β¨
so the whole vibe here is: make sure that the address space of the given struct mm_struct doesn't go away. no cap. you're holding onto it so it stays put π
but β and this is important β this does not protect against parts of the address space being modified or freed, however. so like, the space stays alive, but the stuff inside it can still get changed on you. it's giving "the building is still standing but someone's rearranging the furniture" π
π¨ never use this function to pin this address space for an unbounded/indefinite amount of time. fr fr, don't do it. this is a short-term commitment situation only.
and when you're done being obsessed with it, use mmput to release the reference acquired by mmget. don't just ghost it, okay? π
also, see also <Documentation/mm/active_mm.rst> for an in-depth explanation of mm_struct.mm_count vs mm_struct.mm_users. if you've ever wondered why there are two of them, that's the lore drop you need, iykyk π
β¨ SEE ALSO β¨
it lives over in the kernel file ./include/linux/sched/mm.h, and it's in very good company:
mmgrab(9)might_alloc(9)memalloc_flags_save(9)memalloc_noio_save(9)memalloc_noio_restore(9)memalloc_nofs_save(9)memalloc_nofs_restore(9)memalloc_noreclaim_save(9)memalloc_noreclaim_restore(9)memalloc_pin_save(9)memalloc_pin_restore(9)set_active_memcg(9)
and that's the whole page, bestie, you ate it up π β¨
sign-off szn: this one comes from ./include/linux/sched, and it's dated October 2026 β so mark your calendars, the mmget(9) era is now ππ¦π
π¦ 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