diff --git a/kernel/kthread.c b/kernel/kthread.c index c5e40830c1f2..ce07480731af 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -458,6 +458,17 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data), * new kernel thread. */ if (unlikely(wait_for_completion_killable(&done))) { + int i = 0; + + /* + * I got SIGKILL, but wait for 10 more seconds for completion + * unless chosen by the OOM killer. This delay is there as a + * workaround for boot failure caused by SIGKILL upon device + * driver initialization timeout. + */ + while (i++ < 10 && !test_tsk_thread_flag(current, TIF_MEMDIE)) + if (wait_for_completion_timeout(&done, HZ)) + goto ready; /* * If I was killed by a fatal signal before kthreadd (or new * kernel thread) calls complete(), leave the cleanup of this @@ -471,6 +482,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data), */ wait_for_completion(&done); } +ready: task = create->result; free_create: kfree(create);