diff options
author | Paul Menage <menage@google.com> | 2009-09-23 18:56:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-24 10:20:57 -0400 |
commit | fe6934354f8e287275500cd6ec73826d4d6ad457 (patch) | |
tree | f5ccab89d27472f5116257d1f7248594d3510882 /kernel/cgroup.c | |
parent | c6d57f3312a6619d47c5557b5f6154a74d04ff80 (diff) |
cgroups: move the cgroup debug subsys into cgroup.c to access internal state
While it's architecturally clean to have the cgroup debug subsystem be
completely independent of the cgroups framework, it limits its usefulness
for debugging the contents of internal data structures. Move the debug
subsystem code into the scope of all the cgroups data structures to make
more detailed debugging possible.
Signed-off-by: Paul Menage <menage@google.com>
Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 88 |
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 | ||
3785 | static 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 | |||
3796 | static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont) | ||
3797 | { | ||
3798 | kfree(cont->subsys[debug_subsys_id]); | ||
3799 | } | ||
3800 | |||
3801 | static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft) | ||
3802 | { | ||
3803 | return atomic_read(&cont->count); | ||
3804 | } | ||
3805 | |||
3806 | static u64 debug_taskcount_read(struct cgroup *cont, struct cftype *cft) | ||
3807 | { | ||
3808 | return cgroup_task_count(cont); | ||
3809 | } | ||
3810 | |||
3811 | static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft) | ||
3812 | { | ||
3813 | return (u64)(unsigned long)current->cgroups; | ||
3814 | } | ||
3815 | |||
3816 | static 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(¤t->cgroups->refcount); | ||
3823 | rcu_read_unlock(); | ||
3824 | return count; | ||
3825 | } | ||
3826 | |||
3827 | static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft) | ||
3828 | { | ||
3829 | return test_bit(CGRP_RELEASABLE, &cgrp->flags); | ||
3830 | } | ||
3831 | |||
3832 | static 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 | |||
3858 | static 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 | |||
3864 | struct 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 */ | ||