lkml.org 
[lkml]   [2022]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 9/9] arch/idle: Change arch_cpu_idle() IRQ behaviour
On Thu, May 19, 2022 at 11:27:59PM +0200, Peter Zijlstra wrote:
> Current arch_cpu_idle() is called with IRQs disabled, but will return
> with IRQs enabled.
>
> However, the very first thing the generic code does after calling
> arch_cpu_idle() is raw_local_irq_disable(). This means that
> architectures that can idle with IRQs disabled end up doing a
> pointless 'enable-disable' dance.
>
> Therefore, push this IRQ disabling into the idle function, meaning
> that those architectures can avoid the pointless IRQ state flipping.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---

[...]

> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -699,6 +699,7 @@ EXPORT_SYMBOL(boot_option_idle_override)
> void __cpuidle default_idle(void)
> {
> raw_safe_halt();
> + raw_local_irq_disable();
> }
> #if defined(CONFIG_APM_MODULE) || defined(CONFIG_HALTPOLL_CPUIDLE_MODULE)
> EXPORT_SYMBOL(default_idle);
> @@ -804,13 +805,7 @@ static void amd_e400_idle(void)
>
> default_idle();
>
> - /*
> - * The switch back from broadcast mode needs to be called with
> - * interrupts disabled.
> - */
> - raw_local_irq_disable();
> tick_broadcast_exit();
> - raw_local_irq_enable();
> }
>
> /*
> @@ -849,12 +844,11 @@ static __cpuidle void mwait_idle(void)
> }
>
> __monitor((void *)&current_thread_info()->flags, 0, 0);
> - if (!need_resched())
> + if (!need_resched()) {
> __sti_mwait(0, 0);
> - else
> - raw_local_irq_enable();
> + raw_local_irq_disable();
> + }
> } else {
> - raw_local_irq_enable();
> }


We don't need the outer else clause anymore.

> __current_clr_polling();
> }


--
Thanks and Regards
gautham.

\
 
 \ /
  Last update: 2022-05-23 12:03    [W:8.295 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site