Skip to content

Commit e4ea10e

Browse files
committed
entry: Add arch_in_rcu_eqs()
JIRA: https://issues.redhat.com/browse/RHEL-113440 commit ee4a2e0 Author: Mark Rutland <mark.rutland@arm.com> Date: Tue Jul 8 19:27:41 2025 +1000 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. [ajd@linux.ibm.com: rebase, fix commit message] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Claudio Imbrenda <imbrenda@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Link: https://lore.kernel.org/r/20250708092742.104309-2-ajd@linux.ibm.com Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Message-ID: <20250708092742.104309-2-ajd@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent a0ecbfe commit e4ea10e

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
@@ -85,6 +85,22 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs);
8585
static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs) {}
8686
#endif
8787

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

kernel/entry/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
267267
* TINY_RCU does not support EQS, so let the compiler eliminate
268268
* this part when enabled.
269269
*/
270-
if (!IS_ENABLED(CONFIG_TINY_RCU) && is_idle_task(current)) {
270+
if (!IS_ENABLED(CONFIG_TINY_RCU) &&
271+
(is_idle_task(current) || arch_in_rcu_eqs())) {
271272
/*
272273
* If RCU is not watching then the same careful
273274
* sequence vs. lockdep and tracing is required

0 commit comments

Comments
 (0)