Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__mem_cgroup_usage_register_event

Proto:static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg, struct eventfd_ctx *eventfd, const char *args, enum res_type type)

Type:int

Parameter:

TypeParameterName
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  If ret Then Return ret
3944  mutex_lock( & protect arrays of thresholds )
3946  If type == _MEM Then
3947  thresholds = thresholds for memory usage. RCU-protected
3948  usage = mem_cgroup_usage(memcg, false)
3949  Else if type == _MEMSWAP Then
3950  thresholds = thresholds for mem+swap usage. RCU-protected
3951  usage = mem_cgroup_usage(memcg, true)
3952  Else BUG()
3956  If Primary thresholds array Then __mem_cgroup_threshold(memcg, type == _MEMSWAP)
3959  size = If Primary thresholds array Then Size of entries[] + 1 Else 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  If Not new Then
3964  ret = -ENOMEM
3965  Go to unlock
3967  Size of entries[] = size
3970  If Primary thresholds array Then
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  When i < size cycle
3986  If threshold <= usage Then
3993  Else Break
3998  kfree(* 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.)
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  Return ret
Caller
NameDescribe
mem_cgroup_usage_register_event
memsw_cgroup_usage_register_event