函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:load_image_lzo - Load compressed image data and decompress them with LZO.*@handle: Swap map handle to use for loading data.*@snapshot: Image to copy uncompressed data into.*@nr_to_read: Number of pages to load.

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

返回类型:int

参数:

类型参数名称
struct swap_map_handle *handle
struct snapshot_handle *snapshot
unsigned intnr_to_read
1159  ret等于0
1160  eof等于0
1167  ring等于0, pg等于0, ring_size等于0, have等于0, asked等于0
1169  read_pages等于0
1170  unsigned char * * page = NULL
1171  struct dec_data * data = NULL
1172  struct crc_data * crc = NULL
1174  hib_init_batch( & hb)
1180  nr_threads等于num_online_cpus()减1
1181  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. )
1183  page等于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.)
1184  如果非page
1185  打印错误信息("Failed to allocate LZO page\n")
1186  ret等于负ENOMEM
1187  转到:out_clean
1190  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.)
1191  如果非data
1192  打印错误信息("Failed to allocate LZO data\n")
1193  ret等于负ENOMEM
1194  转到:out_clean
1196 thr小于nr_threads循环memset( & data[thr], 0, offsetof(structdec_data, go))
1199  crc等于开辟内存
1200  如果非crc
1201  打印错误信息("Failed to allocate crc\n")
1202  ret等于负ENOMEM
1203  转到:out_clean
1205  memset(crc, 0, offsetof(structcrc_data, go))
1207  clean_pages_on_decompress = true
1212 thr小于nr_threads循环
1213  init_waitqueue_head( & start decompression )
1214  init_waitqueue_head( & decompression done )
1216  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(Deompression function that runs in its own thread., & data[thr], "image_decompress/%u", thr)
1219  如果是错误
1220  hread = NULL
1221  打印错误信息("Cannot start decompression threads\n")
1222  ret等于负ENOMEM
1223  转到:out_clean
1230  init_waitqueue_head( & start crc update )
1231  init_waitqueue_head( & crc update done )
1233  crc32等于0
1234  points to handle's crc32 等于crc32
1235 thr小于nr_threads循环
1236  uncompressed data [thr]等于unc
1237  uncompressed lengths [thr]等于uncompressed length
1240  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")
1241  如果是错误
1242  hread = NULL
1243  打印错误信息("Cannot start CRC32 thread\n")
1244  ret等于负ENOMEM
1245  转到:out_clean
1255  如果Number of free pages that are not high.大于snapshot_get_image_size()则read_pages等于Number of free pages that are not high.snapshot_get_image_size()的差除2
1257  read_pages等于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(read_pages, Minimum/maximum number of pages for read buffering. , LZO_MAX_RD_PAGES)
1259 i小于read_pages循环
1260  page[i]等于__get_free_page(i < Number of pages/bytes we need for compressed data (worst case). ? GFP_NOIO | __GFP_HIGH : GFP_NOIO | DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success. | __GFP_NORETRY)
1265  如果非page[i]则
1267  ring_size等于i
1268  打印错误信息("Failed to allocate LZO pages\n")
1269  ret等于负ENOMEM
1270  转到:out_clean
1271  否则
1272  退出
1276  want等于ring_size等于i
1278  打印信息("Using %u thread(s) for decompression\n", nr_threads)
1279  打印信息("Loading and decompressing image data (%u pages)...\n", nr_to_read)
1281  m等于nr_to_read除10
1282  如果非mm等于1
1284  nr_pages等于0
1285  start等于ktime_get()
1287  ret等于snapshot_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
1288  如果ret小于等于0则转到:out_finish
1291  循环
1292  以非eofi小于want循环
1293  ret等于swap_read_page(handle, page[ring], & hb)
1294  如果ret
1299  如果curentries[k]则
1301  转到:out_finish
1302  否则
1303  eof等于1
1304  退出
1307  如果ring先自加大于等于ring_sizering等于0
1310  asked加等于i
1311  want减等于i
1316  如果非have
1317  如果非asked退出
1320  ret等于hib_wait_io( & hb)
1321  如果ret则转到:out_finish
1323  have加等于asked
1324  asked等于0
1325  如果eofeof等于2
1329  如果r current threads
1332  r current threads 等于0
1335 havethr小于nr_threads循环
1336  compressed length 等于page[pg]
1340  打印错误信息("Invalid LZO compressed length\n")
1341  ret等于负1
1342  转到:out_finish
1347  如果need大于have
1348  如果eof大于1则
1349  ret等于负1
1350  转到:out_finish
1352  退出
1360  have自减
1361  want自加
1362  如果pg先自加大于等于ring_sizepg等于0
1374  ret等于hib_wait_io( & hb)
1375  如果ret则转到:out_finish
1377  have加等于asked
1378  asked等于0
1379  如果eofeof等于2
1383 thr小于run_threads循环
1388  ret等于urn code
1390  如果ret小于0则
1391  打印错误信息("LZO decompression failed\n")
1392  转到:out_finish
1398  打印错误信息("Invalid LZO uncompressed length\n")
1399  ret等于负1
1400  转到:out_finish
1423  r current threads 等于thr
1424  atomic_set( & ady to start flag , 1)
1425  wake_up( & start crc update )
1428  out_finish :
1429  如果r current threads
1430  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 ))
1431  atomic_set( & ady to stop flag , 0)
1433  stop等于ktime_get()
1434  如果非ret
1435  打印信息("Image loading done\n")
1436  snapshot_write_finalize - Complete the loading of a hibernation image.* Must be called after the last call to snapshot_write_next() in case the last* page in the image happens to be a highmem page and its contents should be* stored in highmem
1437  如果非snapshot_image_loaded(snapshot)则ret等于负ENODATA
1439  如果非ret
1441  如果crc32不等于crc32
1442  打印错误信息("Invalid image CRC32!\n")
1443  ret等于负ENODATA
1448  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.
1449  out_clean :
1450 i小于ring_size循环free_page((unsignedlong)page[i])
1452  如果crc
1453  如果hread 结束线程的运行
1455  释放内存
1457  如果data
1458 thr小于nr_threads循环如果hread
1460  结束线程的运行
1461  vfree(data)
1463  vfree(page)
1465  返回:ret
调用者
名称描述
swsusp_readswsusp_read - read the hibernation image.*@flags_p: flags passed by the "frozen" kernel in the image header should* be written into this memory location