kthread: disable preemption during complete()
authorPeter Boonstoppel <pboonstoppel@nvidia.com>
Thu, 19 Jul 2012 21:58:10 +0000 (14:58 -0700)
committerVarun Wadekar <vwadekar@nvidia.com>
Mon, 6 Aug 2012 09:25:30 +0000 (14:25 +0530)
commit68c9de8e17b859108cda331bfb1c86952b2db742
tree2979cbd0acfc3aa3fe2a2a209556a49295541d90
parent9fe16af79d90224d78a43dbbc558f514e706b1d4
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