snapshot_page(9)
π snapshot_page(9) β or, how to screenshot a page struct, kernel edition π
okay so this is a page from the Kernel API Manual, manual name snapshot_page(9), and bestie it is so much simpler than the name makes it sound. we're literally just taking a snapshot of a struct page. that's it. that's the whole vibe. β¨
πΈ NAME πΈ
snapshot_page β Create a snapshot of a struct page. no cap, that's literally the entire job description.
π¦ SYNOPSIS π¦
void snapshot_page (struct page_snapshot *ps , const struct page *page
);
yes the formatting is a little cursed, don't come for me, that's just how it's written. π
π ARGUMENTS π
psβ a pointer to astruct page_snapshot, and this is where the snapshot goes. it's the little container you're filling up, bestie π«pageβ the page you want to snapshot. the main character of this whole operation π
β¨ DESCRIPTION β¨
so what actually happens: snapshot_page creates a snapshot of the page, and then it stores both its struct page representation and its struct folio representation inside ps. two for the price of one, we love an efficient queen π
now here's the important bit, and i need you to pay attention because this is the part that gets spicy πΆοΈ β a snapshot is marked as "faithful" if the compound state of page was stable and that stability allowed for a safe reconstruction of the folio representation. like, everything lined up, the vibes were immaculate, the reconstruction is trustworthy. π«Ά
but in rare cases that's just not possible (for example, when a folio splitting is happening π β folios are out here living their messy lives and splitting up mid-snapshot), snapshot_page falls back to treating page as a single page. and when it does that, the snapshot is marked as "unfaithful". not a failure exactly, just... the snapshot is being honest with you about what it is. π
and because you're gonna want to know which one you got, there's the snapshot_page_is_faithful helper. use it to check for this exact condition. it's giving "vibe check but for snapshots" β
π SEE ALSO π
the whole friend group, in order, no one left behind:
Kernel file ./mm/util.ckfree_const(9)__kmemdup_nul(9)kstrdup(9)kstrdup_const(9)kstrndup(9)kmemdup(9)kmemdup_array(9)kvmemdup(9)kmemdup_nul(9)memdup_user(9)vmemdup_user(9)strndup_user(9)memdup_user_nul(9)randomize_page(9)__account_locked_vm(9)account_locked_vm(9)__vmalloc_array(9)vmalloc_array(9)__vcalloc(9)vcalloc(9)folio_mapping(9)folio_copy(9)get_cmdline(9)mem_dump_obj(9)compat_set_desc_from_vma(9)__compat_vma_mmap(9)compat_vma_mmap(9)mmap_action_prepare(9)mmap_action_complete(9)folio_pte_batch(9)page_range_contiguous(9)
aaaand that's the whole page, you ate that fr fr π₯
cute little sign-off time: this one lives under ./mm in the source (the Kernel file ./mm/util.c girlies, stand up π§), dated October 2026, and it's snapshot_page(9) from the Kernel API Manual. mwah, go snapshot something responsibly ππ
π¦ 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