[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6nlkyxAZEtY_M7T@J2N7QTR9R3>
Date: Mon, 10 Feb 2025 11:40:03 +0000
From: Mark Rutland <mark.rutland@....com>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: catalin.marinas@....com, will@...nel.org, oleg@...hat.com,
sstabellini@...nel.org, tglx@...utronix.de, peterz@...radead.org,
luto@...nel.org, mingo@...hat.com, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com,
rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
vschneid@...hat.com, kees@...nel.org, wad@...omium.org,
akpm@...ux-foundation.org, samitolvanen@...gle.com,
masahiroy@...nel.org, hca@...ux.ibm.com, aliceryhl@...gle.com,
rppt@...nel.org, xur@...gle.com, paulmck@...nel.org, arnd@...db.de,
mbenes@...e.cz, puranjay@...nel.org, pcc@...gle.com,
ardb@...nel.org, sudeep.holla@....com, guohanjun@...wei.com,
rafael@...nel.org, liuwei09@...tc.cn, dwmw@...zon.co.uk,
Jonathan.Cameron@...wei.com, liaochang1@...wei.com,
kristina.martsenko@....com, ptosi@...gle.com, broonie@...nel.org,
thiago.bauermann@...aro.org, kevin.brodsky@....com,
joey.gouly@....com, liuyuntao12@...wei.com, leobras@...hat.com,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
xen-devel@...ts.xenproject.org
Subject: Re: [PATCH -next v5 05/22] arm64: entry: Use preempt_count() and
need_resched() helper
On Fri, Dec 06, 2024 at 06:17:27PM +0800, Jinjie Ruan wrote:
> 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()".
Hmm. The existing code relies upon preempt_fold_need_resched() to work
correctly. If we want to move from:
READ_ONCE(current_thread_info()->preempt_count) == 0
... to:
!preempt_count() && need_resched()
... then that change should be made *before* we change the preemption
logic to preempt non-IRQ exceptions in patch 3. Otherwise, that logic is
consuming stale data most of the time.
Mark.
> 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@...wei.com>
> ---
> 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
>
Powered by blists - more mailing lists