Merge branch 'omap-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind...
[sfrench/cifs-2.6.git] / kernel / kthread.c
index 84bbadd4d0213c1558ade617ab49695df0b1bd9f..4ebaf8519abf64fb0cc4e93ef42d7ad0cf286c9f 100644 (file)
@@ -76,6 +76,7 @@ static int kthread(void *_create)
 
        /* OK, tell user we're spawned, wait for stop or wakeup */
        __set_current_state(TASK_UNINTERRUPTIBLE);
+       create->result = current;
        complete(&create->started);
        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). */
        pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
-       if (pid < 0) {
+       if (pid < 0)
                create->result = ERR_PTR(pid);
-       } else {
-               struct sched_param param = { .sched_priority = 0 };
+       else
                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, &param);
-               set_user_nice(create->result, KTHREAD_NICE_LEVEL);
-               set_cpus_allowed_ptr(create->result, cpu_all_mask);
-       }
        complete(&create->done);
 }
 
@@ -154,11 +143,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
        wait_for_completion(&create.done);
 
        if (!IS_ERR(create.result)) {
+               struct sched_param param = { .sched_priority = 0 };
                va_list args;
+
                va_start(args, namefmt);
                vsnprintf(create.result->comm, sizeof(create.result->comm),
                          namefmt, 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, &param);
+               set_user_nice(create.result, KTHREAD_NICE_LEVEL);
+               set_cpus_allowed_ptr(create.result, cpu_all_mask);
        }
        return create.result;
 }