All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] NOOP cgroup subsystem
@ 2009-01-09  5:32 KAMEZAWA Hiroyuki
  2009-01-09  6:14 ` Li Zefan
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-01-09  5:32 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org
  Cc: menage@google.com, lizf@cn.fujitsu.com, akpm@linux-foundation.org

How about this idea ? Any comments are welcome.

-Kame

==
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Add an NO OPERATION cgroup subsystem.

Cgroup itself is providing a feature to attach a task(PID) to some class.
This feature itself is very useful but "no operation" cgroup is not supported
now other than debug cgroup. (But debug cgroup should be for DEBUG. distro
may not configure it.)

Motivation: Simply classify Applications by cgroup
  When using cgroup for classifying applications, some kind of "control" or
  "account" subsys must be used. For flexible use of cgroup's nature of
  classifying applications, NOOP is useful. It can be used regardless of
  resource accounting unit or name spaces or some controls.
  IOW, NOOP cgroup allows users to tie PIDs with some nickname.

After this, application can be checked whether it's still alive or not by

	mount -t cgroup none /var/apps noop
	mkdir /var/apps/mydaemon
	echo 0 > /var/apps/mydaemon
	/etc/init.d/mydaemon start
	exit

This can be used as the same technique of "recording pid into /var/run/xxx.pid"
and not necessary to remove stale files. If mydaemon dies, tasks file will
be empty and notify_on_release handler can be used.

I myself want to use this for replacement of "ps -elf | grep" if libcgroup supports
ps under cgroup.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 include/linux/cgroup_subsys.h |    4 ++++
 init/Kconfig                  |    9 +++++++++
 kernel/Makefile               |    1 +
 kernel/cgroup_noop.c          |   34 ++++++++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+)

Index: mmotm-2.6.28-Jan8/include/linux/cgroup_subsys.h
===================================================================
--- mmotm-2.6.28-Jan8.orig/include/linux/cgroup_subsys.h
+++ mmotm-2.6.28-Jan8/include/linux/cgroup_subsys.h
@@ -59,4 +59,8 @@ SUBSYS(freezer)
 SUBSYS(net_cls)
 #endif
 
+#ifdef CONFIG_CGROUP_NOOP
+SUBSYS(noop)
+#endif
+
 /* */
Index: mmotm-2.6.28-Jan8/kernel/Makefile
===================================================================
--- mmotm-2.6.28-Jan8.orig/kernel/Makefile
+++ mmotm-2.6.28-Jan8/kernel/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_CGROUP_DEBUG) += cgroup_deb
 obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
 obj-$(CONFIG_CPUSETS) += cpuset.o
 obj-$(CONFIG_CGROUP_NS) += ns_cgroup.o
+obj-$(CONFIG_CGROUP_NOOP) += cgroup_noop.o
 obj-$(CONFIG_UTS_NS) += utsname.o
 obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
Index: mmotm-2.6.28-Jan8/kernel/cgroup_noop.c
===================================================================
--- /dev/null
+++ mmotm-2.6.28-Jan8/kernel/cgroup_noop.c
@@ -0,0 +1,34 @@
+/*
+ * kernel/cgroup_noop.c - No Operation Cgroup. Just for organizing process tree
+ */
+
+#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 *noop_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 noop_destroy(struct cgroup_subsys *ss, struct cgroup *cont)
+{
+	kfree(cont->subsys[noop_subsys_id]);
+}
+
+
+struct cgroup_subsys noop_subsys = {
+	.name = "noop",
+	.subsys_id = noop_subsys_id,
+	.create = noop_create,
+	.destroy = noop_destroy,
+};
Index: mmotm-2.6.28-Jan8/init/Kconfig
===================================================================
--- mmotm-2.6.28-Jan8.orig/init/Kconfig
+++ mmotm-2.6.28-Jan8/init/Kconfig
@@ -354,6 +354,15 @@ config CGROUP_DEBUG
 
 	  Say N if unsure
 
+config CGROUP_NOOP
+	bool "No Operation cgroup subsystem"
+	depends on CGROUPS
+	help
+	  This provides cgroup subsystem which has no special features. By
+	  this, you can classify applications freely. That is, you can
+	  classify applications regardless of accounting or control contexts
+	  of the system.
+
 config CGROUP_NS
         bool "Namespace cgroup subsystem"
         depends on CGROUPS


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2009-01-21  3:17 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-09  5:32 [RFC][PATCH] NOOP cgroup subsystem KAMEZAWA Hiroyuki
2009-01-09  6:14 ` Li Zefan
2009-01-09  6:24   ` KAMEZAWA Hiroyuki
2009-01-09  6:27     ` Paul Menage
2009-01-09  6:26 ` Paul Menage
2009-01-09  6:29   ` Li Zefan
2009-01-09  6:37     ` Paul Menage
2009-01-09  6:44       ` Li Zefan
2009-01-09  7:22         ` KAMEZAWA Hiroyuki
2009-01-09 21:15         ` Paul Menage
2009-01-09  6:32   ` KAMEZAWA Hiroyuki
2009-01-16  2:20     ` Matthew Helsley
2009-01-16  2:45       ` KAMEZAWA Hiroyuki
     [not found]         ` <20090116114502.b3bd565d.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-01-16  3:02           ` KAMEZAWA Hiroyuki
2009-01-16  3:02             ` KAMEZAWA Hiroyuki
2009-01-16  2:45       ` KAMEZAWA Hiroyuki
2009-01-20  1:52       ` Paul Menage
     [not found]         ` <6599ad830901191752o53926bdbve593301aeff7330f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-20  3:07           ` KAMEZAWA Hiroyuki
2009-01-20  3:07         ` KAMEZAWA Hiroyuki
2009-01-21  2:36           ` Matt Helsley
2009-01-21  3:16           ` Paul Menage
     [not found]           ` <20090120120728.9be81131.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-01-21  2:36             ` Matt Helsley
2009-01-21  3:16             ` Paul Menage
2009-01-20  1:52       ` Paul Menage
     [not found]     ` <20090109153219.dd8c153d.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-01-16  2:20       ` Matthew Helsley
2009-01-09  6:34 ` Daisuke Nishimura

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.