I'm developping a kernel module and I'd like to be able to list tasks' id from a group.
For example: I create two groups in the cpuset subsys: A and B. In B/tasks I put a PID. From my module, I'm getting a pointer to the subsys cgroup (&top_cpuset.css
for exemple) and I iterate over its children (here, A and B thanks to struct list_head children;
in the struct cgroup_subsys_state
).
What I miss is a way from children to list the tasks.
In struct cgroup
(accessible thanks to struct cgroup_subsys_state
) there is this field: struct list_head pidlists
. There is a struct cgroup_pidlists
but it looks like this structure and its functions are internals to cgroup and are not intended to be used (static functions, structure and enum defined in a .c file no .h).
Also in the struct css_set
there is this field struct list_head tasks;
. But I don't find a path from struct cgroup
or struct cgroup_subsys_state
to struct css_set
.
I have no more idea on what I can do to list the different tasks of a group. Any idea?
Edit: I'm modifying a Linux 5.7.0
Edit 2:
From struct task_struct
there is the struct nsproxy *nsproxy;
field. Which gives access to struct cgroup_namespace *cgroup_ns;
field. Which gives an access to the struct css_set *root_cset
where there is the struct list_head tasks
.
But my problem remains the same. Above the struct list_head tasks
, there is this comment "Lists running through all tasks using this cgroup group". But I don't understand how to choose the cgroup group. I mean, a task can be in different cgroup groups. How can get the struct list_head tasks
of a specific group.