xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mwait_idle: Allow setting the max cstate to C1
@ 2014-06-02 14:43 Ross Lagerwall
  2014-06-02 15:46 ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Ross Lagerwall @ 2014-06-02 14:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Keir Fraser, Jan Beulich

From: Ross Lagerwall <rosslagerwall@citrix.com>

Following 91413b519631 ("x86/mwait_idle: export both C1 and C1E"), when
setting the max cstate to C1, the C1E cstate is used as well. This is
because MWAIT_HINT2CSTATE returns the same value for C1 and C1E.
Instead, when limiting the cstate, compare max_cstate with the position
in the states array, as the acpi cpu_idle driver does.

Without this patch, there's no way of setting the max cstate to C1 when using
the mwait_idle driver.

Signed-off-by: Ross Lagerwall <rosslagerwall@citrix.com>
---
 xen/arch/x86/cpu/mwait-idle.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index 72a7abf..e4cfc16 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -328,11 +328,9 @@ static void mwait_idle(void)
 
 	if (max_cstate > 0 && power && !sched_has_urgent_vcpu() &&
 	    (next_state = cpuidle_current_governor->select(power)) > 0) {
-		do {
-			cx = &power->states[next_state];
-		} while (cx->type > max_cstate && --next_state);
-		if (!next_state)
-			cx = NULL;
+		cx = &power->states[next_state];
+		if (cx->idx > max_cstate)
+			cx = &power->states[max_cstate];
 		menu_get_trace_data(&exp, &pred);
 	}
 	if (!cx) {
@@ -585,6 +583,7 @@ static int mwait_idle_cpu_init(struct notifier_block *nfb,
 			setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE);
 
 		cx = dev->states + dev->count;
+		cx->idx = dev->count;
 		cx->type = state;
 		cx->address = hint;
 		cx->entry_method = ACPI_CSTATE_EM_FFH;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-18 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-02 14:43 [PATCH] x86/mwait_idle: Allow setting the max cstate to C1 Ross Lagerwall
2014-06-02 15:46 ` Jan Beulich
2014-06-18  8:13   ` Ross Lagerwall
2014-06-18 10:08     ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).