arch/arm/kernel: use cpu_relax() in halt loops
PATCH 1/1 arch/arm/kernel: use cpu_relax() in halt loops
Looking throught arch/arm/kernel/ I found some halt loops. I just thought we could save some power here using cpu_relax(), or am I missing something?
--- arch/arm/kernel/process.c | 6 ++++-- arch/arm/kernel/setup.c | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-)
arch/arm/kernel/process.c +4 -2
@@ -124,7 +124,8 @@ void arm_machine_restart(char mode, const char *cmd)*/ mdelay (1000 );printk ("Reboot failed -- System halted\n" ); -while (1 ); +while (1 ) +cpu_relax (); }/*
@@ -235,7 +236,8 @@ void machine_shutdown(void)void machine_halt (void ) {machine_shutdown (); -while (1 ); +while (1 ) +cpu_relax (); }void machine_power_off (void )
arch/arm/kernel/setup.c +5 -2
@@ -41,6 +41,7 @@#include <asm/cacheflush.h> #include <asm/cachetype.h> #include <asm/tlbflush.h> +#include <asm/processor.h> #include <asm/mach/arch.h> #include <asm/mach/irq.h>
@@ -337,7 +338,8 @@ static void __init setup_processor(void)if (!list) {printk ("CPU configuration botched (ID %08x), unable " "to continue.\n" ,read_cpuid_id ()); -while (1 ); +while (1 ) +cpu_relax (); } cpu_name = list->cpu_name;
@@ -434,7 +436,8 @@ static struct machine_desc * __init setup_machine(unsigned int nr)if (!list) {printk ("Machine configuration botched (nr %d), unable " "to continue.\n" , nr); -while (1 ); +while (1 ) +cpu_relax (); }printk ("Machine: %s\n" , list->name);
Signature · 1 line
1.7.2.3
Quoted 3 lines · Jonathan Neusch?fer
Looking throught
arch/arm/kernel/I found some halt loops. I just thought we could save some power here usingcpu_relax(), or am I missing something?
#if __LINUX_ARM_ARCH__ == 6
#define cpu_relax() smp_mb()
#else
#define cpu_relax() barrier()
#endif
IOW, it's either a memory barrier or compiler barrier on ARM; it doesn't do any power saving.
Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Jonathan Neusch?fer
Looking throught
arch/arm/kernel/I found some halt loops. I just thought we could save some power here usingcpu_relax(), or am I missing something?
Quoted 8 lines
#if
__LINUX_ARM_ARCH__== 6
#definecpu_relax()smp_mb()
#else
#definecpu_relax()barrier()
#endifIOW, it's either a memory barrier or compiler barrier on ARM; it doesn't do any power saving.
Okay, thanks for that explanation.