Skip to content

Commit

Permalink
x86, hotplug: Fix powersavings with offlined cores on AMD
Browse files Browse the repository at this point in the history
ea53069 made a CPU use monitor/mwait
when offline. This is not the optimal choice for AMD wrt to powersavings
and we'd prefer our cores to halt (i.e. enter C1) instead. For this, the
same selection whether to use monitor/mwait has to be used as when we
select the idle routine for the machine.

With this patch, offlining cores 1-5 on a X6 machine allows core0 to
boost again.

[ hpa: putting this in urgent since it is a (power) regression fix ]

Reported-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: stable@kernel.org # 37.x
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Venkatesh Pallipadi <venki@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.hl>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
LKML-Reference: <1295534572-10730-1-git-send-email-bp@amd64.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Borislav Petkov authored and H. Peter Anvin committed Jan 22, 2011
1 parent f21bbec commit 93789b3
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/x86/include/asm/cpu.h
Original file line number Diff line number Diff line change
@@ -32,5 +32,6 @@ extern void arch_unregister_cpu(int);

DECLARE_PER_CPU(int, cpu_state);

int __cpuinit mwait_usable(const struct cpuinfo_x86 *);

#endif /* _ASM_X86_CPU_H */
3 changes: 2 additions & 1 deletion arch/x86/kernel/process.c
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
#include <linux/utsname.h>
#include <trace/events/power.h>
#include <linux/hw_breakpoint.h>
#include <asm/cpu.h>
#include <asm/system.h>
#include <asm/apic.h>
#include <asm/syscalls.h>
@@ -505,7 +506,7 @@ static void poll_idle(void)
#define MWAIT_ECX_EXTENDED_INFO 0x01
#define MWAIT_EDX_C1 0xf0

static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
{
u32 eax, ebx, ecx, edx;

3 changes: 2 additions & 1 deletion arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
@@ -1402,8 +1402,9 @@ static inline void mwait_play_dead(void)
unsigned int highest_subcstate = 0;
int i;
void *mwait_ptr;
struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);

if (!cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_MWAIT))
if (!(cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)))
return;
if (!cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_CLFLSH))
return;

0 comments on commit 93789b3

Please sign in to comment.