[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/mwait-idle: re-order state entry/exit code a little



commit e67ab91fc4324418d11c941d883361a243aaa2d7
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Feb 24 11:20:34 2022 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Feb 24 11:20:34 2022 +0100

    x86/mwait-idle: re-order state entry/exit code a little
    
    The initial observation is that unlike the original ACPI idle driver we
    have a 2nd cpu_is_haltable() in here. By making the actual state entry
    conditional, the emitted trace records as well as the subsequent stats
    update are at least misleading in case the state wasn't actually entered.
    Hence they would want moving inside the conditional. At which point the
    cpuidle_get_tick() invocations could (and hence should) move as well.
    cstate_restore_tsc() also isn't needed if we didn't actually enter the
    state.
    
    This leaves only the errata_c6_workaround() and lapic_timer_off()
    invocations outside the conditional. As a result it looks easier to
    drop the conditional (and come back in sync with the other driver again)
    than to move almost everything into the conditional.
    
    While there also move the TRACE_6D() out of the IRQ-disabled region.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/cpu/mwait-idle.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index f76c64e04b..9efa569da3 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -847,26 +847,25 @@ static void cf_check mwait_idle(void)
 
        update_last_cx_stat(power, cx, before);
 
-       if (cpu_is_haltable(cpu)) {
-               if (cx->irq_enable_early)
-                       local_irq_enable();
+       if (cx->irq_enable_early)
+               local_irq_enable();
 
-               mwait_idle_with_hints(cx->address, MWAIT_ECX_INTERRUPT_BREAK);
+       mwait_idle_with_hints(cx->address, MWAIT_ECX_INTERRUPT_BREAK);
 
-               local_irq_disable();
-       }
+       local_irq_disable();
 
        after = alternative_call(cpuidle_get_tick);
 
        cstate_restore_tsc();
        trace_exit_reason(irq_traced);
-       TRACE_6D(TRC_PM_IDLE_EXIT, cx->type, after,
-               irq_traced[0], irq_traced[1], irq_traced[2], irq_traced[3]);
 
        /* Now back in C0. */
        update_idle_stats(power, cx, before, after);
        local_irq_enable();
 
+       TRACE_6D(TRC_PM_IDLE_EXIT, cx->type, after,
+               irq_traced[0], irq_traced[1], irq_traced[2], irq_traced[3]);
+
        if (!(lapic_timer_reliable_states & (1 << cx->type)))
                lapic_timer_on();
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.