linear_anon_page_index(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… linear_anon_page_index(9)

okay so bestie, welcome to the kernel API manual, and today's main character is linear_anon_page_index β€” it lives in section 9, and it is literally here to figure out the absolute anonymous page offset of @address inside @vma. that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

pgoff_t linear_anon_page_index (const struct vm_area_struct *vma ,
                                const unsigned long address );

yes it's a two-argument situation, no surprises, we love a clean signature. 🫢


🌸 ARGUMENTS 🌸

  • vma β€” the VMA that address is chilling inside. it's gotta be either an anonymous VMA or a MAP_PRIVATE file-backed one. that's the assignment, no substitutions. πŸ’…
  • address β€” the address whose absolute page offset we're being nosy about. that's it, that's the ask. ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: this function returns the anonymous page offset of address. and by that we mean the page offset that the address had at the moment the VMA was first faulted. like, its original era. its first-era offset. iconic behavior honestly. πŸ‘‘

for anonymous mappings, this bad boy hands back the exact same value as linear_page_index. same answer, different function name, we respect it. πŸ’–

for MAP_PRIVATE file-backed mappings, it returns the anonymous page offset of address β€” which again is the page offset the address possessed back when the VMA was first faulted. first-fault era. we do not forget. πŸ“Œ

⚠️ and listen, bestie, this one is important: it is not valid to call this function for shared file-backed mappings. not valid. do not do it. i'm not gonna sugarcoat it β€” that's a hard no. 🚫😭

πŸ”₯ RETURN πŸ”₯

it returns the absolute anonymous page offset of address within vma. that's the return value. that's the whole point. periodt. πŸ’€βœ¨


🌈 SEE ALSO 🌈

the whole friend group, coming through β€” kernel file ./include/linux/pagemap.h plus:

filemap_set_wb_err(9), filemap_check_wb_err(9), filemap_sample_wb_err(9), file_sample_sb_err(9), mapping_set_error(9), mapping_set_large_folios(9), mapping_align_index(9), mapping_pmd_folio_support(9), folio_flush_mapping(9), folio_inode(9), folio_attach_private(9), folio_change_private(9), folio_detach_private(9), fgf_t(9), fgf_set_order(9), write_begin_get_folio(9), filemap_get_folio(9), filemap_lock_folio(9), filemap_grab_folio(9), find_get_page(9), find_lock_page(9), find_or_create_page(9), grab_cache_page_nowait(9), folio_next_index(9), folio_next_pos(9), folio_file_page(9), folio_contains(9), page_pgoff(9), folio_pos(9), linear_page_delta(9), linear_page_index(9), folio_trylock(9), folio_lock(9), lock_page(9), folio_lock_killable(9), filemap_range_needs_writeback(9), struct readahead_control(9), page_cache_sync_readahead(9), page_cache_async_readahead(9), readahead_folio(9), readahead_pos(9), readahead_length(9), readahead_index(9), readahead_count(9), readahead_batch_length(9), folio_mkwrite_check_truncate(9), i_blocks_per_folio(9)


and that's the whole page, bestie β€” go read a folio, hydrate, and remember: no shared file-backed mappings, we die like people who read the docs. πŸ§šπŸ’œ

source: ./include/linux Β· October 2026 Β· linear_anon_page_index(9) β€” mwah, see u in the group chat πŸ’‹πŸŽ€

πŸ“¦ where this page comes from