From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Paul Menage <menage@google.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"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 1.5/4] cgroup: delay populate css id
Date: Tue, 20 Jan 2009 14:43:37 +0900 [thread overview]
Message-ID: <20090120144337.82ed51d5.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090120115832.0881506c.kamezawa.hiroyu@jp.fujitsu.com>
On Tue, 20 Jan 2009 11:58:32 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > + if (ss->use_id)
> > + if (alloc_css_id(ss, parent, cgrp))
> > + goto err_destroy;
> > + /* At error, ->destroy() callback has to free assigned ID. */
> > }
>
> Should I delay to set css_id->css pointer to valid value until the end of
> populate() ? (add populage_css_id() call after cgroup_populate_dir()).
>
> I'd like to write add-on patch to the patch [1/4]. (or update it.)
> css_id->css == NULL case is handled now, anyway.
>
How about this ?
==
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
When CSS ID is attached, it's not guaranteed that the cgroup will
be finally populated out. (some failure in create())
But, scan by CSS ID can find CSS which is not fully initialized.
This patch tries to prevent that by delaying to fill id->css pointer.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
kernel/cgroup.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
Index: mmotm-2.6.29-Jan16/kernel/cgroup.c
===================================================================
--- mmotm-2.6.29-Jan16.orig/kernel/cgroup.c
+++ mmotm-2.6.29-Jan16/kernel/cgroup.c
@@ -569,6 +569,7 @@ static struct backing_dev_info cgroup_ba
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
};
+static void populate_css_id(struct cgroup_subsys_state *id);
static int alloc_css_id(struct cgroup_subsys *ss,
struct cgroup *parent, struct cgroup *child);
@@ -2329,6 +2330,12 @@ static int cgroup_populate_dir(struct cg
if (ss->populate && (err = ss->populate(ss, cgrp)) < 0)
return err;
}
+ /* This cgroup is ready now */
+ for_each_subsys(cgrp->root, ss) {
+ struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
+ if (ss->use_id)
+ populate_css_id(css);
+ }
return 0;
}
@@ -3252,8 +3259,9 @@ __setup("cgroup_disable=", cgroup_disabl
*/
struct css_id {
/*
- * The css to which this ID points. If cgroup is removed, this will
- * be NULL. This pointer is expected to be RCU-safe because destroy()
+ * The css to which this ID points. This pointer is set to valid value
+ * after cgroup is populated. If cgroup is removed, this will be NULL.
+ * This pointer is expected to be RCU-safe because destroy()
* is called after synchronize_rcu(). But for safe use, css_is_removed()
* css_tryget() should be used for avoiding race.
*/
@@ -3401,6 +3409,13 @@ static int __init cgroup_subsys_init_idr
return 0;
}
+static void populate_css_id(struct cgroup_subsys_state *css)
+{
+ struct css_id *id = rcu_dereference(css->id);
+ if (id)
+ rcu_assign_pointer(id->css, css);
+}
+
static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent,
struct cgroup *child)
{
@@ -3421,8 +3436,7 @@ static int alloc_css_id(struct cgroup_su
for (i = 0; i < depth; i++)
child_id->stack[i] = parent_id->stack[i];
child_id->stack[depth] = child_id->id;
-
- rcu_assign_pointer(child_id->css, child_css);
+ /* child_id->css pointer will be set after this cgroup is available */
rcu_assign_pointer(child_css->id, child_id);
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>
next prev parent reply other threads:[~2009-01-20 5:44 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 ` [PATCH 2/4] cgroup:add css_is_populated KAMEZAWA Hiroyuki
2009-01-16 3:00 ` 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 ` KAMEZAWA Hiroyuki [this message]
2009-01-21 9:36 ` [PATCH 1.5/4] cgroup: delay populate css id 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=20090120144337.82ed51d5.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