Skip to content

Commit f6602a9

Browse files
committed
Merge tag 'rcu-urgent.2022.10.20a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu
Pull RCU fix from Paul McKenney: "Fix a regression caused by commit bf95b2b ("rcu: Switch polled grace-period APIs to ->gp_seq_polled"), which could incorrectly leave interrupts enabled after an early-boot call to synchronize_rcu(). Such synchronize_rcu() calls must acquire leaf rcu_node locks in order to properly interact with polled grace periods, but the code did not take into account the possibility of synchronize_rcu() being invoked from the portion of the boot sequence during which interrupts are disabled. This commit therefore switches the lock acquisition and release from irq to irqsave/irqrestore" * tag 'rcu-urgent.2022.10.20a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu: rcu: Keep synchronize_rcu() from enabling irqs in early boot
2 parents 2a91e89 + 31d8aaa commit f6602a9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kernel/rcu/tree.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,30 +1403,32 @@ static void rcu_poll_gp_seq_end(unsigned long *snap)
14031403
// where caller does not hold the root rcu_node structure's lock.
14041404
static void rcu_poll_gp_seq_start_unlocked(unsigned long *snap)
14051405
{
1406+
unsigned long flags;
14061407
struct rcu_node *rnp = rcu_get_root();
14071408

14081409
if (rcu_init_invoked()) {
14091410
lockdep_assert_irqs_enabled();
1410-
raw_spin_lock_irq_rcu_node(rnp);
1411+
raw_spin_lock_irqsave_rcu_node(rnp, flags);
14111412
}
14121413
rcu_poll_gp_seq_start(snap);
14131414
if (rcu_init_invoked())
1414-
raw_spin_unlock_irq_rcu_node(rnp);
1415+
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
14151416
}
14161417

14171418
// Make the polled API aware of the end of a grace period, but where
14181419
// caller does not hold the root rcu_node structure's lock.
14191420
static void rcu_poll_gp_seq_end_unlocked(unsigned long *snap)
14201421
{
1422+
unsigned long flags;
14211423
struct rcu_node *rnp = rcu_get_root();
14221424

14231425
if (rcu_init_invoked()) {
14241426
lockdep_assert_irqs_enabled();
1425-
raw_spin_lock_irq_rcu_node(rnp);
1427+
raw_spin_lock_irqsave_rcu_node(rnp, flags);
14261428
}
14271429
rcu_poll_gp_seq_end(snap);
14281430
if (rcu_init_invoked())
1429-
raw_spin_unlock_irq_rcu_node(rnp);
1431+
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
14301432
}
14311433

14321434
/*

0 commit comments

Comments
 (0)