函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\memcontrol.c Create Date:2022-07-27 17:46:29
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:__mem_cgroup_usage_register_event

函数原型:static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg, struct eventfd_ctx *eventfd, const char *args, enum res_type type)

返回类型:int

参数:

类型参数名称
struct mem_cgroup *memcg
struct eventfd_ctx *eventfd
const char *args
enum res_typetype
3940  ret等于page_counter_memparse - memparse() for page counter limits*@buf: string to parse*@max: string meaning maximum possible value*@nr_pages: returns the result in number of pages* Returns -EINVAL, or 0 and @nr_pages on success. @nr_pages will be
3941  如果ret则返回:ret
3944  mutex_lock( & protect arrays of thresholds )
3946  如果type恒等于_MEM
3947  thresholds等于 thresholds for memory usage. RCU-protected
3948  usage等于mem_cgroup_usage(memcg, false)
3949  否则如果type恒等于_MEMSWAP
3950  thresholds等于 thresholds for mem+swap usage. RCU-protected
3951  usage等于mem_cgroup_usage(memcg, true)
3952  否则BUG()
3956  如果 Primary thresholds array __mem_cgroup_threshold(memcg, type == _MEMSWAP)
3959  size等于如果 Primary thresholds array Size of entries[] 加1否则1
3962  new等于kmalloc(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(new, entries, size), GFP_KERNEL)
3963  如果非new
3964  ret等于负ENOMEM
3965  转到:unlock
3967  Size of entries[] 等于size
3970  如果 Primary thresholds array
3971  memcpy(Array of thresholds , Array of thresholds , (size - 1) * sizeof(structmem_cgroup_threshold))
3976  eventfd等于eventfd
3977  threshold等于threshold
3980  sort(Array of thresholds , size, sizeof(structmem_cgroup_threshold), compare_thresholds, NULL)
3984  An array index points to threshold just below or equal to usage. 等于负1
3985 i小于size循环
3986  如果threshold小于等于usage
3993  否则退出
3998  释放内存
3999  * Spare threshold array. * This is needed to make mem_cgroup_unregister_event() "never fail". * It must be able to store at least primary->size - 1 entries.等于 Primary thresholds array
4001  cu_assign_pointer() - assign to RCU-protected pointer*@p: pointer to assign to*@v: value to assign (publish)* Assigns the specified value to the specified RCU-protected* pointer, ensuring that any concurrent RCU readers will see* any prior initialization( Primary thresholds array , new)
4004  Wait for a grace period to elapse. But it is illegal to invoke* synchronize_rcu() from within an RCU read-side critical section.* Therefore, any legal call to synchronize_rcu() is a quiescent
4006  unlock :
4007  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.
4009  返回:ret
调用者
名称描述
mem_cgroup_usage_register_event
memsw_cgroup_usage_register_event