函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:alloc_swap_info

函数原型:static struct swap_info_struct *alloc_swap_info(void)

返回类型:struct swap_info_struct

参数:

2830  p等于kvzalloc(struct_size() - Calculate size of structure with trailing array.*@p: Pointer to the structure.*@member: Name of the array member.*@n: Number of elements in the array.* Calculates size of memory needed for structure @p followed by an(p, avail_lists, nr_node_ids), GFP_KERNEL)
2831  如果非p则返回:错误号
2834  加自旋锁
2835 type小于nr_swapfiles循环
2836  如果非SWP_USED etc: see above 按位与SWP_USED的值则退出
2839  如果type大于等于MAX_SWAPFILES
2840  自旋锁解锁
2841  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
2842  返回:错误号
2844  如果type大于等于nr_swapfiles
2845  strange name for an index 等于type
2846  WRITE_ONCE(swap_info[type], p)
2852  smp_wmb()
2853  WRITE_ONCE(nr_swapfiles, nr_swapfiles + 1)
2854  否则
2855  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
2856  p等于swap_info[type]
2862  of the swap extent rbtree =
2863  动态链表初始化
2864  for_each_node(i)
2865  动态链表初始化
2866  SWP_USED etc: see above 等于SWP_USED
2867  自旋锁解锁
2868  spin_lock_init( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2869  spin_lock_init( & protect swap count continuation page* list.)
2871  返回:p
调用者
名称描述
SYSCALL_DEFINE2