Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Load a cgroup's pidarray with either procs' tgids or tasks' pids

Proto:static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type, struct cgroup_pidlist **lp)

Type:int

Parameter:

TypeParameterName
struct cgroup *cgrp
enum cgroup_filetypetype
struct cgroup_pidlist **lp
335  n = 0
340  lockdep_assert_held( & pidlist_mutex)
348  length = group_task_count - count the number of tasks in a cgroup.*@cgrp: the cgroup in question
349  array = kvmalloc_array(length, sizeof(pid_t), GFP_KERNEL)
350  If Not array Then Return -ENOMEM
353  ss_task_iter_start - initiate task iteration*@css: the css to walk tasks of*@flags: CSS_TASK_ITER_* flags*@it: the task iterator to use* Initiate iteration through the tasks of @css
354  When tsk = ss_task_iter_next - return the next task for the iterator*@it: the task iterator being iterated* The "next" function for task iteration. @it should have been* initialized via css_task_iter_start(). Returns NULL when the iteration* reaches the end. cycle
355  If Value for the false possibility is greater at compile time(n == length) Then Break
358  If type == CGROUP_FILE_PROCS Then pid = task_tgid_vnr(tsk)
360  Else pid = task_pid_vnr(tsk)
362  If pid > 0 Then array[n++] = pid
365  ss_task_iter_end - finish task iteration*@it: the task iterator to finish* Finish task iteration started by css_task_iter_start().
366  length = n
368  sort(array, length, sizeof(pid_t), The two pid files - task and cgroup, NULL)
369  If type == CGROUP_FILE_PROCS Then length = pidlist_uniq - given a kmalloc()ed list, strip out all duplicate entries* Returns the number of unique elements.
372  l = d the appropriate pidlist for our purpose (given procs vs tasks)* returns with the lock on that pidlist already held, and takes care* of the use count, or returns NULL with no locks held if we're out of* memory.
373  If Not l Then
374  kvfree(array)
375  Return -ENOMEM
379  kvfree(array of xids )
380  array of xids = array
381  how many elements the above list has = length
382  lp = l
383  Return 0
Caller
NameDescribe
cgroup_pidlist_startseq_file methods for the tasks/procs files. The seq_file position is the* next pid to display; the seq_file iterator is a pointer to the pid* in the cgroup->l->list array.