lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 14 Jun 2007 22:28:19 +0200
From:	Andreas Mohr <andi@...x01.hs-esslingen.de>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Corey Minyard <minyard@....org>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Andi Kleen <ak@...e.de>, linux-kernel@...r.kernel.org
Subject: [PATCH -mm] i386: add cpu_relax() to cmos_lock()

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).

This is a small followup to my cpu_relax() patch series last year.

A different, possibly more readable and efficient way to write this loop
would be something like:

	while ((cmos_lock) ||
           (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)))) {
		cpu_relax();
	}

Compiled and runtime-tested on linux-2.6.22-rc4-mm2, Athlon.

Signed-off-by: Andreas Mohr <andi@...as.de>


--- linux-2.6.22-rc4-mm2.orig/include/asm-i386/mc146818rtc.h	2007-06-10 22:00:53.000000000 +0200
+++ linux-2.6.22-rc4-mm2/include/asm-i386/mc146818rtc.h	2007-06-09 21:40:21.000000000 +0200
@@ -43,8 +43,10 @@
 	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;
 	}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ