[ARM] 4694/1: IXP4xx: Update clockevent support for shutdown and resume
[linux-ginger.git] / kernel / cgroup_debug.c
blob37301e877cb03304ea06983c2766eef696b73892
1 /*
2 * kernel/ccontainer_debug.c - Example cgroup subsystem that
3 * exposes debug info
5 * Copyright (C) Google Inc, 2007
7 * Developed by Paul Menage (menage@google.com)
9 */
11 #include <linux/cgroup.h>
12 #include <linux/fs.h>
13 #include <linux/slab.h>
14 #include <linux/rcupdate.h>
16 #include <asm/atomic.h>
18 static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss,
19 struct cgroup *cont)
21 struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL);
23 if (!css)
24 return ERR_PTR(-ENOMEM);
26 return css;
29 static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
31 kfree(cont->subsys[debug_subsys_id]);
34 static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft)
36 return atomic_read(&cont->count);
39 static u64 taskcount_read(struct cgroup *cont, struct cftype *cft)
41 u64 count;
43 cgroup_lock();
44 count = cgroup_task_count(cont);
45 cgroup_unlock();
46 return count;
49 static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
51 return (u64)(long)current->cgroups;
54 static u64 current_css_set_refcount_read(struct cgroup *cont,
55 struct cftype *cft)
57 u64 count;
59 rcu_read_lock();
60 count = atomic_read(&current->cgroups->ref.refcount);
61 rcu_read_unlock();
62 return count;
65 static struct cftype files[] = {
67 .name = "cgroup_refcount",
68 .read_uint = cgroup_refcount_read,
71 .name = "taskcount",
72 .read_uint = taskcount_read,
76 .name = "current_css_set",
77 .read_uint = current_css_set_read,
81 .name = "current_css_set_refcount",
82 .read_uint = current_css_set_refcount_read,
86 static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
88 return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
91 struct cgroup_subsys debug_subsys = {
92 .name = "debug",
93 .create = debug_create,
94 .destroy = debug_destroy,
95 .populate = debug_populate,
96 .subsys_id = debug_subsys_id,