Merge tag 'x86-timers-2020-03-30' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / kernel / kthread.c
index b262f47..bfbfa48 100644 (file)
@@ -199,8 +199,15 @@ static void __kthread_parkme(struct kthread *self)
                if (!test_bit(KTHREAD_SHOULD_PARK, &self->flags))
                        break;
 
+               /*
+                * Thread is going to call schedule(), do not preempt it,
+                * or the caller of kthread_park() may spend more time in
+                * wait_task_inactive().
+                */
+               preempt_disable();
                complete(&self->parked);
-               schedule();
+               schedule_preempt_disabled();
+               preempt_enable();
        }
        __set_current_state(TASK_RUNNING);
 }
@@ -245,8 +252,14 @@ static int kthread(void *_create)
        /* OK, tell user we're spawned, wait for stop or wakeup */
        __set_current_state(TASK_UNINTERRUPTIBLE);
        create->result = current;
+       /*
+        * Thread is going to call schedule(), do not preempt it,
+        * or the creator may spend more time in wait_task_inactive().
+        */
+       preempt_disable();
        complete(done);
-       schedule();
+       schedule_preempt_disabled();
+       preempt_enable();
 
        ret = -EINTR;
        if (!test_bit(KTHREAD_SHOULD_STOP, &self->flags)) {