linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"menage@google.com" <menage@google.com>,
	"lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: [PATCH 2/4] cgroup:add css_is_populated
Date: Thu, 15 Jan 2009 19:27:12 +0900	[thread overview]
Message-ID: <20090115192712.33b533c3.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090115192120.9956911b.kamezawa.hiroyu@jp.fujitsu.com>

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

cgroup creation is done in several stages.
After allocated and linked to cgroup's hierarchy tree, all necessary
control files are created.

When using CSS_ID, scanning cgroups without cgrouo_lock(), status
of cgroup is important. At removal of cgroup/css, css_tryget() works fine
and we can write a safe code. At creation, we need some flag to show 
"This cgroup is not ready yet"

This patch adds CSS_POPULATED flag.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

---
Index: mmotm-2.6.29-Jan14/include/linux/cgroup.h
===================================================================
--- mmotm-2.6.29-Jan14.orig/include/linux/cgroup.h
+++ mmotm-2.6.29-Jan14/include/linux/cgroup.h
@@ -69,6 +69,7 @@ struct cgroup_subsys_state {
 enum {
 	CSS_ROOT, /* This CSS is the root of the subsystem */
 	CSS_REMOVED, /* This CSS is dead */
+	CSS_POPULATED, /* This CSS finished all initialization */
 };
 
 /*
@@ -90,6 +91,11 @@ static inline bool css_is_removed(struct
 	return test_bit(CSS_REMOVED, &css->flags);
 }
 
+static inline bool css_is_populated(struct cgroup_subsys_state *css)
+{
+	return test_bit(CSS_POPULATED, &css->flags);
+}
+
 /*
  * Call css_tryget() to take a reference on a css if your existing
  * (known-valid) reference isn't already ref-counted. Returns false if
Index: mmotm-2.6.29-Jan14/kernel/cgroup.c
===================================================================
--- mmotm-2.6.29-Jan14.orig/kernel/cgroup.c
+++ mmotm-2.6.29-Jan14/kernel/cgroup.c
@@ -2326,8 +2326,10 @@ static int cgroup_populate_dir(struct cg
 	}
 
 	for_each_subsys(cgrp->root, ss) {
+		struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
 		if (ss->populate && (err = ss->populate(ss, cgrp)) < 0)
 			return err;
+		set_bit(CSS_POPULATED, &css->flags);
 	}
 
 	return 0;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2009-01-15 10:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 10:21 [PATCH 0/4] cgroup/memcg : updates related to CSS KAMEZAWA Hiroyuki
2009-01-15 10:25 ` [PATCH 1/4] cgroup: add CSS ID KAMEZAWA Hiroyuki
2009-01-16  1:18   ` Li Zefan
2009-01-20  1:57   ` Paul Menage
2009-01-22  2:37   ` Daisuke Nishimura
2009-01-22  2:59     ` KAMEZAWA Hiroyuki
2009-01-15 10:27 ` KAMEZAWA Hiroyuki [this message]
2009-01-16  3:00   ` [PATCH 2/4] cgroup:add css_is_populated KAMEZAWA Hiroyuki
2009-01-20  1:41     ` Paul Menage
2009-01-20  1:51       ` Li Zefan
2009-01-20  1:55         ` Paul Menage
2009-01-20  1:39   ` Paul Menage
2009-01-20  2:02     ` KAMEZAWA Hiroyuki
2009-01-20  2:23       ` Paul Menage
2009-01-20  2:58         ` KAMEZAWA Hiroyuki
2009-01-20  5:43           ` [PATCH 1.5/4] cgroup: delay populate css id KAMEZAWA Hiroyuki
2009-01-21  9:36             ` Paul Menage
2009-01-21 10:34               ` KAMEZAWA Hiroyuki
2009-01-22  2:06                 ` KAMEZAWA Hiroyuki
2009-01-22  2:13                   ` Paul Menage
2009-01-15 10:29 ` [PATCH 3/4] memcg: hierarchical reclaim by CSS ID KAMEZAWA Hiroyuki
2009-01-16  1:29   ` Li Zefan
2009-01-16  1:38     ` KAMEZAWA Hiroyuki
2009-01-16  1:49       ` Li Zefan
2009-01-16  1:58         ` KAMEZAWA Hiroyuki
2009-01-16  2:22         ` KAMEZAWA Hiroyuki
2009-01-16  7:35           ` Li Zefan
2009-01-16  7:49             ` KAMEZAWA Hiroyuki
2009-01-15 10:32 ` [PATCH 4/4] memcg : read_statistics update to show total score KAMEZAWA Hiroyuki
2009-01-15 10:51 ` [PATCH 0/4] cgroup/memcg : updates related to CSS Balbir Singh
2009-01-15 10:58   ` KAMEZAWA Hiroyuki

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=20090115192712.33b533c3.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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