From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuanhan Liu <yuanhan.liu@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 1/3] wait: introduce wait_event_cmd_exclusive
Date: Mon, 27 Apr 2015 12:51:01 +0800 [thread overview]
Message-ID: <1430110263-23977-1-git-send-email-yuanhan.liu@linux.intel.com> (raw)
It's just a variant of wait_event_cmd, with exclusive flag being set.
For cases like RAID5, which puts many processes to sleep until 1/4
resources are free, a wake_up wakes up all processes to run, but
there is one process being able to get the resource as it's protected
by a spin lock. That ends up introducing heavy lock contentions, and
hurts performance badly.
Here introduce wait_event_cmd_exclusive to relieve the lock contention
naturally by letting wake_up() just wake up one process.
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
include/linux/wait.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2db8334..6c3b4de 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -358,10 +358,18 @@ do { \
__ret; \
})
-#define __wait_event_cmd(wq, condition, cmd1, cmd2) \
- (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
+#define __wait_event_cmd(wq, condition, cmd1, cmd2, exclusive) \
+ (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, exclusive, 0, \
cmd1; schedule(); cmd2)
+
+#define wait_event_cmd_exclusive(wq, condition, cmd1, cmd2) \
+do { \
+ if (condition) \
+ break; \
+ __wait_event_cmd(wq, condition, cmd1, cmd2, 1); \
+} while (0)
+
/**
* wait_event_cmd - sleep until a condition gets true
* @wq: the waitqueue to wait on
@@ -380,7 +388,7 @@ do { \
do { \
if (condition) \
break; \
- __wait_event_cmd(wq, condition, cmd1, cmd2); \
+ __wait_event_cmd(wq, condition, cmd1, cmd2, 0); \
} while (0)
#define __wait_event_interruptible(wq, condition) \
--
1.9.0
next reply other threads:[~2015-04-27 4:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 4:51 Yuanhan Liu [this message]
2015-04-27 4:51 ` [PATCH 2/3 v2] md/raid5: split wait_for_stripe and introduce wait_for_quiescent Yuanhan Liu
2015-04-27 4:51 ` [PATCH 3/3 v2] md/raid5: per hash value and exclusive wait_for_stripe Yuanhan Liu
2015-04-28 14:13 ` [PATCH 1/3] wait: introduce wait_event_cmd_exclusive Peter Zijlstra
2015-04-29 1:45 ` Yuanhan Liu
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=1430110263-23977-1-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=neilb@suse.de \
--cc=peterz@infradead.org \
/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