login
Header Space

 
 

[PATCH for review] [19/48] i386: add cpu_relax() to cmos_lock()

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <andi@...>, <ak@...>, <linux-kernel@...>
Date: Thursday, July 19, 2007 - 9:48 am

From: Andreas Mohr <andi@lisas.de>

Add cpu_relax() to cmos_lock() inline function for faster operation on SMT
CPUs and less power consumption on others in case of lock contention (which
probably doesn't happen too often, so admittedly this patch is not too
exciting).

[akpm@linux-foundation.org: Include the header file for cpu_relax()]
Signed-off-by: Andreas Mohr <andi@lisas.de>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/asm-i386/mc146818rtc.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux/include/asm-i386/mc146818rtc.h
===================================================================
--- linux.orig/include/asm-i386/mc146818rtc.h
+++ linux/include/asm-i386/mc146818rtc.h
@@ -6,6 +6,7 @@
 
 #include <asm/io.h>
 #include <asm/system.h>
+#include <asm/processor.h>
 #include <linux/mc146818rtc.h>
 
 #ifndef RTC_PORT
@@ -43,8 +44,10 @@ static inline void lock_cmos(unsigned ch
 	unsigned long new;
 	new = ((smp_processor_id()+1) << 8) | reg;
 	for (;;) {
-		if (cmos_lock)
+		if (cmos_lock) {
+			cpu_relax();
 			continue;
+		}
 		if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0)
 			return;
 	}
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH for review] [19/48] i386: add cpu_relax() to cmos_loc..., Andi Kleen, (Thu Jul 19, 9:48 am)
Re: [PATCH for review] [26/48] i386: hpet assumes boot cpu i..., Jeremy Fitzhardinge, (Thu Jul 19, 12:23 pm)
Re: [PATCH for review] [7/48] i386: divorce CONFIG_X86_PAE f..., Christoph Hellwig, (Thu Jul 19, 10:52 am)
Re: [PATCH for review] [7/48] i386: divorce CONFIG_X86_PAE f..., William Lee Irwin III, (Thu Jul 19, 8:45 pm)
Re: [PATCH for review] [11/48] x86_64: During VM oom conditi..., Christoph Hellwig, (Thu Jul 19, 10:04 am)
Re: [PATCH for review] [11/48] x86_64: During VM oom conditi..., Geert Uytterhoeven, (Thu Jul 19, 10:14 am)
Re: [PATCH respin, was PATCH for review] During VM oom condi..., Christoph Hellwig, (Tue Jul 24, 10:31 am)
speck-geostationary