mmgrab(9)
π¦ mmgrab(9) β Kernel API Manual, bestie edition π
okay so welcome to mmgrab(9), aka the Kernel API Manual page that's about to make pinning a &struct mm_struct make sense π
β¨ NAME β¨
mmgrab β Pin a &struct mm_struct. Periodt π
π SYNOPSIS π
void mmgrab (struct mm_struct *mm );
π ARGUMENTS π
mmβ Thestruct mm_structto pin. That's the whole argument, bestie π«Ά
π DESCRIPTION π
Okay so the main character job here: make sure mm will not get freed even after the owning task exits. No cap, that's the whole point π
π¨ Important vibe check: this doesn't guarantee that the associated address space will still exist later on. Before you access it, mmget_not_zero has to be used. Periodt.
This is a preferred way to pin mm for a longer/unbounded amount of time. Slay, that's literally what it's for β¨
When you're done and you need to release the reference acquired by mmgrab, use mmdrop β don't leave it hanging, bestie π
Also see <Documentation/mm/active_mm.rst> for an in-depth explanation of mm_struct.mm_count vs mm_struct.mm_users. iykyk π¦
π₯ SEE ALSO π₯
Kernel file ./include/linux/sched/mm.h:
mmget(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)
mwah π β source/version ./include/linux/sched, date October 2026, page mmgrab(9). bye bestie πβ¨
π¦ 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