kthread: disable preemption during complete()
authorPeter Boonstoppel <pboonstoppel@nvidia.com>
Thu, 19 Jul 2012 21:58:10 +0000 (14:58 -0700)
committerSimone Willett <swillett@nvidia.com>
Tue, 31 Jul 2012 21:58:16 +0000 (14:58 -0700)
commit3e34666ada220c17362c25e0c19d2319db449662
tree9be22a2b641eb524ef1e9064e9652932dfd5a693
parent6308fd8ea1d7291835b3b689779a5b58ac0cf47a
kthread: disable preemption during complete()

After a kthread is created it signals the requester using complete()
and enters TASK_UNINTERRUPTIBLE. However, since complete() wakes up
the requesting thread this can cause a preemption. The preemption will
not remove the task from the runqueue (for that schedule() has to be
invoked directly).

This is a problem if directly after kthread creation you try to do a
kthread_bind(), which will block in HZ steps until the thread is off
the runqueue.

This patch disables preemption during complete(), since we call
schedule() directly afterwards, so it will correctly enter
TASK_UNINTERRUPTIBLE. This speeds up kthread creation/binding during
cpu hotplug significantly.

Change-Id: I856ddd4e01ebdb198ba90f343b4a0c5933fd2b23
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
kernel/kthread.c