USB: cdc-acm: work around some broken devices
[linux-2.6/mini2440.git] / kernel / cgroup_debug.c
blob0c92d797baa6d163853245481597f7fc03236da4
1 /*
2 * kernel/cgroup_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 count = cgroup_task_count(cont);
44 return count;
47 static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft)
49 return (u64)(long)current->cgroups;
52 static u64 current_css_set_refcount_read(struct cgroup *cont,
53 struct cftype *cft)
55 u64 count;
57 rcu_read_lock();
58 count = atomic_read(&current->cgroups->refcount);
59 rcu_read_unlock();
60 return count;
63 static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft)
65 return test_bit(CGRP_RELEASABLE, &cgrp->flags);
68 static struct cftype files[] = {
70 .name = "cgroup_refcount",
71 .read_u64 = cgroup_refcount_read,
74 .name = "taskcount",
75 .read_u64 = taskcount_read,
79 .name = "current_css_set",
80 .read_u64 = current_css_set_read,
84 .name = "current_css_set_refcount",
85 .read_u64 = current_css_set_refcount_read,
89 .name = "releasable",
90 .read_u64 = releasable_read,
94 static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont)
96 return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files));
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,