|
@@ -76,6 +76,7 @@ static int kthread(void *_create)
|
|
|
|
|
|
/* OK, tell user we're spawned, wait for stop or wakeup */
|
|
/* OK, tell user we're spawned, wait for stop or wakeup */
|
|
__set_current_state(TASK_UNINTERRUPTIBLE);
|
|
__set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
|
+ create->result = current;
|
|
complete(&create->started);
|
|
complete(&create->started);
|
|
schedule();
|
|
schedule();
|
|
|
|
|
|
@@ -96,22 +97,10 @@ static void create_kthread(struct kthread_create_info *create)
|
|
|
|
|
|
/* We want our own signal handler (we take no signals by default). */
|
|
/* We want our own signal handler (we take no signals by default). */
|
|
pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
|
|
pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
|
|
- if (pid < 0) {
|
|
|
|
|
|
+ if (pid < 0)
|
|
create->result = ERR_PTR(pid);
|
|
create->result = ERR_PTR(pid);
|
|
- } else {
|
|
|
|
- struct sched_param param = { .sched_priority = 0 };
|
|
|
|
|
|
+ else
|
|
wait_for_completion(&create->started);
|
|
wait_for_completion(&create->started);
|
|
- read_lock(&tasklist_lock);
|
|
|
|
- create->result = find_task_by_pid_ns(pid, &init_pid_ns);
|
|
|
|
- read_unlock(&tasklist_lock);
|
|
|
|
- /*
|
|
|
|
- * root may have changed our (kthreadd's) priority or CPU mask.
|
|
|
|
- * The kernel thread should not inherit these properties.
|
|
|
|
- */
|
|
|
|
- sched_setscheduler(create->result, SCHED_NORMAL, ¶m);
|
|
|
|
- set_user_nice(create->result, KTHREAD_NICE_LEVEL);
|
|
|
|
- set_cpus_allowed_ptr(create->result, cpu_all_mask);
|
|
|
|
- }
|
|
|
|
complete(&create->done);
|
|
complete(&create->done);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,11 +143,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
|
|
wait_for_completion(&create.done);
|
|
wait_for_completion(&create.done);
|
|
|
|
|
|
if (!IS_ERR(create.result)) {
|
|
if (!IS_ERR(create.result)) {
|
|
|
|
+ struct sched_param param = { .sched_priority = 0 };
|
|
va_list args;
|
|
va_list args;
|
|
|
|
+
|
|
va_start(args, namefmt);
|
|
va_start(args, namefmt);
|
|
vsnprintf(create.result->comm, sizeof(create.result->comm),
|
|
vsnprintf(create.result->comm, sizeof(create.result->comm),
|
|
namefmt, args);
|
|
namefmt, args);
|
|
va_end(args);
|
|
va_end(args);
|
|
|
|
+ /*
|
|
|
|
+ * root may have changed our (kthreadd's) priority or CPU mask.
|
|
|
|
+ * The kernel thread should not inherit these properties.
|
|
|
|
+ */
|
|
|
|
+ sched_setscheduler_nocheck(create.result, SCHED_NORMAL, ¶m);
|
|
|
|
+ set_user_nice(create.result, KTHREAD_NICE_LEVEL);
|
|
|
|
+ set_cpus_allowed_ptr(create.result, cpu_all_mask);
|
|
}
|
|
}
|
|
return create.result;
|
|
return create.result;
|
|
}
|
|
}
|