Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\snapshot.c Create Date:2022-07-28 10:01:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:prepare_image - Make room for loading hibernation image

Proto:static int prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)

Type:int

Parameter:

TypeParameterName
struct memory_bitmap *new_bm
struct memory_bitmap *bm
2469  _image_page - Free a page allocated for hibernation image.*@addr: Address of the page to free.*@clear_nosave_free: If set, clear the PageNosaveFree bit for the page.* The page to free should have been allocated by get_image_page() (page flags
2470  Pointer to an auxiliary buffer (1 page) = NULL
2472  nr_highmem = count_highmem_image_pages(bm)
2473  mark_unsafe_pages - Mark pages that were used before hibernation.* Mark the pages that cannot be used for storing the image during restoration,* because they conflict with the pages that had been used before hibernation.
2475  error = memory_bm_create - Allocate memory for a memory bitmap.
2476  If error Then Go to Free
2479  duplicate_memory_bitmap(new_bm, bm)
2480  memory_bm_free(bm, PG_UNSAFE_KEEP)
2481  If nr_highmem > 0 Then
2482  error = prepare_highmem_image(bm, & nr_highmem)
2483  If error Then Go to Free
2495  nr_pages = Total number of image pages - nr_highmem - allocated_unsafe_pages
2496  nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE)
2497  When nr_pages > 0 cycle
2498  lp = get_image_page - Allocate a page for a hibernation image
2499  If Not lp Then
2500  error = -ENOMEM
2501  Go to Free
2503  next = List of "safe" pages (ie. pages that were not used by the image kernel* before hibernation) that may be used as temporary storage for image kernel* memory contents.
2504  List of "safe" pages (ie. pages that were not used by the image kernel* before hibernation) that may be used as temporary storage for image kernel* memory contents. = lp
2505  nr_pages--
2508  nr_pages = Total number of image pages - nr_highmem - allocated_unsafe_pages
2509  When nr_pages > 0 cycle
2510  lp = get_zeroed_page(DOC: Useful GFP flag combinations* Useful GFP flag combinations* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~* Useful GFP flag combinations that are commonly used. It is recommended* that subsystems start with one of these combinations and then set/clear)
2511  If Not lp Then
2512  error = -ENOMEM
2513  Go to Free
2521  swsusp_set_page_forbidden(virt_to_page(kaddr) returns a valid pointer if and only if* virt_addr_valid(kaddr) returns true.(lp))
2522  Each page frame allocated for creating the image is marked by setting the* corresponding bits in forbidden_pages_map and free_pages_map simultaneously
2523  nr_pages--
2525  Return 0
2527  Free :
2528  swsusp_free - Free pages allocated for hibernation image.* Image pages are alocated before snapshot creation, so they need to be* released after resume.
2529  Return error
Caller
NameDescribe
snapshot_write_nextsnapshot_write_next - Get the address to store the next image page.*@handle: Snapshot handle structure to guide the writing.* On the first call, @handle should point to a zeroed snapshot_handle* structure