Skip to content

Commit

Permalink
x86: disable mwait for AMD family 10H/11H CPUs
Browse files Browse the repository at this point in the history
The previous revert of 0c07ee3 left
out the mwait disable condition for AMD family 10H/11H CPUs.

Andreas Herrman said:

It depends on the CPU. For AMD CPUs that support MWAIT this is wrong.
Family 0x10 and 0x11 CPUs will enter C1 on HLT. Powersavings then
depend on a clock divisor and current Pstate of the core.

If all cores of a processor are in halt state (C1) the processor can
enter the C1E (C1 enhanced) state. If mwait is used this will never
happen.

Thus HLT saves more power than MWAIT here.

It might be best to switch off the mwait flag for these AMD CPU
families like it was introduced with commit
f039b75 (x86: Don't use MWAIT on AMD
Family 10)

Re-add the AMD families 10H/11H check and disable the mwait usage for
those.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed May 17, 2008
1 parent 31f4d87 commit e9623b3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion arch/x86/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,33 @@ static void poll_idle(void)
cpu_relax();
}

/*
* mwait selection logic:
*
* It depends on the CPU. For AMD CPUs that support MWAIT this is
* wrong. Family 0x10 and 0x11 CPUs will enter C1 on HLT. Powersavings
* then depend on a clock divisor and current Pstate of the core. If
* all cores of a processor are in halt state (C1) the processor can
* enter the C1E (C1 enhanced) state. If mwait is used this will never
* happen.
*
* idle=mwait overrides this decision and forces the usage of mwait.
*/
static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
{
if (force_mwait)
return 1;

if (c->x86_vendor == X86_VENDOR_AMD) {
switch(c->x86) {
case 0x10:
case 0x11:
return 0;
}
}
return 1;
}

void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
{
static int selected;
Expand All @@ -122,7 +149,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
" performance may degrade.\n");
}
#endif
if (cpu_has(c, X86_FEATURE_MWAIT)) {
if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) {
/*
* Skip, if setup has overridden idle.
* One CPU supports mwait => All CPUs supports mwait
Expand Down

0 comments on commit e9623b3

Please sign in to comment.