mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Blum <bblum@andrew.cmu.edu>
To: Ben Blum <bblum@andrew.cmu.edu>
Cc: Vivek Goyal <vgoyal@redhat.com>, Li Zefan <lizf@cn.fujitsu.com>,
	axboe@kernel.dk, ryov@valinux.co.jp,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	menage@google.com, containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] cgroups: modular subsystems support for use_id
Date: Tue, 12 Jan 2010 18:36:30 -0500	[thread overview]
Message-ID: <20100112233630.GC5098@unix37.andrew.cmu.edu> (raw)
In-Reply-To: <20100112233453.GB5098@unix37.andrew.cmu.edu>

[-- Attachment #1: cgroups-module-use_id-support.patch --]
[-- Type: text/plain, Size: 2626 bytes --]

This patch adds support for subsys.use_id in module-loadable subsystems.

From: Ben Blum <bblum@andrew.cmu.edu>

Signed-off-by: Ben Blum <bblum@andrew.cmu.edu>
---
 kernel/cgroup.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index cc2e1f6..b4ae6ef 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -240,7 +240,8 @@ struct cg_cgroup_link {
 static struct css_set init_css_set;
 static struct cg_cgroup_link init_css_set_link;
 
-static int cgroup_subsys_init_idr(struct cgroup_subsys *ss);
+static int cgroup_init_idr(struct cgroup_subsys *ss,
+			   struct cgroup_subsys_state *css);
 
 /* css_set_lock protects the list of css_set objects, and the
  * chain of tasks off each css_set.  Nests outside task->alloc_lock
@@ -3396,6 +3397,18 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
 
 	/* our new subsystem will be attached to the dummy hierarchy. */
 	init_cgroup_css(css, ss, dummytop);
+	/* init_idr must be after init_cgroup_css because it sets css->id. */
+	if (ss->use_id) {
+		int ret = cgroup_init_idr(ss, css);
+		if (ret) {
+			dummytop->subsys[ss->subsys_id] = NULL;
+			ss->destroy(ss, dummytop);
+			subsys[i] = NULL;
+			mutex_unlock(&cgroup_mutex);
+			return ret;
+		}
+	}
+
 	/*
 	 * Now we need to entangle the css into the existing css_sets. unlike
 	 * in cgroup_init_subsys, there are now multiple css_sets, so each one
@@ -3484,7 +3497,8 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
 	/*
 	 * remove subsystem's css from the dummytop and free it - need to free
 	 * before marking as null because ss->destroy needs the cgrp->subsys
-	 * pointer to find their state.
+	 * pointer to find their state. note that this also takes care of
+	 * freeing the css_id.
 	 */
 	ss->destroy(ss, dummytop);
 	dummytop->subsys[ss->subsys_id] = NULL;
@@ -3563,7 +3577,7 @@ int __init cgroup_init(void)
 		if (!ss->early_init)
 			cgroup_init_subsys(ss);
 		if (ss->use_id)
-			cgroup_subsys_init_idr(ss);
+			cgroup_init_idr(ss, init_css_set.subsys[ss->subsys_id]);
 	}
 
 	/* Add init_css_set to the hash table */
@@ -4231,15 +4245,14 @@ err_out:
 
 }
 
-static int __init cgroup_subsys_init_idr(struct cgroup_subsys *ss)
+static int __init_or_module cgroup_init_idr(struct cgroup_subsys *ss,
+					    struct cgroup_subsys_state *rootcss)
 {
 	struct css_id *newid;
-	struct cgroup_subsys_state *rootcss;
 
 	spin_lock_init(&ss->id_lock);
 	idr_init(&ss->idr);
 
-	rootcss = init_css_set.subsys[ss->subsys_id];
 	newid = get_new_cssid(ss, 0);
 	if (IS_ERR(newid))
 		return PTR_ERR(newid);

  reply	other threads:[~2010-01-13  0:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-31  5:10 [PATCH v4 0/4] cgroups: support for module-loadable subsystems Ben Blum
2009-12-31  5:12 ` [PATCH v4 1/4] cgroups: revamp subsys array Ben Blum
2009-12-31  5:13 ` [PATCH v4 2/4] cgroups: subsystem module loading interface Ben Blum
2009-12-31  5:14 ` [PATCH v4 3/4] cgroups: subsystem module unloading Ben Blum
2009-12-31  5:15 ` [PATCH v4 4/4] cgroups: net_cls as module Ben Blum
2010-01-07  0:04 ` [PATCH v4 0/4] cgroups: support for module-loadable subsystems Andrew Morton
2010-01-07  1:26   ` Ben Blum
2010-01-07  3:07     ` KAMEZAWA Hiroyuki
2010-01-07  6:42       ` Li Zefan
2010-01-07  7:16         ` KAMEZAWA Hiroyuki
2010-01-07  7:48           ` Ben Blum
2010-01-07  7:51             ` KAMEZAWA Hiroyuki
2010-01-07  8:04               ` Ben Blum
2010-01-07  8:14         ` Ben Blum
2010-01-07  8:22           ` Ben Blum
2010-01-08  5:27         ` Ben Blum
2010-01-08  5:29           ` [RFC] [PATCH 1/2] cgroups: modular subsystems support for use_id Ben Blum
2010-01-08  5:30           ` [RFC] [PATCH 2/2] cgroups: blkio subsystem as module Ben Blum
2010-01-08 15:10             ` Vivek Goyal
2010-01-12  0:21               ` KAMEZAWA Hiroyuki
2010-01-14  9:32                 ` Balbir Singh
2010-01-14 11:42                   ` Vivek Goyal
2010-01-08 16:33             ` Vivek Goyal
2010-01-12 23:34               ` Ben Blum
2010-01-12 23:36                 ` Ben Blum [this message]
2010-01-12 23:37                 ` [PATCH v2 " Ben Blum
2010-01-14  9:15                   ` Jens Axboe
2010-01-14  9:29                     ` Li Zefan

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=20100112233630.GC5098@unix37.andrew.cmu.edu \
    --to=bblum@andrew.cmu.edu \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=containers@lists.linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.com \
    --cc=ryov@valinux.co.jp \
    --cc=vgoyal@redhat.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®