Skip to content

Commit ee4a2e0

Browse files
mrutland-armfrankjaa
authored andcommitted
entry: Add arch_in_rcu_eqs()
All architectures have an interruptible RCU extended quiescent state (EQS) as part of their idle sequences, where interrupts can occur without RCU watching. Entry code must account for this and wake RCU as necessary; the common entry code deals with this in irqentry_enter() by treating any interrupt from an idle thread as potentially having occurred within an EQS and waking RCU for the duration of the interrupt via rcu_irq_enter() .. rcu_irq_exit(). Some architectures may have other interruptible EQSs which require similar treatment. For example, on s390 it is necessary to enable interrupts around guest entry in the middle of a period where core KVM code has entered an EQS. So that architectures can wake RCU in these cases, this patch adds a new arch_in_rcu_eqs() hook to the common entry code which is checked in addition to the existing is_idle_thread() check, with RCU woken if either returns true. A default implementation is provided which always returns false, which suffices for most architectures. As no architectures currently implement arch_in_rcu_eqs(), there should be no functional change as a result of this patch alone. A subsequent patch will add an s390 implementation to fix a latent bug with missing RCU wakeups. [[email protected]: rebase, fix commit message] Signed-off-by: Mark Rutland <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Claudio Imbrenda <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Janosch Frank <[email protected]> Reviewed-by: Christian Borntraeger <[email protected]> Signed-off-by: Andrew Donnellan <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Janosch Frank <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Janosch Frank <[email protected]> Message-ID: <[email protected]>
1 parent e04c78d commit ee4a2e0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

include/linux/entry-common.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs);
8686
static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {}
8787
#endif
8888

89+
/**
90+
* arch_in_rcu_eqs - Architecture specific check for RCU extended quiescent
91+
* states.
92+
*
93+
* Returns: true if the CPU is potentially in an RCU EQS, false otherwise.
94+
*
95+
* Architectures only need to define this if threads other than the idle thread
96+
* may have an interruptible EQS. This does not need to handle idle threads. It
97+
* is safe to over-estimate at the cost of redundant RCU management work.
98+
*
99+
* Invoked from irqentry_enter()
100+
*/
101+
#ifndef arch_in_rcu_eqs
102+
static __always_inline bool arch_in_rcu_eqs(void) { return false; }
103+
#endif
104+
89105
/**
90106
* enter_from_user_mode - Establish state when coming from user mode
91107
*

kernel/entry/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
220220
* TINY_RCU does not support EQS, so let the compiler eliminate
221221
* this part when enabled.
222222
*/
223-
if (!IS_ENABLED(CONFIG_TINY_RCU) && is_idle_task(current)) {
223+
if (!IS_ENABLED(CONFIG_TINY_RCU) &&
224+
(is_idle_task(current) || arch_in_rcu_eqs())) {
224225
/*
225226
* If RCU is not watching then the same careful
226227
* sequence vs. lockdep and tracing is required

0 commit comments

Comments
 (0)