diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-04-29 04:00:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:10 -0400 |
commit | e8d55fdeb882cfcb5e8db5a5ce16edfba78aafc5 (patch) | |
tree | 0c0a7338d8adb2aaf4310eb89d1679c802ea617d /kernel/cgroup.c | |
parent | 472b1053f3c319cc60bfb2a0bb062fed77a93eb6 (diff) |
cgroups: simplify init_subsys()
We are at system boot and there is only 1 cgroup group (i,e, init_css_set), so
we don't need to run through the css_set linked list. Neither do we need to
run through the task list, since no processes have been created yet.
Also referring to a comment in cgroup.h:
struct css_set
{
...
/*
* Set of subsystem states, one for each subsystem. This array
* is immutable after creation apart from the init_css_set
* during subsystem registration (at boot time).
*/
struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
}
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Reviewed-by: Paul Menage <menage@google.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index c447c29f8749..b893c8c94858 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2477,7 +2477,6 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry) | |||
2477 | static void __init cgroup_init_subsys(struct cgroup_subsys *ss) | 2477 | static void __init cgroup_init_subsys(struct cgroup_subsys *ss) |
2478 | { | 2478 | { |
2479 | struct cgroup_subsys_state *css; | 2479 | struct cgroup_subsys_state *css; |
2480 | struct list_head *l; | ||
2481 | 2480 | ||
2482 | printk(KERN_INFO "Initializing cgroup subsys %s\n", ss->name); | 2481 | printk(KERN_INFO "Initializing cgroup subsys %s\n", ss->name); |
2483 | 2482 | ||
@@ -2488,35 +2487,19 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss) | |||
2488 | BUG_ON(IS_ERR(css)); | 2487 | BUG_ON(IS_ERR(css)); |
2489 | init_cgroup_css(css, ss, dummytop); | 2488 | init_cgroup_css(css, ss, dummytop); |
2490 | 2489 | ||
2491 | /* Update all cgroup groups to contain a subsys | 2490 | /* Update the init_css_set to contain a subsys |
2492 | * pointer to this state - since the subsystem is | 2491 | * pointer to this state - since the subsystem is |
2493 | * newly registered, all tasks and hence all cgroup | 2492 | * newly registered, all tasks and hence the |
2494 | * groups are in the subsystem's top cgroup. */ | 2493 | * init_css_set is in the subsystem's top cgroup. */ |
2495 | write_lock(&css_set_lock); | 2494 | init_css_set.subsys[ss->subsys_id] = dummytop->subsys[ss->subsys_id]; |
2496 | l = &init_css_set.list; | ||
2497 | do { | ||
2498 | struct css_set *cg = | ||
2499 | list_entry(l, struct css_set, list); | ||
2500 | cg->subsys[ss->subsys_id] = dummytop->subsys[ss->subsys_id]; | ||
2501 | l = l->next; | ||
2502 | } while (l != &init_css_set.list); | ||
2503 | write_unlock(&css_set_lock); | ||
2504 | |||
2505 | /* If this subsystem requested that it be notified with fork | ||
2506 | * events, we should send it one now for every process in the | ||
2507 | * system */ | ||
2508 | if (ss->fork) { | ||
2509 | struct task_struct *g, *p; | ||
2510 | |||
2511 | read_lock(&tasklist_lock); | ||
2512 | do_each_thread(g, p) { | ||
2513 | ss->fork(ss, p); | ||
2514 | } while_each_thread(g, p); | ||
2515 | read_unlock(&tasklist_lock); | ||
2516 | } | ||
2517 | 2495 | ||
2518 | need_forkexit_callback |= ss->fork || ss->exit; | 2496 | need_forkexit_callback |= ss->fork || ss->exit; |
2519 | 2497 | ||
2498 | /* At system boot, before all subsystems have been | ||
2499 | * registered, no tasks have been forked, so we don't | ||
2500 | * need to invoke fork callbacks here. */ | ||
2501 | BUG_ON(!list_empty(&init_task.tasks)); | ||
2502 | |||
2520 | ss->active = 1; | 2503 | ss->active = 1; |
2521 | } | 2504 | } |
2522 | 2505 | ||