page_address_in_vma(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… page_address_in_vma β€” the Kernel API Manual (yep, that's the manual, we're in it)

okay so bestie, welcome to page_address_in_vma(9) β€” genuinely one of those little functions that does exactly what its name says, which, honestly? iconic behavior. no cap. ✨


🌸 NAME

page_address_in_vma β€” the virtual address of a page in this VMA. that's it, that's the whole vibe πŸŽ€


✨ SYNOPSIS

unsigned long page_address_in_vma (const struct folio *folio , const
       struct page *page , const struct vm_area_struct *vma );

like, look at it. three args, one unsigned long out. clean. minimal. main character energy. πŸ‘‘


🫢 ARGUMENTS

  • folio β€” the folio containing the page. it's the big container energy, the friend group the page belongs to πŸ’–
  • page β€” the page within the folio. yes bestie, the actual page inside that folio. we love a nested situation πŸͺ†
  • vma β€” the VMA we need to know the address in. that's the memory region we're asking about, fr fr πŸ—ΊοΈ

πŸ¦‹ DESCRIPTION

so what it actually does: it calculates the user virtual address of this page in the specified VMA. that's the whole thing. nailed it. ⭐

but here's the part where you gotta listen, babes 🚨 β€” it is the caller's responsibility to check that the page is actually within the VMA. this function is not doing that vibe check for you. you're on your own there, iykyk πŸ™ˆ

also: there may not currently be a PTE pointing at this page. like, right now, maybe nothing. but if a page fault occurs at this address, this is the page which will be accessed. so it's giving foreshadowing. it's giving "trust me, this is where it's gonna be." πŸ’€βœ¨


πŸ”’ CONTEXT

before you even think about calling this, two rules, and they're not optional:

  • the caller should hold a reference to the folio 🫢
  • the caller should hold a lock (eg the i_mmap_lock or the mmap_lock) which keeps the VMA from being altered πŸ›‘οΈ

that second one matters. the VMA cannot be getting shuffled around under you while you're doing this. hold the lock. be a responsible little gremlin. 🌈


πŸ‘‘ RETURN

the virtual address corresponding to this page in the VMA. an unsigned long. that's the gift. that's the whole payoff. take it and go πŸ’


🧚 SEE ALSO

kernel file ./mm/rmap.c and honestly the whole extended friend group:

that's the whole rmap squad right there. pt-es, pmd, pud, anon, file, add, remove, unmap, migrate β€” the full roster. obsessed. πŸ“


lowkey reminder: check the page is in the VMA yourself, and hold that folio reference + lock. this function trusts you. don't make it regret that. πŸ’œ

and that's the tea! β˜• this little gem lives in ./mm, and this particular page is dated October 2026 β€” so like, see you in the future bestie, mwah πŸ’‹πŸŽ€βœ¨

πŸ“¦ where this page comes from