-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task Control Groups: simple task cgroup debug info subsystem
This example subsystem exports debugging information as an aid to diagnosing refcount leaks, etc, in the cgroup framework. Signed-off-by: Paul Menage <menage@google.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information
Paul Menage
authored and
Linus Torvalds
committed
Oct 19, 2007
1 parent
62d0df6
commit 006cb99
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,8 @@ SUBSYS(cpuacct) | |
|
||
/* */ | ||
|
||
#ifdef CONFIG_CGROUP_DEBUG | ||
SUBSYS(debug) | ||
#endif | ||
|
||
/* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* kernel/ccontainer_debug.c - Example cgroup subsystem that | ||
* 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(); | ||
count = atomic_read(¤t->cgroups->ref.refcount); | ||
rcu_read_unlock(); | ||
return count; | ||
} | ||
|
||
static struct cftype files[] = { | ||
{ | ||
.name = "cgroup_refcount", | ||
.read_uint = cgroup_refcount_read, | ||
}, | ||
{ | ||
.name = "taskcount", | ||
.read_uint = taskcount_read, | ||
}, | ||
|
||
{ | ||
.name = "current_css_set", | ||
.read_uint = current_css_set_read, | ||
}, | ||
|
||
{ | ||
.name = "current_css_set_refcount", | ||
.read_uint = current_css_set_refcount_read, | ||
}, | ||
}; | ||
|
||
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, | ||
}; |