函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\snapshot.c Create Date:2022-07-27 11:01:20
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:hibernate_preallocate_memory - Preallocate memory for hibernation image

函数原型:int hibernate_preallocate_memory(void)

返回类型:int

参数:

1703  pages等于0
1708  打印信息("Preallocating image memory... ")
1709  start等于ktime_get()
1711  error等于memory_bm_create - Allocate memory for a memory bitmap.
1712  如果error则转到:err_out
1715  error等于memory_bm_create - Allocate memory for a memory bitmap.
1716  如果error则转到:err_out
1719  Numbers of normal and highmem page frames allocated for hibernation image* before suspending devices.等于0
1720  Numbers of normal and highmem page frames allocated for hibernation image* before suspending devices.等于0
1723  save_highmem等于count_highmem_pages()
1724  saveable等于_data_pages - Compute the total number of saveable non-highmem pages.
1730  count等于saveable
1731  saveable加等于save_highmem
1732  highmem等于save_highmem
1733  size等于0
1734  do nothing (zone)
1735  size加等于snapshot_additional_pages - Estimate the number of extra pages needed
1736  如果s_highmem - helper function to quickly check if a struct zone is a* highmem zone or not. This is an attempt to keep references* to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum.*@zone - pointer to struct zone variablehighmem加等于zone_page_state(zone, NR_FREE_PAGES)
1738  否则count加等于zone_page_state(zone, NR_FREE_PAGES)
1741  avail_normal等于count
1742  count加等于highmem
1743  count减等于linux/mm/page_alloc.c
1746  size加等于page_key_additional_pages(saveable)
1749  max_size等于countsizePAGES_FOR_IO的差除2减2乘DIV_ROUND_UP(Number of bytes to reserve for memory allocations made by device drivers* from their ->freeze() and ->freeze_noirq() callbacks so that they don't* cause image creation to fail (tunable via /sys/power/reserved_size)., PAGE_SIZE)
1752  size等于DIV_ROUND_UP(Preferred image size in bytes (tunable via /sys/power/image_size).* When it is set to N, swsusp will do its best to ensure the image* size will not exceed N bytes, but if that is impossible, it will* try to create the smallest image possible., PAGE_SIZE)
1753  如果size大于max_sizesize等于max_size
1760  如果size大于等于saveable
1761  pages等于preallocate_image_highmem(save_highmem)
1762  pages加等于preallocate_image_memory(saveable - pages, avail_normal)
1763  转到:out
1767  pages等于minimum_image_size - Estimate the minimum acceptable size of an image
1773  如果avail_normal大于pagesavail_normal减等于pages
1775  否则avail_normal等于0
1777  如果size小于pagessize等于min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedlong, pages, max_size)
1786  shrink_all_memory(saveable - size)
1795  pages_highmem等于preallocate_image_highmem(highmem / 2)
1796  alloc等于countmax_size
1797  如果alloc大于pages_highmemalloc减等于pages_highmem
1799  否则alloc等于0
1801  pages等于preallocate_image_memory(alloc, avail_normal)
1802  如果pages小于alloc
1804  alloc减等于pages
1805  pages加等于pages_highmem
1806  pages_highmem等于preallocate_image_highmem(alloc)
1807  如果pages_highmem小于alloc则转到:err_out
1809  pages加等于pages_highmem
1814  alloc等于countpagessize
1815  pages加等于preallocate_image_highmem(alloc)
1816  否则
1821  alloc等于max_sizesize
1822  size等于preallocate_highmem_fraction(alloc, highmem, count)
1823  pages_highmem加等于size
1824  alloc减等于size
1825  size等于preallocate_image_memory(alloc, avail_normal)
1826  pages_highmem加等于preallocate_image_highmem(alloc - size)
1827  pages加等于pages_highmemsize
1835  pages减等于_unnecessary_pages - Release preallocated pages not needed for the image.
1837  out :
1838  stop等于ktime_get()
1839  打印标准信息("done (allocated %lu pages)\n", pages)
1840  swsusp_show_speed - Print time elapsed between two events during hibernation.*@start: Starting event.*@stop: Final event.*@nr_pages: Number of memory pages processed between @start and @stop.*@msg: Additional diagnostic message to print.
1842  返回:0
1844  err_out :
1845  打印标准信息("\n")
1846  swsusp_free - Free pages allocated for hibernation image.* Image pages are alocated before snapshot creation, so they need to be* released after resume.
1847  返回:负ENOMEM
调用者
名称描述
hibernation_snapshothibernation_snapshot - Quiesce devices and create a hibernation image.*@platform_mode: If set, use platform driver to prepare for the transition.* This routine must be called with system_transition_mutex held.