Commit c74c44c6 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Will Deacon
Browse files

arm64: entry: Use preempt_count() and need_resched() helper



The generic entry code uses preempt_count() and need_resched() helpers to
check if it should do preempt_schedule_irq(). 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.

Reviewed-by: default avatarAda Couprie Diaz <ada.coupriediaz@arm.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 77c19539
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -299,14 +299,6 @@ static inline bool arm64_preempt_schedule_irq(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
@@ -701,8 +693,10 @@ static __always_inline void __el1_irq(struct pt_regs *regs,
	do_interrupt_handler(regs, handler);
	irq_exit_rcu();

	if (!preempt_count() && need_resched()) {
		if (arm64_preempt_schedule_irq())
			preempt_schedule_irq();
	}

	exit_to_kernel_mode(regs, state);
}