mmu_notifier_register(9)
π mmu_notifier_register(9) π
ok so you found a page from the Kernel API Manual (yes girl, kernel internals, we're doing this π§) and honestly? it's a whole vibe. let's get into it.
β¨ NAME β¨
mmu_notifier_register β the function where you register a notifier on a mm. that's it, that's the whole name. iconic behavior honestly π
π¦ SYNOPSIS π¦
int mmu_notifier_register (struct mmu_notifier *subscription , struct
mm_struct *mm );
two args in, an int out, slay.
πΈ ARGUMENTS πΈ
subscriptionβ the notifier you're attaching, bestie. this is the main character of the operation πmmβ the mm you're attaching that notifier to. the venue, the location, the place where it all goes down β¨
π₯ DESCRIPTION π₯
okay so listen up because this part is important and i'm not being dramatic (i am being a little dramatic). when you call this registration function, you must not hold mmap_lock β nope, not that, and also not any other VM related lock. so put the locks DOWN before you call, okay? π«Ά
you also gotta make sure mm_users can't go down to zero while this is running, because otherwise you get races with mmu_notifier_release and nobody wants that energy π. so mm has to be current->mm, OR the mm should be pinned safely β like with get_task_mm. and if the mm is not current->mm? then you release that mm_users pin by calling mmput after mmu_notifier_register returns. cleanup era π
mmu_notifier_unregister or mmu_notifier_put must always be called to unregister the notifier. always always. no cap. this is not optional, this is the law π
and here's a cute little detail: while the caller has a mmu_notifier, the subscription->mm pointer will remain valid, and it can be converted to an active mm pointer via mmget_not_zero. it's giving stable relationship π₯°
β οΈ real talk: the "no locks" rule and the "mm_users can't hit zero" rule are the whole safety story here. skip them and you're in undefined-behavior territory, and not the fun kind π
π SEE ALSO π
- the Kernel file
./mm/mmu_notifier.cβ go read it, it's right there mmu_interval_read_begin(9)mmu_notifier_get_locked(9)mmu_notifier_put(9)mmu_interval_notifier_insert(9)mmu_interval_notifier_remove(9)mmu_notifier_synchronize(9)
all the siblings, all the cousins, one big notifier family reunion π¦π
and that's the page!! sourced from ./mm, version date October 2026, and it's literally titled mmu_notifier_register(9) β so yeah, that's the whole thing. go forth and register responsibly, 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