aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-09-11 15:00:19 -0400
committerTejun Heo <tj@kernel.org>2015-09-22 12:46:53 -0400
commit4530eddb59494b89650d6bcd980fc7f7717ad80c (patch)
tree0f6212afa2e7e0e4724c5f12644508f1a0baf138 /include/linux/cgroup.h
parent3df9ca0a2b8b50db5a079ae9d97c5b55435e9a6c (diff)
cgroup, memcg, cpuset: implement cgroup_taskset_for_each_leader()
It wasn't explicitly documented but, when a process is being migrated, cpuset and memcg depend on cgroup_taskset_first() returning the threadgroup leader; however, this approach is somewhat ghetto and would no longer work for the planned multi-process migration. This patch introduces explicit cgroup_taskset_for_each_leader() which iterates over only the threadgroup leaders and replaces cgroup_taskset_first() usages for accessing the leader with it. This prepares both memcg and cpuset for multi-process migration. This patch also updates the documentation for cgroup_taskset_for_each() to clarify the iteration rules and removes comments mentioning task ordering in tasksets. v2: A previous patch which added threadgroup leader test was dropped. Patch updated accordingly. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Zefan Li <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index fb717f2cba5b..e9c3eac074e2 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -232,11 +232,33 @@ void css_task_iter_end(struct css_task_iter *it);
232 * cgroup_taskset_for_each - iterate cgroup_taskset 232 * cgroup_taskset_for_each - iterate cgroup_taskset
233 * @task: the loop cursor 233 * @task: the loop cursor
234 * @tset: taskset to iterate 234 * @tset: taskset to iterate
235 *
236 * @tset may contain multiple tasks and they may belong to multiple
237 * processes. When there are multiple tasks in @tset, if a task of a
238 * process is in @tset, all tasks of the process are in @tset. Also, all
239 * are guaranteed to share the same source and destination csses.
240 *
241 * Iteration is not in any specific order.
235 */ 242 */
236#define cgroup_taskset_for_each(task, tset) \ 243#define cgroup_taskset_for_each(task, tset) \
237 for ((task) = cgroup_taskset_first((tset)); (task); \ 244 for ((task) = cgroup_taskset_first((tset)); (task); \
238 (task) = cgroup_taskset_next((tset))) 245 (task) = cgroup_taskset_next((tset)))
239 246
247/**
248 * cgroup_taskset_for_each_leader - iterate group leaders in a cgroup_taskset
249 * @leader: the loop cursor
250 * @tset: takset to iterate
251 *
252 * Iterate threadgroup leaders of @tset. For single-task migrations, @tset
253 * may not contain any.
254 */
255#define cgroup_taskset_for_each_leader(leader, tset) \
256 for ((leader) = cgroup_taskset_first((tset)); (leader); \
257 (leader) = cgroup_taskset_next((tset))) \
258 if ((leader) != (leader)->group_leader) \
259 ; \
260 else
261
240/* 262/*
241 * Inline functions. 263 * Inline functions.
242 */ 264 */