Skip to content

Commit

Permalink
rcu: Make rcu_blocking_is_gp() stop early-boot might_sleep()
Browse files Browse the repository at this point in the history
Currently, rcu_blocking_is_gp() invokes might_sleep() even during early
boot when interrupts are disabled and before the scheduler is scheduling.
This is at best an accident waiting to happen.  Therefore, this commit
moves that might_sleep() under an rcu_scheduler_active check in order
to ensure that might_sleep() is not invoked unless sleeping might actually
happen.

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
  • Loading branch information
Zqiang authored and Paul E. McKenney committed Jan 4, 2023
1 parent 2d7f00b commit 3d1adf7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/rcu/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3333,9 +3333,10 @@ void __init kfree_rcu_scheduler_running(void)
*/
static int rcu_blocking_is_gp(void)
{
if (rcu_scheduler_active != RCU_SCHEDULER_INACTIVE)
if (rcu_scheduler_active != RCU_SCHEDULER_INACTIVE) {
might_sleep();
return false;
might_sleep(); /* Check for RCU read-side critical section. */
}
return true;
}

Expand Down

0 comments on commit 3d1adf7

Please sign in to comment.