aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 03204044622f..ccec722213a4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3781,3 +3781,91 @@ css_get_next(struct cgroup_subsys *ss, int id,
3781 return ret; 3781 return ret;
3782} 3782}
3783 3783
3784#ifdef CONFIG_CGROUP_DEBUG
3785static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss,
3786 struct cgroup *cont)
3787{
3788 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
3789
3790 if (!css)
3791 return ERR_PTR(-ENOMEM);
3792
3793 return css;
3794}
3795
3796static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
3797{
3798 kfree(cont->subsys[debug_subsys_id]);
3799}
3800
3801static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft)
3802{
3803 return atomic_read(&cont->count);
3804}
3805
3806static u64 debug_taskcount_read(struct cgroup *cont, struct cftype *cft)
3807{
3808 return cgroup_task_count(cont);
3809}
3810
3811static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
3812{
3813 return (u64)(unsigned long)current->cgroups;
3814}
3815
3816static u64 current_css_set_refcount_read(struct cgroup *cont,
3817 struct cftype *cft)
3818{
3819 u64 count;
3820
3821 rcu_read_lock();
3822 count = atomic_read(&current->cgroups->refcount);
3823 rcu_read_unlock();
3824 return count;
3825}
3826
3827static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft)
3828{
3829 return test_bit(CGRP_RELEASABLE, &cgrp->flags);
3830}
3831
3832static struct cftype debug_files[] = {
3833 {
3834 .name = "cgroup_refcount",
3835 .read_u64 = cgroup_refcount_read,
3836 },
3837 {
3838 .name = "taskcount",
3839 .read_u64 = debug_taskcount_read,
3840 },
3841
3842 {
3843 .name = "current_css_set",
3844 .read_u64 = current_css_set_read,
3845 },
3846
3847 {
3848 .name = "current_css_set_refcount",
3849 .read_u64 = current_css_set_refcount_read,
3850 },
3851
3852 {
3853 .name = "releasable",
3854 .read_u64 = releasable_read,
3855 },
3856};
3857
3858static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
3859{
3860 return cgroup_add_files(cont, ss, debug_files,
3861 ARRAY_SIZE(debug_files));
3862}
3863
3864struct cgroup_subsys debug_subsys = {
3865 .name = "debug",
3866 .create = debug_create,
3867 .destroy = debug_destroy,
3868 .populate = debug_populate,
3869 .subsys_id = debug_subsys_id,
3870};
3871#endif /* CONFIG_CGROUP_DEBUG */