mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: nishimura@mxp.nes.nec.co.jp,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"menage@google.com" <menage@google.com>,
	"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: [RFC][PATCH] NOOP cgroup subsystem
Date: Fri, 9 Jan 2009 15:34:17 +0900	[thread overview]
Message-ID: <20090109153417.ee79e86d.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20090109143226.b79d21b4.kamezawa.hiroyu@jp.fujitsu.com>

On Fri, 9 Jan 2009 14:32:26 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> How about this idea ? Any comments are welcome.
> 
I like this :)
It would be very usefull to define a hierarchy just for grouping processes.


Thanks,
Daisuke Nishimura.

> -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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      parent reply	other threads:[~2009-01-09  6:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09  5:32 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
2009-01-16  3:02         ` KAMEZAWA Hiroyuki
2009-01-20  1:52       ` Paul Menage
2009-01-20  3:07         ` KAMEZAWA Hiroyuki
2009-01-21  2:36           ` Matt Helsley
2009-01-21  3:16           ` Paul Menage
2009-01-09  6:34 ` Daisuke Nishimura [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090109153417.ee79e86d.nishimura@mxp.nes.nec.co.jp \
    --to=nishimura@mxp.nes.nec.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®