From: Gerrit Huizenga Handle the CKRM initialization only if the Taskclass classtype is built and set the initial class of the init process. Signed-Off-By: Matt Helsley Signed-Off-By: Gerrit Huizenga Signed-off-by: Andrew Morton --- kernel/ckrm/ckrm.c | 5 +++-- kernel/ckrm/ckrm_tc.c | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff -puN kernel/ckrm/ckrm.c~ckrm-cleanups-to-ckrm-initialization kernel/ckrm/ckrm.c --- 25/kernel/ckrm/ckrm.c~ckrm-cleanups-to-ckrm-initialization Wed Jul 13 14:44:39 2005 +++ 25-akpm/kernel/ckrm/ckrm.c Wed Jul 13 14:44:39 2005 @@ -845,7 +845,10 @@ void __init ckrm_init(void) #ifdef CONFIG_CKRM_TYPE_TASKCLASS { extern void ckrm_meta_init_taskclass(void); + ckrm_cb_newtask(&init_task); ckrm_meta_init_taskclass(); + /* prepare init_task and then rely on inheritance + of properties */ } #endif #ifdef CONFIG_CKRM_TYPE_SOCKETCLASS @@ -854,8 +857,6 @@ void __init ckrm_init(void) ckrm_meta_init_sockclass(); } #endif - /* prepare init_task and then rely on inheritance of properties */ - ckrm_cb_newtask(&init_task); printk("CKRM Initialization done\n"); } diff -puN kernel/ckrm/ckrm_tc.c~ckrm-cleanups-to-ckrm-initialization kernel/ckrm/ckrm_tc.c --- 25/kernel/ckrm/ckrm_tc.c~ckrm-cleanups-to-ckrm-initialization Wed Jul 13 14:44:39 2005 +++ 25-akpm/kernel/ckrm/ckrm_tc.c Wed Jul 13 14:44:39 2005 @@ -35,6 +35,8 @@ #include +#define TASK_EXIT_CLASS ((void*)-1) + static struct ckrm_task_class taskclass_dflt_class = { }; @@ -112,14 +114,15 @@ ckrm_set_taskclass(struct task_struct *t spin_lock(&tsk->ckrm_tsklock); curcls = tsk->taskclass; - if ((void *)-1 == curcls) { + if (TASK_EXIT_CLASS == curcls) { /* task is disassociated from ckrm. Don't bother it. */ spin_unlock(&tsk->ckrm_tsklock); - ckrm_core_drop(class_core(newcls)); + if (newcls && (newcls != TASK_EXIT_CLASS)) + ckrm_core_drop(class_core(newcls)); return; } - if ((curcls == NULL) && (newcls == (void *)-1)) { + if ((curcls == NULL) && (newcls == TASK_EXIT_CLASS)) { /* * Task needs to disassociated from ckrm and has no circles * just disassociate and return. @@ -130,7 +133,7 @@ ckrm_set_taskclass(struct task_struct *t } if (oldcls && (oldcls != curcls)) { spin_unlock(&tsk->ckrm_tsklock); - if (newcls) { + if (newcls && (newcls != TASK_EXIT_CLASS)) { /* compensate for previous grab */ pr_debug("(%s:%d): Race-condition caught <%s> %d\n", tsk->comm, tsk->pid, class_core(newcls)->name, @@ -140,7 +143,7 @@ ckrm_set_taskclass(struct task_struct *t return; } /* Make sure we have a real destination core. */ - if (!newcls) { + if (newcls == NULL) { newcls = &taskclass_dflt_class; ckrm_core_grab(class_core(newcls)); } @@ -160,7 +163,7 @@ ckrm_set_taskclass(struct task_struct *t INIT_LIST_HEAD(&tsk->taskclass_link); tsk->taskclass = NULL; class_unlock(class_core(curcls)); - if (newcls == (void *)-1) { + if (newcls == TASK_EXIT_CLASS) { tsk->taskclass = newcls; spin_unlock(&tsk->ckrm_tsklock); @@ -223,7 +226,7 @@ static void tc_add_resctrl(struct ckrm_c class_lock(core); list_for_each_entry(tsk, &core->objlist, taskclass_link) { if (rcbs->change_resclass) - (*rcbs->change_resclass) (tsk, (void *)-1, + (*rcbs->change_resclass) (tsk, TASK_EXIT_CLASS, core->res_class[resid]); } class_unlock(core); @@ -289,7 +292,7 @@ static void cb_taskclass_exit(void *tsk1 struct task_struct *tsk = (struct task_struct *)tsk1; CE_CLASSIFY_NORET(&ct_taskclass, CKRM_EVENT_EXIT, tsk); - ckrm_set_taskclass(tsk, (void *)-1, NULL, CKRM_EVENT_EXIT); + ckrm_set_taskclass(tsk, TASK_EXIT_CLASS, NULL, CKRM_EVENT_EXIT); } static void cb_taskclass_exec(void *filename) @@ -636,6 +639,9 @@ void __init ckrm_meta_init_taskclass(voi * note registeration of all resource controllers will be done * later dynamically as these are specified as modules */ + + /* prepare init_task and then rely on inheritance of properties */ + ckrm_set_taskclass(&init_task, NULL, NULL, CKRM_EVENT_NEWTASK); } static int tc_show_members(struct ckrm_core_class *core, struct seq_file *seq) _