diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kthread.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c index 4ba7cccb4994..390ef119aa50 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -16,6 +16,7 @@ #include <linux/mutex.h> #include <linux/slab.h> #include <linux/freezer.h> +#include <linux/preempt.h> #include <trace/events/sched.h> static DEFINE_SPINLOCK(kthread_create_lock); @@ -88,7 +89,17 @@ static int kthread(void *_create) /* OK, tell user we're spawned, wait for stop or wakeup */ __set_current_state(TASK_UNINTERRUPTIBLE); create->result = current; + + /* + * Disable preemption so we enter TASK_UNINTERRUPTIBLE after + * complete() instead of possibly being preempted. This speeds + * up clients that do a kthread_bind() directly after + * creation. + */ + preempt_disable(); complete(&create->done); + preempt_enable_no_resched(); + schedule(); ret = -EINTR; |