From: Joe Korty <joe.korty@ccur.com>
To: paulmck@linux.vnet.ibm.com
Cc: fweisbec@gmail.com, peterz@infradead.org, laijs@cn.fujitsu.com,
mathieu.desnoyers@efficios.com, dhowells@redhat.com,
loic.minier@linaro.org, dhaval.giani@gmail.com,
tglx@linutronix.de, josh@joshtriplett.org,
houston.jim@comcast.net, andi@firstfloor.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 7/9] jrcu: support lazy / not-lazy end-of-batch recognition
Date: Sun, 13 Mar 2011 23:50:44 -0400 [thread overview]
Message-ID: <20110314035044.GA12983@tsunami.ccur.com> (raw)
jrcu: make lazy/not-lazy end-of-batch recognition a config option.
Some mb() are not needed for correct operation, they just make JRCU
recognize end-of-batch at the earliest possible moment. Mark those
semi-optional mb's with an #ifdef.
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Index: b/init/Kconfig
===================================================================
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -434,6 +434,23 @@ config JRCU_DAEMON
Required. The context switch when leaving the daemon is needed
to get the CPU to reliably participate in end-of-batch processing.
+config JRCU_LAZY
+ bool "Should JRCU be lazy recognizing end-of-batch"
+ depends on JRCU
+ default n
+ help
+ If you say Y here, JRCU will on occasion fail to recognize
+ end-of-batch for an rcu period or two.
+
+ If you say N here, JRCU will be more aggressive; in fact it
+ will always recognize end-of-batch at the earliest possible time.
+
+ Being lazy should be fractionally more efficient in that JRCU
+ inserts fewer memory barriers along some high performance kernel
+ code paths.
+
+ If unsure, say N.
+
config PREEMPT_COUNT_CPU
# bool "Let one CPU look at another CPUs preemption count"
bool
Index: b/include/linux/preempt.h
===================================================================
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -10,12 +10,36 @@
#include <linux/linkage.h>
#include <linux/list.h>
+/* cannot include rcupdate.h here, so open-code this */
+
+#if defined(CONFIG_JRCU)
+# define __add_preempt_count(val) do { \
+ int newval = (preempt_count() += (val)); \
+ if (newval == (val)) \
+ smp_wmb(); \
+} while (0)
+#else
+# define __add_preempt_count(val) do { preempt_count() += (val); } while (0)
+#endif
+
+#if defined(CONFIG_JRCU_LAZY) || !defined(CONFIG_JRCU)
+# define __sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
+#else
+# define __sub_preempt_count(val) do { \
+ int newval = (preempt_count() -= (val)); \
+ if (newval == 0) { \
+ /* race with preemption OK, preempt will do the mb for us */ \
+ smp_wmb(); \
+ } \
+} while (0)
+#endif
+
#if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER)
extern void add_preempt_count(int val);
extern void sub_preempt_count(int val);
#else
-# define add_preempt_count(val) do { preempt_count() += (val); } while (0)
-# define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
+# define add_preempt_count(val) __add_preempt_count(val)
+# define sub_preempt_count(val) __sub_preempt_count(val)
#endif
#define inc_preempt_count() add_preempt_count(1)
Index: b/kernel/jrcu.c
===================================================================
--- a/kernel/jrcu.c
+++ b/kernel/jrcu.c
@@ -154,9 +154,7 @@ static inline void rcu_eob(int cpu)
struct rcu_data *rd = &rcu_data[cpu];
if (unlikely(rd->wait)) {
rd->wait = 0;
-#ifdef CONFIG_RCU_PARANOID
- /* not needed, we can tolerate some fuzziness on exactly
- * when other CPUs see the above write insn. */
+#ifndef CONFIG_JRCU_LAZY
smp_wmb();
#endif
}
Index: b/kernel/sched.c
===================================================================
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3829,7 +3829,7 @@ void __kprobes add_preempt_count(int val
if (DEBUG_LOCKS_WARN_ON((preempt_count() < 0)))
return;
#endif
- preempt_count() += val;
+ __add_preempt_count(val);
#ifdef CONFIG_DEBUG_PREEMPT
/*
* Spinlock count overflowing soon?
@@ -3860,7 +3860,7 @@ void __kprobes sub_preempt_count(int val
if (preempt_count() == val)
trace_preempt_on(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
- preempt_count() -= val;
+ __sub_preempt_count(val);
}
EXPORT_SYMBOL(sub_preempt_count);
reply other threads:[~2011-03-14 3:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20110314035044.GA12983@tsunami.ccur.com \
--to=joe.korty@ccur.com \
--cc=andi@firstfloor.org \
--cc=dhaval.giani@gmail.com \
--cc=dhowells@redhat.com \
--cc=fweisbec@gmail.com \
--cc=houston.jim@comcast.net \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.minier@linaro.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.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
all inboxes | Powered by JetHome®