]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - kernel/kthread.c
UBUNTU: snapcraft.yaml: install the apq8016-sbc and msm8916-mtp dtb files
[mirror_ubuntu-zesty-kernel.git] / kernel / kthread.c
index 9ff173dca1aef5e09fd640dc6757fee99c7a956c..15f24579d8faad0db5088c6008a42ce2d0ab2a89 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/freezer.h>
 #include <linux/ptrace.h>
 #include <linux/uaccess.h>
+#include <linux/cgroup.h>
 #include <trace/events/sched.h>
 
 static DEFINE_SPINLOCK(kthread_create_lock);
@@ -205,6 +206,7 @@ static int kthread(void *_create)
        ret = -EINTR;
 
        if (!test_bit(KTHREAD_SHOULD_STOP, &self.flags)) {
+               cgroup_kthread_ready();
                __kthread_parkme(&self);
                ret = threadfn(data);
        }
@@ -295,6 +297,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 SIGKILLed before kthreadd (or new kernel thread)
                 * calls complete(), leave the cleanup of this structure to
@@ -308,6 +321,7 @@ struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
                 */
                wait_for_completion(&done);
        }
+ready:
        task = create->result;
        if (!IS_ERR(task)) {
                static const struct sched_param param = { .sched_priority = 0 };
@@ -510,6 +524,7 @@ int kthreadd(void *unused)
        set_mems_allowed(node_states[N_MEMORY]);
 
        current->flags |= PF_NOFREEZE;
+       cgroup_init_kthreadd();
 
        for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);