From: Christoph Lameter <cl@linux.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Subject: Re: [GIT PULL] ring-buffer: Replace this_cpu_*() with __this_cpu_*()
Date: Tue, 24 Mar 2015 14:37:43 -0500 (CDT) [thread overview]
Message-ID: <alpine.DEB.2.11.1503241411080.610@gentwo.org> (raw)
In-Reply-To: <alpine.DEB.2.11.1503241343470.32546@gentwo.org>
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@linux.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
next prev parent reply other threads:[~2015-03-24 19:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 22:02 [GIT PULL] ring-buffer: Replace this_cpu_*() with __this_cpu_*() Steven Rostedt
2015-03-19 22:16 ` Linus Torvalds
2015-03-19 22:34 ` Steven Rostedt
2015-03-19 22:42 ` Steven Rostedt
2015-05-19 15:35 ` Christoph Lameter
2015-05-19 15:42 ` Steven Rostedt
2015-05-19 16:20 ` Christoph Lameter
2015-03-23 17:48 ` Steven Rostedt
2015-03-24 18:47 ` Christoph Lameter
2015-03-24 19:37 ` Christoph Lameter [this message]
2015-05-18 19:50 ` Linus Torvalds
2015-05-18 20:40 ` Steven Rostedt
2015-03-20 7:26 ` Uwe Kleine-König
2015-03-20 11:55 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.11.1503241411080.610@gentwo.org \
--to=cl@linux.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox