diff options
-rw-r--r-- | kernel/Makefile | 1 | ||||
-rw-r--r-- | kernel/cgroup.c | 88 | ||||
-rw-r--r-- | kernel/cgroup_debug.c | 105 |
3 files changed, 88 insertions, 106 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 187c89b4783d..b8d4cd8ac0b9 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -58,7 +58,6 @@ obj-$(CONFIG_KEXEC) += kexec.o | |||
58 | obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o | 58 | obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o |
59 | obj-$(CONFIG_COMPAT) += compat.o | 59 | obj-$(CONFIG_COMPAT) += compat.o |
60 | obj-$(CONFIG_CGROUPS) += cgroup.o | 60 | obj-$(CONFIG_CGROUPS) += cgroup.o |
61 | obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o | ||
62 | obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o | 61 | obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o |
63 | obj-$(CONFIG_CPUSETS) += cpuset.o | 62 | obj-$(CONFIG_CPUSETS) += cpuset.o |
64 | obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o | 63 | obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o |
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 */ | ||
diff --git a/kernel/cgroup_debug.c b/kernel/cgroup_debug.c deleted file mode 100644 index 0c92d797baa6..000000000000 --- a/kernel/cgroup_debug.c +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /* | ||
2 | * kernel/cgroup_debug.c - Example cgroup subsystem that | ||
3 | * exposes debug info | ||
4 | * | ||
5 | * Copyright (C) Google Inc, 2007 | ||
6 | * | ||
7 | * Developed by Paul Menage (menage@google.com) | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #include <linux/cgroup.h> | ||
12 | #include <linux/fs.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/rcupdate.h> | ||
15 | |||
16 | #include <asm/atomic.h> | ||
17 | |||
18 | static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, | ||
19 | struct cgroup *cont) | ||
20 | { | ||
21 | struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); | ||
22 | |||
23 | if (!css) | ||
24 | return ERR_PTR(-ENOMEM); | ||
25 | |||
26 | return css; | ||
27 | } | ||
28 | |||
29 | static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont) | ||
30 | { | ||
31 | kfree(cont->subsys[debug_subsys_id]); | ||
32 | } | ||
33 | |||
34 | static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft) | ||
35 | { | ||
36 | return atomic_read(&cont->count); | ||
37 | } | ||
38 | |||
39 | static u64 taskcount_read(struct cgroup *cont, struct cftype *cft) | ||
40 | { | ||
41 | u64 count; | ||
42 | |||
43 | count = cgroup_task_count(cont); | ||
44 | return count; | ||
45 | } | ||
46 | |||
47 | static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft) | ||
48 | { | ||
49 | return (u64)(long)current->cgroups; | ||
50 | } | ||
51 | |||
52 | static u64 current_css_set_refcount_read(struct cgroup *cont, | ||
53 | struct cftype *cft) | ||
54 | { | ||
55 | u64 count; | ||
56 | |||
57 | rcu_read_lock(); | ||
58 | count = atomic_read(¤t->cgroups->refcount); | ||
59 | rcu_read_unlock(); | ||
60 | return count; | ||
61 | } | ||
62 | |||
63 | static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft) | ||
64 | { | ||
65 | return test_bit(CGRP_RELEASABLE, &cgrp->flags); | ||
66 | } | ||
67 | |||
68 | static struct cftype files[] = { | ||
69 | { | ||
70 | .name = "cgroup_refcount", | ||
71 | .read_u64 = cgroup_refcount_read, | ||
72 | }, | ||
73 | { | ||
74 | .name = "taskcount", | ||
75 | .read_u64 = taskcount_read, | ||
76 | }, | ||
77 | |||
78 | { | ||
79 | .name = "current_css_set", | ||
80 | .read_u64 = current_css_set_read, | ||
81 | }, | ||
82 | |||
83 | { | ||
84 | .name = "current_css_set_refcount", | ||
85 | .read_u64 = current_css_set_refcount_read, | ||
86 | }, | ||
87 | |||
88 | { | ||
89 | .name = "releasable", | ||
90 | .read_u64 = releasable_read, | ||
91 | }, | ||
92 | }; | ||
93 | |||
94 | static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont) | ||
95 | { | ||
96 | return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files)); | ||
97 | } | ||
98 | |||
99 | struct cgroup_subsys debug_subsys = { | ||
100 | .name = "debug", | ||
101 | .create = debug_create, | ||
102 | .destroy = debug_destroy, | ||
103 | .populate = debug_populate, | ||
104 | .subsys_id = debug_subsys_id, | ||
105 | }; | ||