prepare_image(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

prepare_image(9) πŸ’– the kernel api manual, bestie

okay so this is prepare_image from the prepare_image(9) manual page, and we're gonna get into it because ngl this function is lowkey doing a lot. ✨


NAME 🌸

prepare_image β€” make room for loading hibernation image. periodt.


SYNOPSIS πŸŽ€

int prepare_image (struct memory_bitmap *new_bm , struct memory_bitmap
*bm , struct memory_bitmap
*zero_bm );

ARGUMENTS πŸ’…

  • new_bm β€” uninitialized memory bitmap structure. it's giving blank canvas energy, not me about to fill it in.
  • bm β€” memory bitmap with unsafe pages marked. like, the pages that are gonna get overwritten? they're flagged here, bestie.
  • zero_bm β€” memory bitmap containing the zero pages. the zeros are living their best life in this one.

DESCRIPTION πŸ¦‹

use bm to mark the pages that will be overwritten in the process of restoring the system memory state from the suspend image (the "unsafe" pages) and allocate memory for the image. no cap, that's the whole vibe check.

the idea is to allocate a new memory bitmap first and then allocate as many pages as needed for image data, but without specifying what those pages will be used for just yet β€” like, we're manifesting pages but not labeling them, iykyk. instead, we mark them all as allocated and create a lists of "safe" pages to be used later. on systems with high memory a list of "safe" highmem pages is created too. slay for highmem honestly.

because it was not known which pages were unsafe when zero_bm was created, make a copy of it and recreate it within safe pages. literally the glow-up of bitmaps, we love to see it. 🫢


SEE ALSO πŸ”₯

bestie, the crossover episode is real. go check out:


and that's the page! gentle reminder this one lives in ./kernel/power, dated October 2026, and it's part of the kernel api manual. made with πŸ’– for the kernel girlies. bye bestie, go mark some safe pages! πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from