函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-27 16:47:27
Last Modify:2020-03-17 22:19:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:scan_swap_map_slots

函数原型:static int scan_swap_map_slots(struct swap_info_struct *si, unsigned char usage, int nr, swp_entry_t slots[])

返回类型:int

参数:

类型参数名称
struct swap_info_struct *si
unsigned charusage
intnr
swp_entry_tslots
739  last_in_cluster等于0
740  latency_ration等于LATENCY_LIMIT
741  n_ret等于0
743  如果nr大于SWAP_BATCHnr等于SWAP_BATCH
757  SWP_USED etc: see above 加等于SWP_SCANNING
758  scan_base等于offset等于likely index for next allocation
761  如果cluster info. Only for SSD
762  如果Try to get a swap entry from current cpu's swap entry pool (a cluster). This* might involve allocating a new cluster for current CPU too.则转到:checks
764  否则转到:scan
768  如果此条件成立可能性小(为编译器优化)(!countdown to next cluster search --)则
771  转到:checks
774  自旋锁解锁
782  scan_base等于offset等于dex of first free in swap_map
783  last_in_cluster等于offsetSWAPFILE_CLUSTER减1
789  否则如果offset恒等于last_in_cluster
802  offset等于scan_base
803  加自旋锁
804  countdown to next cluster search 等于SWAPFILE_CLUSTER减1
807  checks :
808  如果cluster info. Only for SSD
811  如果n_ret则转到:done
818  如果非SWP_USED etc: see above 按位与SWP_WRITEOK的值则转到:no_page
820  如果非dex of last free in swap_map 则转到:no_page
822  如果offset大于dex of last free in swap_map scan_base等于offset等于dex of first free in swap_map
825  ci等于lock_cluster(si, offset)
827  如果vm_swap_full()且vmalloc'ed array of usage counts [offset]恒等于Flag page is cached, in first swap_map
829  unlock_cluster(ci)
830  自旋锁解锁
831  swap_was_freed等于rns 1 if swap entry is freed
832  加自旋锁
834  如果swap_was_freed则转到:checks
836  转到:scan
839  如果vmalloc'ed array of usage counts [offset]则
840  unlock_cluster(ci)
841  如果非n_ret则转到:scan
843  否则转到:done
846  vmalloc'ed array of usage counts [offset]等于usage
847  The cluster corresponding to page_nr will be used. The cluster will be* removed from free cluster list and its usage counter will be increased.
848  unlock_cluster(ci)
850  swap_range_alloc(si, offset, 1)
851  likely index for next allocation 等于offset加1
852  slots[n_ret++]等于Store a type+offset into a swp_entry_t in an arch-independent format
855  如果n_ret恒等于nroffset大于等于dex of last free in swap_map 则转到:done
861  如果此条件成立可能性小(为编译器优化)(--latency_ration < 0)则
862  如果n_ret则转到:done
864  自旋锁解锁
865  cond_resched()
866  加自旋锁
867  latency_ration等于LATENCY_LIMIT
871  如果cluster info. Only for SSD
872  如果Try to get a swap entry from current cpu's swap entry pool (a cluster). This* might involve allocating a new cluster for current CPU too.则转到:checks
874  否则转到:done
878  offset先自加
881  如果countdown to next cluster search 且非vmalloc'ed array of usage counts [offset]则
882  countdown to next cluster search 先自减
883  转到:checks
886  done :
887  SWP_USED etc: see above 减等于SWP_SCANNING
888  返回:n_ret
890  scan :
891  自旋锁解锁
892 offset先自加小于等于dex of last free in swap_map 循环
894  加自旋锁
895  转到:checks
898  加自旋锁
899  转到:checks
902  cond_resched()
906  offset等于dex of first free in swap_map
907 offset小于scan_base循环
909  加自旋锁
910  转到:checks
913  加自旋锁
914  转到:checks
917  cond_resched()
920  offset自加
922  加自旋锁
924  no_page :
925  SWP_USED etc: see above 减等于SWP_SCANNING
926  返回:n_ret
调用者
名称描述
scan_swap_map
get_swap_pages