函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:save_image_lzo - Save the suspend image data compressed with LZO.*@handle: Swap map handle to use for saving the image.*@snapshot: Image to read data from.*@nr_to_write: Number of pages to save.

函数原型:static int save_image_lzo(struct swap_map_handle *handle, struct snapshot_handle *snapshot, unsigned int nr_to_write)

返回类型:int

参数:

类型参数名称
struct swap_map_handle *handle
struct snapshot_handle *snapshot
unsigned intnr_to_write
671  ret等于0
679  unsigned char * page = NULL
680  struct cmp_data * data = NULL
681  struct crc_data * crc = NULL
683  hib_init_batch( & hb)
689  nr_threads等于num_online_cpus()减1
690  nr_threads等于clamp_val - return a value clamped to a given range using val's type*@val: current value*@lo: minimum allowable value*@hi: maximum allowable value* This macro does no typechecking and uses temporary variables of whatever* type the input argument @val is(nr_threads, 1, Maximum number of threads for compression/decompression. )
692  page等于__get_free_page(GFP_NOIO | __GFP_HIGH)
693  如果非page
694  打印错误信息("Failed to allocate LZO page\n")
695  ret等于负ENOMEM
696  转到:out_clean
699  data等于vmalloc(array_size() - Calculate size of 2-dimensional array.*@a: dimension one*@b: dimension two* Calculates size of 2-dimensional array: @a *@b.* Returns: number of bytes needed to represent the array or SIZE_MAX on* overflow.)
700  如果非data
701  打印错误信息("Failed to allocate LZO data\n")
702  ret等于负ENOMEM
703  转到:out_clean
705 thr小于nr_threads循环memset( & data[thr], 0, offsetof(structcmp_data, go))
708  crc等于开辟内存
709  如果非crc
710  打印错误信息("Failed to allocate crc\n")
711  ret等于负ENOMEM
712  转到:out_clean
714  memset(crc, 0, offsetof(structcrc_data, go))
719 thr小于nr_threads循环
720  init_waitqueue_head( & start compression )
721  init_waitqueue_head( & compression done )
723  hread 等于kthread_run - create and wake a thread.*@threadfn: the function to run until signal_pending(current).*@data: data ptr for @threadfn.*@namefmt: printf-style name for the thread.* Description: Convenient wrapper for kthread_create() followed by(Compression function that runs in its own thread., & data[thr], "image_compress/%u", thr)
726  如果是错误
727  hread = NULL
728  打印错误信息("Cannot start compression threads\n")
729  ret等于负ENOMEM
730  转到:out_clean
737  init_waitqueue_head( & start crc update )
738  init_waitqueue_head( & crc update done )
740  crc32等于0
741  points to handle's crc32 等于crc32
742 thr小于nr_threads循环
743  uncompressed data [thr]等于unc
744  uncompressed lengths [thr]等于uncompressed length
747  hread 等于kthread_run - create and wake a thread.*@threadfn: the function to run until signal_pending(current).*@data: data ptr for @threadfn.*@namefmt: printf-style name for the thread.* Description: Convenient wrapper for kthread_create() followed by(CRC32 update function that runs in its own thread., crc, "image_crc32")
748  如果是错误
749  hread = NULL
750  打印错误信息("Cannot start CRC32 thread\n")
751  ret等于负ENOMEM
752  转到:out_clean
759  reqd_free_pages等于Number of pages required to be kept free while writing the image. Always* half of all available low pages before the writing starts.
761  打印信息("Using %u thread(s) for compression\n", nr_threads)
762  打印信息("Compressing and saving image data (%u pages)...\n", nr_to_write)
764  m等于nr_to_write除10
765  如果非mm等于1
767  nr_pages等于0
768  start等于ktime_get()
769  循环
770 thr小于nr_threads循环
771 off小于LZO_UNC_SIZE循环
787  如果非off退出
796  如果非thr退出
799  r current threads 等于thr
800  atomic_set( & ady to start flag , 1)
801  wake_up( & start crc update )
803 thr小于run_threads循环
808  ret等于urn code
810  如果ret小于0则
811  打印错误信息("LZO compression failed\n")
812  转到:out_finish
818  打印错误信息("Invalid LZO compressed length\n")
819  ret等于负1
820  转到:out_finish
838  ret等于swap_write_page(handle, page, & hb)
839  如果ret则转到:out_finish
844  wait_event - sleep until a condition gets true*@wq_head: the waitqueue to wait on*@condition: a C expression for the event to wait for* The process is put to sleep (TASK_UNINTERRUPTIBLE) until the*@condition evaluates to true(crc update done , atomic_read( & ady to stop flag ))
845  atomic_set( & ady to stop flag , 0)
848  out_finish :
849  err2等于hib_wait_io( & hb)
850  stop等于ktime_get()
851  如果非retret等于err2
853  如果非ret打印信息("Image saving done\n")
855  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.
856  out_clean :
857  如果crc
858  如果hread 结束线程的运行
860  释放内存
862  如果data
863 thr小于nr_threads循环如果hread
865  结束线程的运行
866  vfree(data)
868  如果pagefree_page((unsignedlong)page)
870  返回:ret
调用者
名称描述
swsusp_writeswsusp_write - Write entire image and metadata.*@flags: flags to pass to the "boot" kernel in the image header* It is important _NOT_ to umount filesystems at this point. We want* them synced (in case something goes wrong) but we DO not want to mark