prepare_highmem_image(9)
π prepare_highmem_image(9) π
okay so bestie, welcome to the prepare_highmem_image page from the Kernel API Manual β yes that's the manual name, it's giving very serious kernel energy and honestly? iconic. sit down, grab a snack π, we're learning about allocating memory for loading highmem data from an image. no cap.
β¨ NAME β¨
prepare_highmem_image β allocate memory for loading highmem data from image. that's it, that's the whole vibe. π«Ά
πΈ SYNOPSIS πΈ
int prepare_highmem_image (struct memory_bitmap *bm , unsigned int
*nr_highmem_p );
look at her. so clean. so signature. π
π ARGUMENTS π
bmβ pointer to an uninitialized memory bitmap structure. bestie, note the word uninitialized β this is not a "oops I forgot to init it" situation, that's the whole assignment. πnr_highmem_pβ pointer to the number of highmem image pages. it's a pointer, so it's pointing at the variable holding that count. π¦
π₯ DESCRIPTION π₯
okay so here's what she does: prepare_highmem_image tries to allocate as many highmem pages as there are highmem image pages. and where does it get that number? nr_highmem_p points to the variable containing the number of highmem image pages. iykyk.
the pages that are "safe" β and by "safe" we mean they will not be overwritten when the hibernation image is restored entirely π β get the corresponding bits set in bm.
and bm must be uninitialized. literally the requirement. don't come in here with a pre-baked bitmap, that's not the move. π
π NOTE π
do not call this function if there are no highmem image pages. like, at all. fr fr. this is not a drill, this is the documented note and we respect it. π«
π SEE ALSO π
kernel file ./kernel/power/snapshot.c β and the whole friend group, all of them, no one gets left out:
get_image_page(9)free_image_page(9)alloc_rtree_node(9)free_mem_extents(9)create_mem_extents(9)memory_bm_next_pfn(9)mark_nosave_pages(9)create_basic_memory_bitmaps(9)free_basic_memory_bitmaps(9)snapshot_additional_pages(9)count_free_highmem_pages(9)count_highmem_pages(9)count_data_pages(9)swsusp_free(9)preallocate_image_pages(9)free_unnecessary_pages(9)minimum_image_size(9)hibernate_preallocate_memory(9)pack_pfns(9)snapshot_read_next(9)unpack_orig_pfns(9)count_highmem_image_pages(9)copy_last_highmem_page(9)prepare_image(9)snapshot_write_next(9)restore_highmem(9)
and that's the page, bestie β you ate that. this one lives under ./kernel/power and it's dated October 2026. mwah πβ¨
π¦ 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