cond_resched() fix
authorAndrew Morton <akpm@osdl.org>
Sat, 29 Jul 2006 02:52:09 +0000 (22:52 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 7 Aug 2006 03:52:16 +0000 (20:52 -0700)
commitfed0a6b6fb78cd432863f29e83a458c9fd13a308
tree7347e3962c19f346cbb9f8ca7190fc51ec1a5eb8
parentaccdd0e1f5080ec98f7bf87c5a8b255539e1ab4b
cond_resched() fix

Fix a bug identified by Zou Nan hai <nanhai.zou@intel.com>:

If the system is in state SYSTEM_BOOTING, and need_resched() is true,
cond_resched() returns true even though it didn't reschedule.  Consequently
need_resched() remains true and JBD locks up.

Fix that by teaching cond_resched() to only return true if it really did call
schedule().

cond_resched_lock() and cond_resched_softirq() have a problem too.  If we're
in SYSTEM_BOOTING state and need_resched() is true, these functions will drop
the lock and will then try to call schedule(), but the SYSTEM_BOOTING state
will prevent schedule() from being called.  So on return, need_resched() will
still be true, but cond_resched_lock() has to return 1 to tell the caller that
the lock was dropped.  The caller will probably lock up.

Bottom line: if these functions dropped the lock, they _must_ call schedule()
to clear need_resched().   Make it so.

Also, uninline __cond_resched().  It's largeish, and slowpath.

Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/sched.c