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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 24 Mar 2015 14:37:43 -0500 (CDT)
From:	Christoph Lameter <cl@...ux.com>
To:	Steven Rostedt <rostedt@...dmis.org>
cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Uwe Kleine-Koenig <u.kleine-koenig@...gutronix.de>
Subject: Re: [GIT PULL] ring-buffer: Replace this_cpu_*() with
 __this_cpu_*()

Here is a potential patch for this.

Subject: [percpu] make this_cpu_read/write operate like raw_cpu_read/write

As noted threre is not much of a point in disabling preemption or interrupts
for this_cpu_read/write since the processor may change afterwards anyways
if preemption is on. Thus we should be able to use the raw versions instead.

The most that could go amiss is that the guaranteed local read/writes now
become operaton that may rarely be done from a remote cpu and thus cause
cache line evictions.

Signed-off-by: Christoph Lameter <cl@...ux.com>

Index: linux/include/asm-generic/percpu.h
===================================================================
--- linux.orig/include/asm-generic/percpu.h	2014-08-05 10:43:51.569894168 -0500
+++ linux/include/asm-generic/percpu.h	2015-03-24 14:18:07.655034405 -0500
@@ -105,15 +105,6 @@ do {									\
 	(__ret);							\
 })

-#define this_cpu_generic_read(pcp)					\
-({									\
-	typeof(pcp) __ret;						\
-	preempt_disable();						\
-	__ret = *this_cpu_ptr(&(pcp));					\
-	preempt_enable();						\
-	__ret;								\
-})
-
 #define this_cpu_generic_to_op(pcp, val, op)				\
 do {									\
 	unsigned long __flags;						\
@@ -292,32 +283,40 @@ do {									\
 	raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
 #endif

+/*
+ * this_cpu_read/write is not per cpu atomic but that does not matter
+ * since the cpu may change afte the operation anyways. At most we
+ * kick out a per cpu area cacheline.
+ */
 #ifndef this_cpu_read_1
-#define this_cpu_read_1(pcp)		this_cpu_generic_read(pcp)
+#define this_cpu_read_1(pcp)		raw_cpu_read_1(pcp)
 #endif
 #ifndef this_cpu_read_2
-#define this_cpu_read_2(pcp)		this_cpu_generic_read(pcp)
+#define this_cpu_read_2(pcp)		raw_cpu_read_2(pcp)
 #endif
 #ifndef this_cpu_read_4
-#define this_cpu_read_4(pcp)		this_cpu_generic_read(pcp)
+#define this_cpu_read_4(pcp)		raw_cpu_read_4(pcp)
 #endif
 #ifndef this_cpu_read_8
-#define this_cpu_read_8(pcp)		this_cpu_generic_read(pcp)
+#define this_cpu_read_8(pcp)		raw_cpu_read_8(pcp)
 #endif

 #ifndef this_cpu_write_1
-#define this_cpu_write_1(pcp, val)	this_cpu_generic_to_op(pcp, val, =)
+#define this_cpu_write_1(pcp, val)	raw_cpu_write_1(pcp, val)
 #endif
 #ifndef this_cpu_write_2
-#define this_cpu_write_2(pcp, val)	this_cpu_generic_to_op(pcp, val, =)
+#define this_cpu_write_2(pcp, val)	raw_cpu_write_2(pcp, val)
 #endif
 #ifndef this_cpu_write_4
-#define this_cpu_write_4(pcp, val)	this_cpu_generic_to_op(pcp, val, =)
+#define this_cpu_write_4(pcp, val)	raw_cpu_write_4(pcp, val)
 #endif
 #ifndef this_cpu_write_8
-#define this_cpu_write_8(pcp, val)	this_cpu_generic_to_op(pcp, val, =)
+#define this_cpu_write_8(pcp, val)	raw_cpu_write_8(pcp, val)
 #endif

+/*
+ * this cpu rmv operations must be fully per cpu atomic.
+ */
 #ifndef this_cpu_add_1
 #define this_cpu_add_1(pcp, val)	this_cpu_generic_to_op(pcp, val, +=)
 #endif
--
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