aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-04-09 11:50:36 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-04-08 20:20:37 -0400
commit1c99315bb36b5d776210546d438ca928dc9b1f22 (patch)
treeaa43f3ffe76fd1aed66ed9e4a433c5f310fd7e74 /kernel/kthread.c
parent3217ab97f14c5c8f9f975ed8c40c351164b0b10e (diff)
kthread: move sched-realeted initialization from kthreadd context
kthreadd is the single thread which implements ths "create" request, move sched_setscheduler/etc from create_kthread() to kthread_create() to improve the scalability. We should be careful with sched_setscheduler(), use _nochek helper. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: Vitaliy Gusev <vgusev@openvz.org Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index c013bf000ce6..4ebaf8519abf 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -97,19 +97,10 @@ static void create_kthread(struct kthread_create_info *create)
97 97
98 /* We want our own signal handler (we take no signals by default). */ 98 /* We want our own signal handler (we take no signals by default). */
99 pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD); 99 pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
100 if (pid < 0) { 100 if (pid < 0)
101 create->result = ERR_PTR(pid); 101 create->result = ERR_PTR(pid);
102 } else { 102 else
103 struct sched_param param = { .sched_priority = 0 };
104 wait_for_completion(&create->started); 103 wait_for_completion(&create->started);
105 /*
106 * root may have changed our (kthreadd's) priority or CPU mask.
107 * The kernel thread should not inherit these properties.
108 */
109 sched_setscheduler(create->result, SCHED_NORMAL, &param);
110 set_user_nice(create->result, KTHREAD_NICE_LEVEL);
111 set_cpus_allowed_ptr(create->result, cpu_all_mask);
112 }
113 complete(&create->done); 104 complete(&create->done);
114} 105}
115 106
@@ -152,11 +143,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
152 wait_for_completion(&create.done); 143 wait_for_completion(&create.done);
153 144
154 if (!IS_ERR(create.result)) { 145 if (!IS_ERR(create.result)) {
146 struct sched_param param = { .sched_priority = 0 };
155 va_list args; 147 va_list args;
148
156 va_start(args, namefmt); 149 va_start(args, namefmt);
157 vsnprintf(create.result->comm, sizeof(create.result->comm), 150 vsnprintf(create.result->comm, sizeof(create.result->comm),
158 namefmt, args); 151 namefmt, args);
159 va_end(args); 152 va_end(args);
153 /*
154 * root may have changed our (kthreadd's) priority or CPU mask.
155 * The kernel thread should not inherit these properties.
156 */
157 sched_setscheduler_nocheck(create.result, SCHED_NORMAL, &param);
158 set_user_nice(create.result, KTHREAD_NICE_LEVEL);
159 set_cpus_allowed_ptr(create.result, cpu_all_mask);
160 } 160 }
161 return create.result; 161 return create.result;
162} 162}