Blame view
kernel/cgroup_debug.c
2.04 KB
006cb9920
|
1 |
/* |
3116f0e3d
|
2 |
* kernel/cgroup_debug.c - Example cgroup subsystem that |
006cb9920
|
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
* exposes debug info * * Copyright (C) Google Inc, 2007 * * Developed by Paul Menage (menage@google.com) * */ #include <linux/cgroup.h> #include <linux/fs.h> #include <linux/slab.h> #include <linux/rcupdate.h> #include <asm/atomic.h> static struct cgroup_subsys_state *debug_create(struct cgroup_subsys *ss, struct cgroup *cont) { struct cgroup_subsys_state *css = kzalloc(sizeof(*css), GFP_KERNEL); if (!css) return ERR_PTR(-ENOMEM); return css; } static void debug_destroy(struct cgroup_subsys *ss, struct cgroup *cont) { kfree(cont->subsys[debug_subsys_id]); } static u64 cgroup_refcount_read(struct cgroup *cont, struct cftype *cft) { return atomic_read(&cont->count); } static u64 taskcount_read(struct cgroup *cont, struct cftype *cft) { u64 count; cgroup_lock(); count = cgroup_task_count(cont); cgroup_unlock(); return count; } static u64 current_css_set_read(struct cgroup *cont, struct cftype *cft) { return (u64)(long)current->cgroups; } static u64 current_css_set_refcount_read(struct cgroup *cont, struct cftype *cft) { u64 count; rcu_read_lock(); |
146aa1bd0
|
60 |
count = atomic_read(¤t->cgroups->refcount); |
006cb9920
|
61 62 63 |
rcu_read_unlock(); return count; } |
3116f0e3d
|
64 65 66 67 |
static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft) { return test_bit(CGRP_RELEASABLE, &cgrp->flags); } |
006cb9920
|
68 69 70 |
static struct cftype files[] = { { .name = "cgroup_refcount", |
f4c753b7e
|
71 |
.read_u64 = cgroup_refcount_read, |
006cb9920
|
72 73 74 |
}, { .name = "taskcount", |
f4c753b7e
|
75 |
.read_u64 = taskcount_read, |
006cb9920
|
76 77 78 79 |
}, { .name = "current_css_set", |
f4c753b7e
|
80 |
.read_u64 = current_css_set_read, |
006cb9920
|
81 82 83 84 |
}, { .name = "current_css_set_refcount", |
f4c753b7e
|
85 |
.read_u64 = current_css_set_refcount_read, |
006cb9920
|
86 |
}, |
3116f0e3d
|
87 88 89 90 |
{ .name = "releasable", .read_u64 = releasable_read, |
146aa1bd0
|
91 |
}, |
006cb9920
|
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
}; static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont) { return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files)); } struct cgroup_subsys debug_subsys = { .name = "debug", .create = debug_create, .destroy = debug_destroy, .populate = debug_populate, .subsys_id = debug_subsys_id, }; |