From nobody Mon Apr 6 09:11:36 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEAB53AA1BC for ; Fri, 20 Mar 2026 11:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774006257; cv=none; b=oAlVRqJLdipXT0wvJd8AUgwZSQir0Z1O/uiiV2voOhI5C0wIDeb8HpNlNYzOdW2Er+JFNUt0pDR1FfSgRtaePh+cNQLafmzY7IcZRWPSNdxm8vm2SirHyJvOvzDrl26vRbmw2wMgWtHvwIFiecLkUN+SKb9NosMnUpUoHok6CkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774006257; c=relaxed/simple; bh=i2NyVyEZ+/7Iam2NIktlD4QK3MoEhYPNxPtfOnnI5YA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lWo+iHuD+Koq7067tOgd8MctAdEsdy0RtDa+X8RiGc5vtXjhw1eWuzpP07ozO8pytbBd8p3BDpfIF7CgcXJytUDA2bsy+PKDhUigytF9YZEF9O8lbN2QcFY9caFsLnGeYThXuJzD8tr4l6IrtXflLILlWb5SaofqMkAZqsf+wNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3718422F8; Fri, 20 Mar 2026 04:30:42 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9FD273F7BD; Fri, 20 Mar 2026 04:30:46 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ada.coupriediaz@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, luto@kernel.org, mark.rutland@arm.com, peterz@infradead.org, ruanjinjie@huawei.com, tglx@kernel.org, vladimir.murzin@arm.com, will@kernel.org Subject: [PATCH 2/2] arm64/entry: Remove arch_irqentry_exit_need_resched() Date: Fri, 20 Mar 2026 11:30:26 +0000 Message-Id: <20260320113026.3219620-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20260320113026.3219620-1-mark.rutland@arm.com> References: <20260320113026.3219620-1-mark.rutland@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The only user of arch_irqentry_exit_need_resched() is arm64. As arm64 provides its own preemption logic, there's no need to indirect some of this via the generic irq entry code. Remove arch_irqentry_exit_need_resched(), and fold its logic directly into arm64's entry code. Signed-off-by: Mark Rutland Cc: Ada Couprie Diaz Cc: Andy Lutomirski Cc: Catalin Marinas Cc: Jinjie Ruan Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vladimir Murzin Cc: Will Deacon --- arch/arm64/include/asm/entry-common.h | 27 --------------------------- arch/arm64/kernel/entry-common.c | 27 ++++++++++++++++++++++++++- kernel/entry/common.c | 16 +--------------- 3 files changed, 27 insertions(+), 43 deletions(-) diff --git a/arch/arm64/include/asm/entry-common.h b/arch/arm64/include/asm= /entry-common.h index cab8cd78f6938..2b8335ea2a390 100644 --- a/arch/arm64/include/asm/entry-common.h +++ b/arch/arm64/include/asm/entry-common.h @@ -27,31 +27,4 @@ static __always_inline void arch_exit_to_user_mode_work(= struct pt_regs *regs, =20 #define arch_exit_to_user_mode_work arch_exit_to_user_mode_work =20 -static inline bool arch_irqentry_exit_need_resched(void) -{ - /* - * DAIF.DA are cleared at the start of IRQ/FIQ handling, and when GIC - * priority masking is used the GIC irqchip driver will clear DAIF.IF - * using gic_arch_enable_irqs() for normal IRQs. If anything is set in - * DAIF we must have handled an NMI, so skip preemption. - */ - if (system_uses_irq_prio_masking() && read_sysreg(daif)) - return false; - - /* - * Preempting a task from an IRQ means we leave copies of PSTATE - * on the stack. cpufeature's enable calls may modify PSTATE, but - * resuming one of these preempted tasks would undo those changes. - * - * Only allow a task to be preempted once cpufeatures have been - * enabled. - */ - if (!system_capabilities_finalized()) - return false; - - return true; -} - -#define arch_irqentry_exit_need_resched arch_irqentry_exit_need_resched - #endif /* _ASM_ARM64_ENTRY_COMMON_H */ diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-com= mon.c index 1aedadf09eb4d..c4481e0e326a7 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -486,6 +486,31 @@ static __always_inline void __el1_pnmi(struct pt_regs = *regs, irqentry_nmi_exit(regs, state); } =20 +static void arm64_irqentry_exit_cond_resched(void) +{ + /* + * DAIF.DA are cleared at the start of IRQ/FIQ handling, and when GIC + * priority masking is used the GIC irqchip driver will clear DAIF.IF + * using gic_arch_enable_irqs() for normal IRQs. If anything is set in + * DAIF we must have handled an NMI, so skip preemption. + */ + if (system_uses_irq_prio_masking() && read_sysreg(daif)) + return; + + /* + * Preempting a task from an IRQ means we leave copies of PSTATE + * on the stack. cpufeature's enable calls may modify PSTATE, but + * resuming one of these preempted tasks would undo those changes. + * + * Only allow a task to be preempted once cpufeatures have been + * enabled. + */ + if (!system_capabilities_finalized()) + return; + + irqentry_exit_cond_resched(); +} + static __always_inline void __el1_irq(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { @@ -497,7 +522,7 @@ static __always_inline void __el1_irq(struct pt_regs *r= egs, do_interrupt_handler(regs, handler); irq_exit_rcu(); =20 - irqentry_exit_cond_resched(); + arm64_irqentry_exit_cond_resched(); =20 exit_to_kernel_mode(regs, state); } diff --git a/kernel/entry/common.c b/kernel/entry/common.c index af9cae1f225e3..28351d76cfeb3 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -171,20 +171,6 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs= *regs) return ret; } =20 -/** - * arch_irqentry_exit_need_resched - Architecture specific need resched fu= nction - * - * Invoked from raw_irqentry_exit_cond_resched() to check if resched is ne= eded. - * Defaults return true. - * - * The main purpose is to permit arch to avoid preemption of a task from a= n IRQ. - */ -static inline bool arch_irqentry_exit_need_resched(void); - -#ifndef arch_irqentry_exit_need_resched -static inline bool arch_irqentry_exit_need_resched(void) { return true; } -#endif - void raw_irqentry_exit_cond_resched(void) { if (!preempt_count()) { @@ -192,7 +178,7 @@ void raw_irqentry_exit_cond_resched(void) rcu_irq_exit_check_preempt(); if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) WARN_ON_ONCE(!on_thread_stack()); - if (need_resched() && arch_irqentry_exit_need_resched()) + if (need_resched()) preempt_schedule_irq(); } } --=20 2.30.2