Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swap_slots.c Create Date:2022-07-28 15:20:50
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:alloc_swap_slot_cache

Proto:static int alloc_swap_slot_cache(unsigned int cpu)

Type:int

Parameter:

TypeParameterName
unsigned intcpu
125  slots = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t), GFP_KERNEL)
127  If Not slots Then Return -ENOMEM
130  slots_ret = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t), GFP_KERNEL)
132  If Not slots_ret Then
133  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.
134  Return -ENOMEM
137  mutex_lock( & swap_slots_cache_mutex)
138  cache = per_cpu(swp_slots, cpu)
139  If slots || slots_ret Then Go to out
142  If Not lock_initialized Then
143  mutex_init - initialize the mutex*@mutex: the mutex to be initialized* Initialize the mutex to unlocked state.* It is not allowed to initialize an already locked mutex.( & protects slots, nr, cur )
144  Process spin lock initialization( & protects slots_ret, n_ret )
145  lock_initialized = true
147  nr = 0
148  cur = 0
149  n_ret = 0
156  Force strict CPU ordering.* And yes, this might be required on UP too when we're talking* to devices.()
157  slots = slots
158  slots = NULL
159  slots_ret = slots_ret
160  slots_ret = NULL
161  out :
162  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
163  If slots Then 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.
165  If slots_ret Then 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.
167  Return 0