From: "Jan Beulich" Subject: [PATCH 2/3] x86/mwait_idle: export both C1 and C1E Date: Thu, 29 Aug 2013 14:11:55 +0100 Message-ID: <521F64BB02000078000EF709@nat28.tlf.novell.com> References: <521F631602000078000EF6F9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE6D5A68B.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VF21D-0005xY-Ek for xen-devel@lists.xenproject.org; Thu, 29 Aug 2013 13:12:11 +0000 In-Reply-To: <521F631602000078000EF6F9@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Len Brown , Keir Fraser , Jun Nakajima List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartE6D5A68B.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Here we disable HW promotion of C1 to C1E and export both C1 and C1E as distinct C-states. This allows a cpuidle governor to choose a lower latency C-state than C1E when necessary to satisfy performance and QOS constraints -- and still save power versus polling. This also corrects the erroneous latency previously reported for C1E -- it is 10usec, not 1usec. Signed-off-by: Len Brown Avoided the effect of changing the meaning of "max_cstate=3D". Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -88,6 +88,7 @@ struct idle_cpu { * Indicate which enable bits to clear here. */ unsigned long auto_demotion_disable_flags; + bool_t disable_promotion_to_c1e; }; =20 static const struct idle_cpu *icpu; @@ -132,6 +133,12 @@ static const struct cpuidle_state nehale .target_residency =3D 6, }, { + .name =3D "C1E-NHM", + .flags =3D MWAIT2flg(0x01), + .exit_latency =3D 10, + .target_residency =3D 20, + }, + { .name =3D "C3-NHM", .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 20, @@ -150,8 +157,14 @@ static const struct cpuidle_state snb_cs { .name =3D "C1-SNB", .flags =3D MWAIT2flg(0x00), - .exit_latency =3D 1, - .target_residency =3D 1, + .exit_latency =3D 2, + .target_residency =3D 2, + }, + { + .name =3D "C1E-SNB", + .flags =3D MWAIT2flg(0x01), + .exit_latency =3D 10, + .target_residency =3D 20, }, { .name =3D "C3-SNB", @@ -182,6 +195,12 @@ static const struct cpuidle_state ivb_cs .target_residency =3D 1, }, { + .name =3D "C1E-IVB", + .flags =3D MWAIT2flg(0x01), + .exit_latency =3D 10, + .target_residency =3D 20, + }, + { .name =3D "C3-IVB", .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 59, @@ -210,6 +229,12 @@ static const struct cpuidle_state hsw_cs .target_residency =3D 2, }, { + .name =3D "C1E-HSW", + .flags =3D MWAIT2flg(0x01), + .exit_latency =3D 10, + .target_residency =3D 20, + }, + { .name =3D "C3-HSW", .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 33, @@ -232,10 +257,10 @@ static const struct cpuidle_state hsw_cs =20 static const struct cpuidle_state atom_cstates[] =3D { { - .name =3D "C1-ATM", + .name =3D "C1E-ATM", .flags =3D MWAIT2flg(0x00), - .exit_latency =3D 1, - .target_residency =3D 4, + .exit_latency =3D 10, + .target_residency =3D 20, }, { .name =3D "C2-ATM", @@ -354,9 +379,19 @@ static void auto_demotion_disable(void * wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits); } =20 +static void c1e_promotion_disable(void *dummy) +{ + u64 msr_bits; + + rdmsrl(MSR_IA32_POWER_CTL, msr_bits); + msr_bits &=3D ~0x2; + wrmsrl(MSR_IA32_POWER_CTL, msr_bits); +} + static const struct idle_cpu idle_cpu_nehalem =3D { .state_table =3D nehalem_cstates, .auto_demotion_disable_flags =3D NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_D= EMOTE, + .disable_promotion_to_c1e =3D 1, }; =20 static const struct idle_cpu idle_cpu_atom =3D { @@ -370,14 +405,17 @@ static const struct idle_cpu idle_cpu_li =20 static const struct idle_cpu idle_cpu_snb =3D { .state_table =3D snb_cstates, + .disable_promotion_to_c1e =3D 1, }; =20 static const struct idle_cpu idle_cpu_ivb =3D { .state_table =3D ivb_cstates, + .disable_promotion_to_c1e =3D 1, }; =20 static const struct idle_cpu idle_cpu_hsw =3D { .state_table =3D hsw_cstates, + .disable_promotion_to_c1e =3D 1, }; =20 #define ICPU(model, cpu) { 6, model, &idle_cpu_##cpu } @@ -520,6 +558,9 @@ static int mwait_idle_cpu_init(struct no if (icpu->auto_demotion_disable_flags) on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, = NULL, 1); =20 + if (icpu->disable_promotion_to_c1e) + on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, = NULL, 1); + return NOTIFY_DONE; } =20 --- a/xen/include/asm-x86/msr-index.h +++ b/xen/include/asm-x86/msr-index.h @@ -83,6 +83,8 @@ #define MSR_IA32_LASTINTFROMIP 0x000001dd #define MSR_IA32_LASTINTTOIP 0x000001de =20 +#define MSR_IA32_POWER_CTL 0x000001fc + #define MSR_IA32_MTRR_PHYSBASE0 0x00000200 #define MSR_IA32_MTRR_PHYSMASK0 0x00000201 #define MSR_IA32_MTRR_PHYSBASE1 0x00000202 --=__PartE6D5A68B.1__= Content-Type: text/plain; name="x86-mwait-idle-C1E.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mwait-idle-C1E.patch" x86/mwait_idle: export both C1 and C1E=0A=0AHere we disable HW promotion = of C1 to C1E and export both C1 and C1E=0Aas distinct C-states.=0A=0AThis = allows a cpuidle governor to choose a lower latency C-state than=0AC1E = when necessary to satisfy performance and QOS constraints -- and=0Astill = save power versus polling.=0AThis also corrects the erroneous latency = previously reported for C1E=0A-- it is 10usec, not 1usec.=0A=0ASigned-off-b= y: Len Brown =0A=0AAvoided the effect of changing the = meaning of "max_cstate=3D".=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/cpu/mwait-idle.c=0A+++ b/xen/arch/x86/cpu/mwai= t-idle.c=0A@@ -88,6 +88,7 @@ struct idle_cpu {=0A * Indicate which = enable bits to clear here.=0A */=0A unsigned long auto_demotion_disable= _flags;=0A+ bool_t disable_promotion_to_c1e;=0A };=0A =0A static const = struct idle_cpu *icpu;=0A@@ -132,6 +133,12 @@ static const struct = cpuidle_state nehale=0A .target_residency =3D 6,=0A = },=0A {=0A+ .name =3D "C1E-NHM",=0A+ .flags =3D = MWAIT2flg(0x01),=0A+ .exit_latency =3D 10,=0A+ = .target_residency =3D 20,=0A+ },=0A+ {=0A .name =3D = "C3-NHM",=0A .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSH= ED,=0A .exit_latency =3D 20,=0A@@ -150,8 +157,14 @@ static const = struct cpuidle_state snb_cs=0A {=0A .name =3D "C1-SNB",=0A = .flags =3D MWAIT2flg(0x00),=0A- .exit_latency =3D 1,=0A- = .target_residency =3D 1,=0A+ .exit_latency =3D 2,=0A+ = .target_residency =3D 2,=0A+ },=0A+ {=0A+ .name =3D = "C1E-SNB",=0A+ .flags =3D MWAIT2flg(0x01),=0A+ .exit_laten= cy =3D 10,=0A+ .target_residency =3D 20,=0A },=0A {=0A = .name =3D "C3-SNB",=0A@@ -182,6 +195,12 @@ static const struct cpuidle_stat= e ivb_cs=0A .target_residency =3D 1,=0A },=0A {=0A+ = .name =3D "C1E-IVB",=0A+ .flags =3D MWAIT2flg(0x01),=0A+ = .exit_latency =3D 10,=0A+ .target_residency =3D 20,=0A+ = },=0A+ {=0A .name =3D "C3-IVB",=0A .flags =3D = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D = 59,=0A@@ -210,6 +229,12 @@ static const struct cpuidle_state hsw_cs=0A = .target_residency =3D 2,=0A },=0A {=0A+ .name =3D = "C1E-HSW",=0A+ .flags =3D MWAIT2flg(0x01),=0A+ .exit_laten= cy =3D 10,=0A+ .target_residency =3D 20,=0A+ },=0A+ {=0A = .name =3D "C3-HSW",=0A .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_T= LB_FLUSHED,=0A .exit_latency =3D 33,=0A@@ -232,10 +257,10 @@ = static const struct cpuidle_state hsw_cs=0A =0A static const struct = cpuidle_state atom_cstates[] =3D {=0A {=0A- .name =3D = "C1-ATM",=0A+ .name =3D "C1E-ATM",=0A .flags =3D = MWAIT2flg(0x00),=0A- .exit_latency =3D 1,=0A- = .target_residency =3D 4,=0A+ .exit_latency =3D 10,=0A+ = .target_residency =3D 20,=0A },=0A {=0A .name =3D = "C2-ATM",=0A@@ -354,9 +379,19 @@ static void auto_demotion_disable(void = *=0A wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits);=0A }=0A =0A+static = void c1e_promotion_disable(void *dummy)=0A+{=0A+ u64 msr_bits;=0A+= =0A+ rdmsrl(MSR_IA32_POWER_CTL, msr_bits);=0A+ msr_bits &=3D = ~0x2;=0A+ wrmsrl(MSR_IA32_POWER_CTL, msr_bits);=0A+}=0A+=0A static = const struct idle_cpu idle_cpu_nehalem =3D {=0A .state_table =3D = nehalem_cstates,=0A .auto_demotion_disable_flags =3D NHM_C1_AUTO_DEMOTE= | NHM_C3_AUTO_DEMOTE,=0A+ .disable_promotion_to_c1e =3D 1,=0A };=0A = =0A static const struct idle_cpu idle_cpu_atom =3D {=0A@@ -370,14 +405,17 = @@ static const struct idle_cpu idle_cpu_li=0A =0A static const struct = idle_cpu idle_cpu_snb =3D {=0A .state_table =3D snb_cstates,=0A+ = .disable_promotion_to_c1e =3D 1,=0A };=0A =0A static const struct idle_cpu = idle_cpu_ivb =3D {=0A .state_table =3D ivb_cstates,=0A+ .disable_pr= omotion_to_c1e =3D 1,=0A };=0A =0A static const struct idle_cpu idle_cpu_hs= w =3D {=0A .state_table =3D hsw_cstates,=0A+ .disable_promotion_= to_c1e =3D 1,=0A };=0A =0A #define ICPU(model, cpu) { 6, model, &idle_cpu_#= #cpu }=0A@@ -520,6 +558,9 @@ static int mwait_idle_cpu_init(struct no=0A = if (icpu->auto_demotion_disable_flags)=0A on_selected_cpus(cp= umask_of(cpu), auto_demotion_disable, NULL, 1);=0A =0A+ if (icpu->disable_p= romotion_to_c1e)=0A+ on_selected_cpus(cpumask_of(cpu), = c1e_promotion_disable, NULL, 1);=0A+=0A return NOTIFY_DONE;=0A = }=0A =0A--- a/xen/include/asm-x86/msr-index.h=0A+++ b/xen/include/asm-x86/m= sr-index.h=0A@@ -83,6 +83,8 @@=0A #define MSR_IA32_LASTINTFROMIP = 0x000001dd=0A #define MSR_IA32_LASTINTTOIP 0x000001de=0A = =0A+#define MSR_IA32_POWER_CTL 0x000001fc=0A+=0A #define = MSR_IA32_MTRR_PHYSBASE0 0x00000200=0A #define MSR_IA32_MTRR_PHYSMASK0 = 0x00000201=0A #define MSR_IA32_MTRR_PHYSBASE1 0x00000202=0A --=__PartE6D5A68B.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartE6D5A68B.1__=--