Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:DO NOT USE IN NEW FILES.* Parse input and register new cgroup event handler.* Input must be in format '<event_fd> <control_fd> <args>'.* Interpretation of args is defined by control file implementation.

Proto:static ssize_t memcg_write_event_control(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off)

Type:ssize_t

Parameter:

TypeParameterName
struct kernfs_open_file *of
char *buf
size_tnbytes
loff_toff
4504  css = of_css(of)
4505  memcg = mem_cgroup_from_css(css)
4515  buf = strstrip(buf)
4517  efd = simple_strtoul - convert a string to an unsigned long*@cp: The start of the string*@endp: A pointer to the end of the parsed string will be placed here*@base: The number base to use* This function is obsolete. Please use kstrtoul instead.
4518  If endp != ' ' Then Return -EINVAL
4520  buf = endp + 1
4522  cfd = simple_strtoul - convert a string to an unsigned long*@cp: The start of the string*@endp: A pointer to the end of the parsed string will be placed here*@base: The number base to use* This function is obsolete. Please use kstrtoul instead.
4523  If endp != ' ' && endp != '\0' Then Return -EINVAL
4525  buf = endp + 1
4527  event = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
4528  If Not event Then Return -ENOMEM
4531  memcg which the event belongs to. = memcg
4532  Initialization list head
4533  init_poll_funcptr( & All fields below needed to unregister event when* userspace closes eventfd., memcg_event_ptable_queue_proc)
4534  init_waitqueue_func_entry( & wait, Gets called on EPOLLHUP on eventfd when user closes it.* Called with wqh->lock held and interrupts disabled.)
4535  INIT_WORK( & remove, Unregister event and free resources.* Gets called from workqueue.)
4537  efile = fdget(efd)
4538  If Not file Then
4539  ret = -EBADF
4540  Go to out_kfree
4543  ventfd to signal userspace about the event. = eventfd_ctx_fileget(file)
4544  If IS_ERR(ventfd to signal userspace about the event.) Then
4545  ret = PTR_ERR(ventfd to signal userspace about the event.)
4546  Go to out_put_efile
4549  cfile = fdget(cfd)
4550  If Not file Then
4551  ret = -EBADF
4552  Go to out_put_eventfd
4557  ret = inode_permission(file_inode(file), MAY_READ)
4558  If ret < 0 Then Go to out_put_cfile
4569  name = name
4571  If Not strcmp(name, "memory.usage_in_bytes") Then
4572  register_event = mem_cgroup_usage_register_event
4573  unregister_event = mem_cgroup_usage_unregister_event
4574  Else if Not strcmp(name, "memory.oom_control") Then
4575  register_event = mem_cgroup_oom_register_event
4576  unregister_event = mem_cgroup_oom_unregister_event
4577  Else if Not strcmp(name, "memory.pressure_level") Then
4578  register_event = vmpressure_register_event() - Bind vmpressure notifications to an eventfd*@memcg: memcg that is interested in vmpressure notifications*@eventfd: eventfd context to link notifications with*@args: event arguments (pressure level threshold, optional mode)*
4579  unregister_event = vmpressure_unregister_event() - Unbind eventfd from vmpressure*@memcg: memcg handle*@eventfd: eventfd context that was used to link vmpressure with the @cg* This function does internal manipulations to detach the @eventfd from* the vmpressure
4580  Else if Not strcmp(name, "memory.memsw.usage_in_bytes") Then
4581  register_event = memsw_cgroup_usage_register_event
4582  unregister_event = memsw_cgroup_usage_unregister_event
4583  Else
4584  ret = -EINVAL
4585  Go to out_put_cfile
4593  cfile_css = ss_tryget_online_from_dir - get corresponding css from a cgroup dentry*@dentry: directory dentry of interest*@ss: subsystem of interest* If @dentry is a directory for a cgroup which has @ss enabled on it, try* to get the corresponding css and return it
4595  ret = -EINVAL
4596  If IS_ERR(cfile_css) Then Go to out_put_cfile
4598  If cfile_css != css Then
4599  ss_put - put a css reference*@css: target css* Put a reference obtained via css_get() and css_tryget_online().
4600  Go to out_put_cfile
4603  ret = register_event(memcg, ventfd to signal userspace about the event., buf)
4604  If ret Then Go to out_put_css
4607  vfs_poll(file, & All fields below needed to unregister event when* userspace closes eventfd.)
4609  spin_lock( & event_list_lock)
4610  list_add - add a new entry*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head.* This is good for implementing stacks.
4611  spin_unlock( & event_list_lock)
4613  fdput(cfile)
4614  fdput(efile)
4616  Return nbytes
4618  out_put_css :
4619  ss_put - put a css reference*@css: target css* Put a reference obtained via css_get() and css_tryget_online().
4620  out_put_cfile :
4621  fdput(cfile)
4622  out_put_eventfd :
4623  eventfd_ctx_put(ventfd to signal userspace about the event.)
4624  out_put_efile :
4625  fdput(efile)
4626  out_kfree :
4627  kfree(event)
4629  Return ret