From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>,
linux-kernel@vger.kernel.org, mingo@elte.hu, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de,
peterz@infradead.org, rostedt@goodmis.org,
Valdis.Kletnieks@vt.edu, dhowells@redhat.com,
eric.dumazet@gmail.com, darren@dvhart.com, fweisbec@gmail.com,
patches@linaro.org
Subject: [PATCH 2/4 V2] rcu: use "int trycount" instead of "bool expedited"
Date: Mon, 19 Mar 2012 16:12:12 +0800 [thread overview]
Message-ID: <1332144734-9375-3-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1332144734-9375-1-git-send-email-laijs@cn.fujitsu.com>
Use the value of trycount for the strategy for expedited or not in srcu.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/srcu.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/kernel/srcu.c b/kernel/srcu.c
index 9e86ed7..2923541 100644
--- a/kernel/srcu.c
+++ b/kernel/srcu.c
@@ -251,16 +251,16 @@ EXPORT_SYMBOL_GPL(__srcu_read_unlock);
* we repeatedly block for 1-millisecond time periods. This approach
* has done well in testing, so there is no need for a config parameter.
*/
-#define SYNCHRONIZE_SRCU_READER_DELAY 5
+#define SYNCHRONIZE_SRCU_READER_DELAY 5
+#define SYNCHRONIZE_SRCU_TRYCOUNT 2
+#define SYNCHRONIZE_SRCU_EXP_TRYCOUNT 12
/*
* Wait until all the readers(which starts before this wait_idx()
* with the specified idx) complete.
*/
-static void wait_idx(struct srcu_struct *sp, int idx, bool expedited)
+static void wait_idx(struct srcu_struct *sp, int idx, int trycount)
{
- int trycount = 0;
-
/*
* SRCU read-side critical sections are normally short, so wait
* a small amount of time before possibly blocking.
@@ -268,9 +268,10 @@ static void wait_idx(struct srcu_struct *sp, int idx, bool expedited)
if (!srcu_readers_active_idx_check(sp, idx)) {
udelay(SYNCHRONIZE_SRCU_READER_DELAY);
while (!srcu_readers_active_idx_check(sp, idx)) {
- if (expedited && ++ trycount < 10)
+ if (trycount > 0) {
+ trycount--;
udelay(SYNCHRONIZE_SRCU_READER_DELAY);
- else
+ } else
schedule_timeout_interruptible(1);
}
}
@@ -284,7 +285,7 @@ static void srcu_flip(struct srcu_struct *sp)
/*
* Helper function for synchronize_srcu() and synchronize_srcu_expedited().
*/
-static void __synchronize_srcu(struct srcu_struct *sp, bool expedited)
+static void __synchronize_srcu(struct srcu_struct *sp, int trycount)
{
int busy_idx;
@@ -301,8 +302,8 @@ static void __synchronize_srcu(struct srcu_struct *sp, bool expedited)
* There are some readers start with idx=0, and some others start
* with idx=1. So two wait_idx()s are enough for synchronize:
* __synchronize_srcu() {
- * wait_idx(sp, 0, expedited);
- * wait_idx(sp, 1, expedited);
+ * wait_idx(sp, 0, trycount);
+ * wait_idx(sp, 1, trycount);
* }
* When it returns, all started readers have complete.
*
@@ -331,7 +332,7 @@ static void __synchronize_srcu(struct srcu_struct *sp, bool expedited)
* Because this probability is not high, wait_idx()
* will normally not need to wait.
*/
- wait_idx(sp, 1 - busy_idx, expedited);
+ wait_idx(sp, 1 - busy_idx, trycount);
/* flip the index to ensure the return of the next wait_idx() */
srcu_flip(sp);
@@ -339,7 +340,7 @@ static void __synchronize_srcu(struct srcu_struct *sp, bool expedited)
/*
* Now that wait_idx() has waited for the really old readers.
*/
- wait_idx(sp, busy_idx, expedited);
+ wait_idx(sp, busy_idx, trycount);
mutex_unlock(&sp->mutex);
}
@@ -360,7 +361,7 @@ static void __synchronize_srcu(struct srcu_struct *sp, bool expedited)
*/
void synchronize_srcu(struct srcu_struct *sp)
{
- __synchronize_srcu(sp, 0);
+ __synchronize_srcu(sp, SYNCHRONIZE_SRCU_TRYCOUNT);
}
EXPORT_SYMBOL_GPL(synchronize_srcu);
@@ -381,7 +382,7 @@ EXPORT_SYMBOL_GPL(synchronize_srcu);
*/
void synchronize_srcu_expedited(struct srcu_struct *sp)
{
- __synchronize_srcu(sp, 1);
+ __synchronize_srcu(sp, SYNCHRONIZE_SRCU_EXP_TRYCOUNT);
}
EXPORT_SYMBOL_GPL(synchronize_srcu_expedited);
--
1.7.4.4
next prev parent reply other threads:[~2012-03-19 8:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 8:12 [PATCH 0/4 V2] rcu: implement call_srcu() Lai Jiangshan
2012-03-19 8:12 ` [PATCH 1/4 V2] rcu: fix srcu_readers_active() Lai Jiangshan
2012-03-19 8:12 ` Lai Jiangshan [this message]
2012-03-19 8:12 ` [PATCH 3/4 V2] implement per-domain single-thread state machine call_srcu() Lai Jiangshan
2012-04-10 23:18 ` Paul E. McKenney
2012-04-11 12:27 ` Paul E. McKenney
2012-04-14 13:22 ` Peter Zijlstra
2012-04-14 15:26 ` Paul E. McKenney
2012-03-19 8:12 ` [PATCH 4/4 V2] add srcu torture test Lai Jiangshan
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=1332144734-9375-3-git-send-email-laijs@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=fweisbec@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=patches@linaro.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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®