| Function report | 
| Source Code: mm\swapfile.c | Create Date:2022-07-28 15:17:18 | 
| Last Modify:2020-03-17 22:19:49 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:get_swap_pages
Proto:int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size)
Type:int
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| int | n_goal | |
| swp_entry_t | swp_entries | |
| int | entry_size | 
| 994 | size = Define swap_entry_size() as constant to let compiler to optimize* out some code if !CONFIG_THP_SWAP(entry_size) | 
| 997 | n_ret = 0 | 
| 1001 | WARN_ON_ONCE(n_goal > 1 && size == SWAPFILE_CLUSTER) | 
| 1003 | avail_pgs = atomic_long_read( & nr_swap_pages) / size | 
| 1007 | If n_goal > SWAP_BATCH Then n_goal = SWAP_BATCH | 
| 1013 | atomic_long_sub(n_goal * size, & nr_swap_pages) | 
| 1015 | spin_lock( & swap_avail_lock) | 
| 1017 | start_over : | 
| 1022 | spin_unlock( & swap_avail_lock) | 
| 1024 | If Not dex of last free in swap_map || Not (SWP_USED etc: see above & SWP_WRITEOK) Then | 
| 1025 | spin_lock( & swap_avail_lock) | 
| 1028 | Go to nextsi | 
| 1030 | WARN(!dex of last free in swap_map , "swap_info %d in list but !highest_bit\n", strange name for an index ) | 
| 1033 | WARN(!(SWP_USED etc: see above & SWP_WRITEOK), "swap_info %d in list but !SWP_WRITEOK\n", strange name for an index ) | 
| 1036 | __del_from_avail_list(si) | 
| 1038 | Go to nextsi | 
| 1040 | If size == SWAPFILE_CLUSTER Then | 
| 1041 | If Not (SWP_USED etc: see above & SWP_FS) Then n_ret = swap_alloc_cluster(si, swp_entries) | 
| 1043 | Else n_ret = scan_swap_map_slots(si, Flag page is cached, in first swap_map , n_goal, swp_entries) | 
| 1047 | If n_ret || size == SWAPFILE_CLUSTER Then Go to check_out | 
| 1049 | pr_debug("scan_swap_map of si %d failed to find offset\n", strange name for an index ) | 
| 1052 | spin_lock( & swap_avail_lock) | 
| 1053 | nextsi : | 
| 1069 | spin_unlock( & swap_avail_lock) | 
| 1071 | check_out : | 
| 1072 | If n_ret < n_goal Then atomic_long_add((long)(n_goal - n_ret) * size, & nr_swap_pages) | 
| 1075 | noswap : | 
| 1076 | Return n_ret | 
| Name | Describe | 
|---|---|
| refill_swap_slots_cache | alled with swap slot cache's alloc lock held | 
| get_swap_page | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |