diff mbox series

[RFC,v2,5/5] x86/mwait-idle: squash stats update when not actually entering C-state

Message ID b9270896-efea-3e81-99fb-685fc5b708be@suse.com (mailing list archive)
State Superseded
Headers show
Series x86/mwait-idle: updates from Linux (and more) | expand

Commit Message

Jan Beulich Jan. 20, 2022, 2:05 p.m. UTC
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@suse.com>
---
RFC: Arguably more of what follows could be moved into the if() -
     thoughts?
---
v2: New.

Comments

Roger Pau Monné Jan. 20, 2022, 4 p.m. UTC | #1
On Thu, Jan 20, 2022 at 03:05:12PM +0100, Jan Beulich wrote:
> 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@suse.com>
> ---
> RFC: Arguably more of what follows could be moved into the if() -
>      thoughts?

I would move at least the restoring of the TSC, but I would be fine
with moving everything up to local_irq_enable unless I'm missing
something.

I think you could likely also avoid the call to update_idle_stats so
there's no need to fetch the new tick count.

Thanks, Roger.
Jan Beulich Jan. 20, 2022, 4:21 p.m. UTC | #2
On 20.01.2022 17:00, Roger Pau Monné wrote:
> On Thu, Jan 20, 2022 at 03:05:12PM +0100, Jan Beulich wrote:
>> 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@suse.com>
>> ---
>> RFC: Arguably more of what follows could be moved into the if() -
>>      thoughts?
> 
> I would move at least the restoring of the TSC, but I would be fine
> with moving everything up to local_irq_enable unless I'm missing
> something.

Yes, that's what I was considering.

> I think you could likely also avoid the call to update_idle_stats so
> there's no need to fetch the new tick count.

No, this call cannot be bypassed. At least not without further
rearrangements elsewhere.

Jan
Roger Pau Monné Jan. 21, 2022, 9:32 a.m. UTC | #3
On Thu, Jan 20, 2022 at 05:21:31PM +0100, Jan Beulich wrote:
> On 20.01.2022 17:00, Roger Pau Monné wrote:
> > On Thu, Jan 20, 2022 at 03:05:12PM +0100, Jan Beulich wrote:
> >> 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@suse.com>
> >> ---
> >> RFC: Arguably more of what follows could be moved into the if() -
> >>      thoughts?
> > 
> > I would move at least the restoring of the TSC, but I would be fine
> > with moving everything up to local_irq_enable unless I'm missing
> > something.
> 
> Yes, that's what I was considering.
> 
> > I think you could likely also avoid the call to update_idle_stats so
> > there's no need to fetch the new tick count.
> 
> No, this call cannot be bypassed. At least not without further
> rearrangements elsewhere.

Ack, I would move everything you can then.

Thanks, Roger.
diff mbox series

Patch

--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -861,9 +861,11 @@  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);
+	}
+	else
+		before = after = alternative_call(cpuidle_get_tick);
 
 	cstate_restore_tsc();
 	trace_exit_reason(irq_traced);