aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-09-24 04:18:55 -0400
committerIngo Molnar <mingo@kernel.org>2014-10-28 05:56:52 -0400
commit8eb23b9f35aae413140d3fda766a98092c21e9b0 (patch)
tree657a91ed72882475ada772da052a8a332d70a2dc /kernel/sched/core.c
parent26cabd31259ba43f68026ce3f62b78094124333f (diff)
sched: Debug nested sleeps
Validate we call might_sleep() with TASK_RUNNING, which catches places where we nest blocking primitives, eg. mutex usage in a wait loop. Since all blocking is arranged through task_struct::state, nesting this will cause the inner primitive to set TASK_RUNNING and the outer will thus not block. Another observed problem is calling a blocking function from schedule()->sched_submit_work()->blk_schedule_flush_plug() which will then destroy the task state for the actual __schedule() call that comes after it. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: tglx@linutronix.de Cc: ilya.dryomov@inktank.com Cc: umgwanakikbuti@gmail.com Cc: oleg@redhat.com Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20140924082242.591637616@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0456a55fc27f..5b4b96b27cd7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7298,6 +7298,19 @@ void __might_sleep(const char *file, int line, int preempt_offset)
7298{ 7298{
7299 static unsigned long prev_jiffy; /* ratelimiting */ 7299 static unsigned long prev_jiffy; /* ratelimiting */
7300 7300
7301 /*
7302 * Blocking primitives will set (and therefore destroy) current->state,
7303 * since we will exit with TASK_RUNNING make sure we enter with it,
7304 * otherwise we will destroy state.
7305 */
7306 if (WARN(current->state != TASK_RUNNING,
7307 "do not call blocking ops when !TASK_RUNNING; "
7308 "state=%lx set at [<%p>] %pS\n",
7309 current->state,
7310 (void *)current->task_state_change,
7311 (void *)current->task_state_change))
7312 __set_current_state(TASK_RUNNING);
7313
7301 rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. */ 7314 rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. */
7302 if ((preempt_count_equals(preempt_offset) && !irqs_disabled() && 7315 if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
7303 !is_idle_task(current)) || 7316 !is_idle_task(current)) ||