diff options
-rw-r--r-- | include/linux/cgroup.h | 15 | ||||
-rw-r--r-- | kernel/cgroup.c | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index c2515851c1aa..d60904b9e505 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -473,6 +473,7 @@ struct cftype { | |||
473 | }; | 473 | }; |
474 | 474 | ||
475 | extern struct cgroup_root cgrp_dfl_root; | 475 | extern struct cgroup_root cgrp_dfl_root; |
476 | extern struct css_set init_css_set; | ||
476 | 477 | ||
477 | static inline bool cgroup_on_dfl(const struct cgroup *cgrp) | 478 | static inline bool cgroup_on_dfl(const struct cgroup *cgrp) |
478 | { | 479 | { |
@@ -700,6 +701,20 @@ static inline struct cgroup_subsys_state *task_css(struct task_struct *task, | |||
700 | return task_css_check(task, subsys_id, false); | 701 | return task_css_check(task, subsys_id, false); |
701 | } | 702 | } |
702 | 703 | ||
704 | /** | ||
705 | * task_css_is_root - test whether a task belongs to the root css | ||
706 | * @task: the target task | ||
707 | * @subsys_id: the target subsystem ID | ||
708 | * | ||
709 | * Test whether @task belongs to the root css on the specified subsystem. | ||
710 | * May be invoked in any context. | ||
711 | */ | ||
712 | static inline bool task_css_is_root(struct task_struct *task, int subsys_id) | ||
713 | { | ||
714 | return task_css_check(task, subsys_id, true) == | ||
715 | init_css_set.subsys[subsys_id]; | ||
716 | } | ||
717 | |||
703 | static inline struct cgroup *task_cgroup(struct task_struct *task, | 718 | static inline struct cgroup *task_cgroup(struct task_struct *task, |
704 | int subsys_id) | 719 | int subsys_id) |
705 | { | 720 | { |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 11a03d67635a..3f1ca934a237 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -348,7 +348,7 @@ struct cgrp_cset_link { | |||
348 | * reference-counted, to improve performance when child cgroups | 348 | * reference-counted, to improve performance when child cgroups |
349 | * haven't been created. | 349 | * haven't been created. |
350 | */ | 350 | */ |
351 | static struct css_set init_css_set = { | 351 | struct css_set init_css_set = { |
352 | .refcount = ATOMIC_INIT(1), | 352 | .refcount = ATOMIC_INIT(1), |
353 | .cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links), | 353 | .cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links), |
354 | .tasks = LIST_HEAD_INIT(init_css_set.tasks), | 354 | .tasks = LIST_HEAD_INIT(init_css_set.tasks), |