[PATCH -next v5 05/22] arm64: entry: Use preempt_count() and need_resched() helper
From: Jinjie Ruan
Date: Fri Dec 06 2024 - 05:24:59 EST
The generic entry code uses preempt_count() and need_resched() helpers to
check if it is time to resched. Currently, arm64 use its own check logic,
that is "READ_ONCE(current_thread_info()->preempt_count == 0", which is
equivalent to "preempt_count() == 0 && need_resched()".
In preparation for moving arm64 over to the generic entry code, use
these helpers to replace arm64's own code and move it ahead.
No functional changes.
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
arch/arm64/kernel/entry-common.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index da68c089b74b..efd1a990d138 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -88,14 +88,6 @@ static inline bool arm64_need_resched(void)
if (!need_irq_preemption())
return false;
- /*
- * Note: thread_info::preempt_count includes both thread_info::count
- * and thread_info::need_resched, and is not equivalent to
- * preempt_count().
- */
- if (READ_ONCE(current_thread_info()->preempt_count) != 0)
- return false;
-
/*
* 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
@@ -141,8 +133,10 @@ static __always_inline void __exit_to_kernel_mode(struct pt_regs *regs,
return;
}
- if (arm64_need_resched())
- preempt_schedule_irq();
+ if (!preempt_count() && need_resched()) {
+ if (arm64_need_resched())
+ preempt_schedule_irq();
+ }
trace_hardirqs_on();
} else {
--
2.34.1