Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:19:24
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:alloc_swap_info

Proto:static struct swap_info_struct *alloc_swap_info(void)

Type:struct swap_info_struct

Parameter:Nothing

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  If Not p Then Return ERR_PTR( - ENOMEM)
2834  spin_lock( & swap_lock)
2835  When type < nr_swapfiles cycle
2836  If Not (SWP_USED etc: see above & SWP_USED) Then Break
2839  If type >= MAX_SWAPFILES Then
2840  spin_unlock( & swap_lock)
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  Return ERR_PTR( - EPERM)
2844  If type >= nr_swapfiles Then
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  Else
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  plist_node_init - Dynamic struct plist_node initializer*@node: &struct plist_node pointer*@prio: initial node priority
2864  for_each_node(i)
2865  plist_node_init - Dynamic struct plist_node initializer*@node: &struct plist_node pointer*@prio: initial node priority
2866  SWP_USED etc: see above = SWP_USED
2867  spin_unlock( & swap_lock)
2868  Process spin lock initialization( & 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  Process spin lock initialization( & protect swap count continuation page* list.)
2871  Return p
Caller
NameDescribe
SYSCALL_DEFINE2