sched: Exclude cond_resched() from nested sleep test

cond_resched() is a preemption point, not strictly a blocking
primitive, so exclude it from the ->state test.

In particular, preemption preserves task_struct::state.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Alex Elder <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Axel Lin <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Dave Jones <[email protected]>
Cc: Jason Baron <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
Peter Zijlstra 2014-09-24 10:18:56 +02:00 • committed by Ingo Molnar
commit 3427445afd
3 changed files with 15 additions and 6 deletions

View file

@ -7296,8 +7296,6 @@ static inline int preempt_count_equals(int preempt_offset)
void __might_sleep(const char *file, int line, int preempt_offset)
{
static unsigned long prev_jiffy; /* ratelimiting */
/*
* Blocking primitives will set (and therefore destroy) current->state,
* since we will exit with TASK_RUNNING make sure we enter with it,
@ -7311,6 +7309,14 @@ void __might_sleep(const char *file, int line, int preempt_offset)
(void *)current->task_state_change))
__set_current_state(TASK_RUNNING);
___might_sleep(file, line, preempt_offset);
}
EXPORT_SYMBOL(__might_sleep);
void ___might_sleep(const char *file, int line, int preempt_offset)
{
static unsigned long prev_jiffy; /* ratelimiting */
rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. */
if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
!is_idle_task(current)) ||
@ -7340,7 +7346,7 @@ void __might_sleep(const char *file, int line, int preempt_offset)
#endif
dump_stack();
}
EXPORT_SYMBOL(__might_sleep);
EXPORT_SYMBOL(___might_sleep);
#endif
#ifdef CONFIG_MAGIC_SYSRQ