Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.24 /kernel/cgroup_debug.c

Filename:/kernel/cgroup_debug.c
Lines Added:97
Lines Deleted:0
Also changed in: (Previous) 2.6.24-rc8  2.6.24-rc7  2.6.24-rc6  2.6.24-rc5  2.6.24-rc4  2.6.24-rc3 
(Following) 2.6.25-git14  2.6.25-git15  2.6.25-git16  2.6.25-git17  2.6.25-git18  2.6.25-git19 

Location
[  2.6.24
  [  kernel
     o  cgroup_debug.c

Patch

diff --git a/kernel/cgroup_debug.c b/kernel/cgroup_debug.c
new file mode 100644
index 0000000..37301e8
--- /dev/null
+++ b/kernel/cgroup_debug.c
@@ -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,
+};


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.