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

[PATCH v3 2/2] x86/mwait-idle: squash stats update when not actually entering C-state


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 27 Jan 2022 16:13:47 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gmEKu/9ca5lmYiJgoL5lXi4Mn2sZqGXi0uK5GeeQpB4=; b=Ydc+5pSntp53rD5K+N2zq86zxPtNt7tilcg4t3L0ovdgkYTHUbQ82jnMb3755wo965CuWPsbmx3ERdPhBy4Gx7jBAhZJ98F8CUs43Xq/t8F+mwJjmxnrB8zqnWKvqwTFPtmQH/b8yP7r/tYKiekhyp+1AoftkGSjft3mN3UmEBIvMRMph/iHgjbHjUPlL4eUau10r0q47+A3GpWONi6zi7eHOmeBs8EviRLhjILclgGDYZyfd6zNaiggkgOfSgg4hoGrhrRBXibfKctYAMmxJTvecRvtSiZVO3nuwBXjArNZTIsXsbqjlI3jT8gg0WR7HkHSmD9Jl15qmrT0mDOTaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dsNlr4oZpKp8GfZFfN1suIJmAwFxkcE2Cq9YIIs5dZQpKRVs1kocqzfFPojCME+3eOqTT/nm1RjqU+hY4YEckb8PSsFveyIrlhMHEpbcbghyvYNp3JF9FKe6LyAxVPkzn98NdMVysqrJUJ1e5MV+GpH8+fNNMqkkjyDQ1NW3AlFBD7aj1ERxWiqlwYa97Nmam+Fw/CR5A/IutI1CGoBOFgnhyeEW1qEXBh1GRi6vc3qqFzsakv435J0pdkSGVW0zWuIjt8UjxkH3F3LE+USDHol8jOb7ptDD0xA6EeUW9DfYuSKiFH5FS+TNGxL3i1Je08F+lGvOsdjt1t3JQuVK2w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 27 Jan 2022 15:13:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

While we don't want to skip calling update_idle_stats(), arrange for it
to not increment the overall time spent in the state we didn't really
enter.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
RFC: If we wanted to also move the tracing, then I think the part ahead
     of the if() also would need moving. At that point we could as well
     move update_last_cx_stat(), too, which afaict would allow skipping
     update_idle_stats() on the "else" path (which therefore would go
     away). Yet then, with the setting of power->safe_state moved up a
     little (which imo it should have been anyway) the two
     cpu_is_haltable() invocations would only have the lapic_timer_off()
     invocation left in between. This would then seem to call for simply
     ditching the 2nd one - acpi-idle also doesn't have a 2nd instance.
TBD: For the tracing I wonder if that really needs to come ahead of the
     local_irq_enable(). Maybe trace_exit_reason() needs to, but quite
     certainly TRACE_6D() doesn't.
---
v3: Also move cstate_restore_tsc() invocation and split ones to
    update_idle_stats().
v2: New.

--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -854,17 +854,23 @@ static void mwait_idle(void)
                mwait_idle_with_hints(cx->address, MWAIT_ECX_INTERRUPT_BREAK);
 
                local_irq_disable();
-       }
 
-       after = alternative_call(cpuidle_get_tick);
+               after = alternative_call(cpuidle_get_tick);
+
+               cstate_restore_tsc();
+
+               /* Now back in C0. */
+               update_idle_stats(power, cx, before, after);
+       } else {
+               /* Never left C0. */
+               after = alternative_call(cpuidle_get_tick);
+               update_idle_stats(power, cx, after, after);
+       }
 
-       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();
 
        if (!(lapic_timer_reliable_states & (1 << cx->type)))




 


Rackspace

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