Skip to content

Commit

Permalink
sched: Do not account rcu_preempt_depth on RT in might_sleep()
Browse files Browse the repository at this point in the history
RT changes the rcu_preempt_depth semantics, so we cannot check for it
in might_sleep().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner authored and Sebastian Andrzej Siewior committed Sep 13, 2021
1 parent 6fff45c commit 16efe18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/linux/rcupdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void __rcu_read_unlock(void);
* types of kernel builds, the rcu_read_lock() nesting depth is unknowable.
*/
#define rcu_preempt_depth() READ_ONCE(current->rcu_read_lock_nesting)
#ifndef CONFIG_PREEMPT_RT
#define sched_rcu_preempt_depth() rcu_preempt_depth()
#else
static inline int sched_rcu_preempt_depth(void) { return 0; }
#endif

#else /* #ifdef CONFIG_PREEMPT_RCU */

Expand All @@ -79,6 +84,8 @@ static inline int rcu_preempt_depth(void)
return 0;
}

#define sched_rcu_preempt_depth() rcu_preempt_depth()

#endif /* #else #ifdef CONFIG_PREEMPT_RCU */

/* Internal to kernel */
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -9471,7 +9471,7 @@ void __init sched_init(void)
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
static inline int preempt_count_equals(int preempt_offset)
{
int nested = preempt_count() + rcu_preempt_depth();
int nested = preempt_count() + sched_rcu_preempt_depth();

return (nested == preempt_offset);
}
Expand Down

0 comments on commit 16efe18

Please sign in to comment.