Commit 3427445a authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: tglx@linutronix.de
Cc: ilya.dryomov@inktank.com
Cc: umgwanakikbuti@gmail.com
Cc: oleg@redhat.com
Cc: Alex Elder <alex.elder@linaro.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Axel Lin <axel.lin@ingics.com>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20140924082242.656559952@infradead.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 8eb23b9f
...@@ -162,6 +162,7 @@ extern int _cond_resched(void); ...@@ -162,6 +162,7 @@ extern int _cond_resched(void);
#endif #endif
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
void ___might_sleep(const char *file, int line, int preempt_offset);
void __might_sleep(const char *file, int line, int preempt_offset); void __might_sleep(const char *file, int line, int preempt_offset);
/** /**
* might_sleep - annotation for functions that can sleep * might_sleep - annotation for functions that can sleep
...@@ -177,6 +178,8 @@ extern int _cond_resched(void); ...@@ -177,6 +178,8 @@ extern int _cond_resched(void);
do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
# define sched_annotate_sleep() __set_current_state(TASK_RUNNING) # define sched_annotate_sleep() __set_current_state(TASK_RUNNING)
#else #else
static inline void ___might_sleep(const char *file, int line,
int preempt_offset) { }
static inline void __might_sleep(const char *file, int line, static inline void __might_sleep(const char *file, int line,
int preempt_offset) { } int preempt_offset) { }
# define might_sleep() do { might_resched(); } while (0) # define might_sleep() do { might_resched(); } while (0)
......
...@@ -2806,7 +2806,7 @@ static inline int signal_pending_state(long state, struct task_struct *p) ...@@ -2806,7 +2806,7 @@ static inline int signal_pending_state(long state, struct task_struct *p)
extern int _cond_resched(void); extern int _cond_resched(void);
#define cond_resched() ({ \ #define cond_resched() ({ \
__might_sleep(__FILE__, __LINE__, 0); \ ___might_sleep(__FILE__, __LINE__, 0); \
_cond_resched(); \ _cond_resched(); \
}) })
...@@ -2819,14 +2819,14 @@ extern int __cond_resched_lock(spinlock_t *lock); ...@@ -2819,14 +2819,14 @@ extern int __cond_resched_lock(spinlock_t *lock);
#endif #endif
#define cond_resched_lock(lock) ({ \ #define cond_resched_lock(lock) ({ \
__might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \ ___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\
__cond_resched_lock(lock); \ __cond_resched_lock(lock); \
}) })
extern int __cond_resched_softirq(void); extern int __cond_resched_softirq(void);
#define cond_resched_softirq() ({ \ #define cond_resched_softirq() ({ \
__might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \ ___might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \
__cond_resched_softirq(); \ __cond_resched_softirq(); \
}) })
......
...@@ -7296,8 +7296,6 @@ static inline int preempt_count_equals(int preempt_offset) ...@@ -7296,8 +7296,6 @@ static inline int preempt_count_equals(int preempt_offset)
void __might_sleep(const char *file, int line, 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, * Blocking primitives will set (and therefore destroy) current->state,
* since we will exit with TASK_RUNNING make sure we enter with it, * 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) ...@@ -7311,6 +7309,14 @@ void __might_sleep(const char *file, int line, int preempt_offset)
(void *)current->task_state_change)) (void *)current->task_state_change))
__set_current_state(TASK_RUNNING); __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. */ rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. */
if ((preempt_count_equals(preempt_offset) && !irqs_disabled() && if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
!is_idle_task(current)) || !is_idle_task(current)) ||
...@@ -7340,7 +7346,7 @@ void __might_sleep(const char *file, int line, int preempt_offset) ...@@ -7340,7 +7346,7 @@ void __might_sleep(const char *file, int line, int preempt_offset)
#endif #endif
dump_stack(); dump_stack();
} }
EXPORT_SYMBOL(__might_sleep); EXPORT_SYMBOL(___might_sleep);
#endif #endif
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment