From: "Jan Beulich" Subject: [PATCH 1/2] x86/mwait_idle: stop using driver_data for static flags Date: Tue, 16 Apr 2013 09:47:56 +0100 Message-ID: <516D2C5C02000078000CD7A2@nat28.tlf.novell.com> References: <516D2AB102000078000CD795@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6858592C.0__=" Return-path: In-Reply-To: <516D2AB102000078000CD795@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 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. --=__Part6858592C.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The (Linux) commit 4202735e8ab6ecfb0381631a0d0b58fefe0bd4e2 (cpuidle: Split cpuidle_state structure and move per-cpu statistics = fields) observed that the MWAIT flags for Cn on every processor to date were the same, and created get_driver_data() to supply them. Unfortunately, that assumption is false, going forward. So here we restore the MWAIT flags to the cpuidle_state table. However, instead restoring the old "driver_data" field, we put the flags into the existing "flags" field, where they probalby should have lived all along. This patch does not change any operation. Signed-off-by: Len Brown Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -108,6 +108,16 @@ static const struct cpuidle_state { #define CPUIDLE_FLAG_TLB_FLUSHED 0x10000 =20 /* + * MWAIT takes an 8-bit "hint" in EAX "suggesting" + * the C-state (top nibble) and sub-state (bottom nibble) + * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc. + * + * We store the hint at the top of our "flags" for each state. + */ +#define flg2MWAIT(flags) (((flags) >> 24) & 0xFF) +#define MWAIT2flg(eax) ((eax & 0xFF) << 24) + +/* * States are indexed by the cstate number, * which is also the index into the MWAIT hint array. * Thus C0 is a dummy. @@ -116,18 +126,19 @@ static const struct cpuidle_state nehale { /* MWAIT C0 */ }, { /* MWAIT C1 */ .name =3D "C1-NHM", + .flags =3D MWAIT2flg(0x00), .exit_latency =3D 3, .target_residency =3D 6, }, { /* MWAIT C2 */ .name =3D "C3-NHM", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 20, .target_residency =3D 80, }, { /* MWAIT C3 */ .name =3D "C6-NHM", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 200, .target_residency =3D 800, } @@ -137,24 +148,25 @@ static const struct cpuidle_state snb_cs { /* MWAIT C0 */ }, { /* MWAIT C1 */ .name =3D "C1-SNB", + .flags =3D MWAIT2flg(0x00), .exit_latency =3D 1, .target_residency =3D 1, }, { /* MWAIT C2 */ .name =3D "C3-SNB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 80, .target_residency =3D 211, }, { /* MWAIT C3 */ .name =3D "C6-SNB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 104, .target_residency =3D 345, }, { /* MWAIT C4 */ .name =3D "C7-SNB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 109, .target_residency =3D 345, } @@ -164,24 +176,25 @@ static const struct cpuidle_state ivb_cs { /* MWAIT C0 */ }, { /* MWAIT C1 */ .name =3D "C1-IVB", + .flags =3D MWAIT2flg(0x00), .exit_latency =3D 1, .target_residency =3D 1, }, { /* MWAIT C2 */ .name =3D "C3-IVB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 59, .target_residency =3D 156, }, { /* MWAIT C3 */ .name =3D "C6-IVB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 80, .target_residency =3D 300, }, { /* MWAIT C4 */ .name =3D "C7-IVB", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 87, .target_residency =3D 300, } @@ -191,44 +204,32 @@ static const struct cpuidle_state atom_c { /* MWAIT C0 */ }, { /* MWAIT C1 */ .name =3D "C1-ATM", + .flags =3D MWAIT2flg(0x00), .exit_latency =3D 1, .target_residency =3D 4, }, { /* MWAIT C2 */ .name =3D "C2-ATM", + .flags =3D MWAIT2flg(0x10), .exit_latency =3D 20, .target_residency =3D 80, }, { /* MWAIT C3 */ }, { /* MWAIT C4 */ .name =3D "C4-ATM", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 100, .target_residency =3D 400, }, { /* MWAIT C5 */ }, { /* MWAIT C6 */ .name =3D "C6-ATM", - .flags =3D CPUIDLE_FLAG_TLB_FLUSHED, + .flags =3D MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, .exit_latency =3D 140, .target_residency =3D 560, } }; =20 -static u32 get_driver_data(unsigned int cstate) -{ - static const u32 driver_data[] =3D { - [1] /* MWAIT C1 */ =3D 0x00, - [2] /* MWAIT C2 */ =3D 0x10, - [3] /* MWAIT C3 */ =3D 0x20, - [4] /* MWAIT C4 */ =3D 0x30, - [5] /* MWAIT C5 */ =3D 0x40, - [6] /* MWAIT C6 */ =3D 0x52, - }; - - return driver_data[cstate < ARRAY_SIZE(driver_data) ? cstate : 0]; -} - static void mwait_idle(void) { unsigned int cpu =3D smp_processor_id(); @@ -477,7 +478,7 @@ static int mwait_idle_cpu_init(struct no =20 cx =3D dev->states + dev->count; cx->type =3D cstate; - cx->address =3D get_driver_data(cstate); + cx->address =3D flg2MWAIT(cpuidle_state_table[cstate].flags= ); cx->entry_method =3D ACPI_CSTATE_EM_FFH; cx->latency =3D cpuidle_state_table[cstate].exit_latency; cx->target_residency =3D --=__Part6858592C.0__= Content-Type: text/plain; name="x86-mwait-idle-flags.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mwait-idle-flags.patch" x86/mwait_idle: stop using driver_data for static flags=0A=0AThe (Linux) = commit 4202735e8ab6ecfb0381631a0d0b58fefe0bd4e2=0A(cpuidle: Split = cpuidle_state structure and move per-cpu statistics fields)=0Aobserved = that the MWAIT flags for Cn on every processor to date were the=0Asame, = and created get_driver_data() to supply them.=0A=0AUnfortunately, that = assumption is false, going forward.=0ASo here we restore the MWAIT flags = to the cpuidle_state table.=0AHowever, instead restoring the old "driver_da= ta" field,=0Awe put the flags into the existing "flags" field,=0Awhere = they probalby should have lived all along.=0A=0AThis patch does not change = any operation.=0A=0ASigned-off-by: Len Brown =0ASigned= -off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/cpu/mwait-= idle.c=0A+++ b/xen/arch/x86/cpu/mwait-idle.c=0A@@ -108,6 +108,16 @@ static = const struct cpuidle_state {=0A #define CPUIDLE_FLAG_TLB_FLUSHED = 0x10000=0A =0A /*=0A+ * MWAIT takes an 8-bit "hint" in EAX "suggesting"=0A+= * the C-state (top nibble) and sub-state (bottom nibble)=0A+ * 0x00 means = "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.=0A+ *=0A+ * We store the hint at = the top of our "flags" for each state.=0A+ */=0A+#define flg2MWAIT(flags) = (((flags) >> 24) & 0xFF)=0A+#define MWAIT2flg(eax) ((eax & 0xFF) << = 24)=0A+=0A+/*=0A * States are indexed by the cstate number,=0A * which = is also the index into the MWAIT hint array.=0A * Thus C0 is a dummy.=0A@@= -116,18 +126,19 @@ static const struct cpuidle_state nehale=0A { = /* MWAIT C0 */ },=0A { /* MWAIT C1 */=0A .name =3D = "C1-NHM",=0A+ .flags =3D MWAIT2flg(0x00),=0A .exit_laten= cy =3D 3,=0A .target_residency =3D 6,=0A },=0A { /* MWAIT = C2 */=0A .name =3D "C3-NHM",=0A- .flags =3D = CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D MWAIT2flg(0x10) | = CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D 20,=0A = .target_residency =3D 80,=0A },=0A { /* MWAIT C3 */=0A = .name =3D "C6-NHM",=0A- .flags =3D CPUIDLE_FLAG_TLB_FLUSHED,=0A+ = .flags =3D MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,=0A = .exit_latency =3D 200,=0A .target_residency =3D 800,=0A = }=0A@@ -137,24 +148,25 @@ static const struct cpuidle_state snb_cs=0A { = /* MWAIT C0 */ },=0A { /* MWAIT C1 */=0A .name =3D = "C1-SNB",=0A+ .flags =3D MWAIT2flg(0x00),=0A .exit_laten= cy =3D 1,=0A .target_residency =3D 1,=0A },=0A { /* MWAIT = C2 */=0A .name =3D "C3-SNB",=0A- .flags =3D = CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D MWAIT2flg(0x10) | = CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D 80,=0A = .target_residency =3D 211,=0A },=0A { /* MWAIT C3 */=0A = .name =3D "C6-SNB",=0A- .flags =3D CPUIDLE_FLAG_TLB_FLUSHED,=0A+ = .flags =3D MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,=0A = .exit_latency =3D 104,=0A .target_residency =3D 345,=0A = },=0A { /* MWAIT C4 */=0A .name =3D "C7-SNB",=0A- = .flags =3D CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D = MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D = 109,=0A .target_residency =3D 345,=0A }=0A@@ -164,24 = +176,25 @@ static const struct cpuidle_state ivb_cs=0A { /* MWAIT C0 */ = },=0A { /* MWAIT C1 */=0A .name =3D "C1-IVB",=0A+ = .flags =3D MWAIT2flg(0x00),=0A .exit_latency =3D 1,=0A = .target_residency =3D 1,=0A },=0A { /* MWAIT C2 */=0A = .name =3D "C3-IVB",=0A- .flags =3D CPUIDLE_FLAG_TLB_FLUSHED,=0A+ = .flags =3D MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,=0A = .exit_latency =3D 59,=0A .target_residency =3D 156,=0A = },=0A { /* MWAIT C3 */=0A .name =3D "C6-IVB",=0A- = .flags =3D CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D = 80,=0A .target_residency =3D 300,=0A },=0A { /* MWAIT C4 = */=0A .name =3D "C7-IVB",=0A- .flags =3D CPUIDLE_FLAG_TLB= _FLUSHED,=0A+ .flags =3D MWAIT2flg(0x30) | CPUIDLE_FLAG_TLB_FLUSH= ED,=0A .exit_latency =3D 87,=0A .target_residency = =3D 300,=0A }=0A@@ -191,44 +204,32 @@ static const struct cpuidle_state= atom_c=0A { /* MWAIT C0 */ },=0A { /* MWAIT C1 */=0A = .name =3D "C1-ATM",=0A+ .flags =3D MWAIT2flg(0x00),=0A = .exit_latency =3D 1,=0A .target_residency =3D 4,=0A = },=0A { /* MWAIT C2 */=0A .name =3D "C2-ATM",=0A+ = .flags =3D MWAIT2flg(0x10),=0A .exit_latency =3D 20,=0A = .target_residency =3D 80,=0A },=0A { /* MWAIT C3 */ },=0A { /* MWAIT = C4 */=0A .name =3D "C4-ATM",=0A- .flags =3D = CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D MWAIT2flg(0x30) | = CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D 100,=0A = .target_residency =3D 400,=0A },=0A { /* MWAIT C5 */ },=0A { /* MWAIT = C6 */=0A .name =3D "C6-ATM",=0A- .flags =3D = CPUIDLE_FLAG_TLB_FLUSHED,=0A+ .flags =3D MWAIT2flg(0x52) | = CPUIDLE_FLAG_TLB_FLUSHED,=0A .exit_latency =3D 140,=0A = .target_residency =3D 560,=0A }=0A };=0A =0A-static u32 get_driver_data(u= nsigned int cstate)=0A-{=0A- static const u32 driver_data[] =3D {=0A- = [1] /* MWAIT C1 */ =3D 0x00,=0A- [2] /* MWAIT C2 */ = =3D 0x10,=0A- [3] /* MWAIT C3 */ =3D 0x20,=0A- = [4] /* MWAIT C4 */ =3D 0x30,=0A- [5] /* MWAIT C5 */ =3D = 0x40,=0A- [6] /* MWAIT C6 */ =3D 0x52,=0A- };=0A-=0A- = return driver_data[cstate < ARRAY_SIZE(driver_data) ? cstate : 0];=0A-}=0A-= =0A static void mwait_idle(void)=0A {=0A unsigned int cpu =3D = smp_processor_id();=0A@@ -477,7 +478,7 @@ static int mwait_idle_cpu_init(st= ruct no=0A =0A cx =3D dev->states + dev->count;=0A = cx->type =3D cstate;=0A- cx->address =3D get_driver_data(cst= ate);=0A+ cx->address =3D flg2MWAIT(cpuidle_state_table[cstat= e].flags);=0A cx->entry_method =3D ACPI_CSTATE_EM_FFH;=0A = cx->latency =3D cpuidle_state_table[cstate].exit_latency;=0A = cx->target_residency =3D=0A --=__Part6858592C.0__= 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 --=__Part6858592C.0__=--