aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuanhan Liu <yuanhan.liu@linux.intel.com>2015-05-08 04:19:05 -0400
committerNeilBrown <neilb@suse.de>2015-06-16 20:00:14 -0400
commit9f3520c3115b451ac1301779fc3c769d94907a70 (patch)
tree32aa25027053b7b97f741015573eda1df59ba28a
parent4c9309c0cce96ea93be638dd243616e56e4bfe7d (diff)
wait: introduce wait_event_exclusive_cmd
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_exclusive_cmd 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> v2: its assumed that wait*() and __wait*() have the same arguments - peterz Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--include/linux/wait.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2db83349865b..db78c7204947 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -358,6 +358,19 @@ do { \
358 __ret; \ 358 __ret; \
359}) 359})
360 360
361#define __wait_event_exclusive_cmd(wq, condition, cmd1, cmd2) \
362 (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 1, 0, \
363 cmd1; schedule(); cmd2)
364/*
365 * Just like wait_event_cmd(), except it sets exclusive flag
366 */
367#define wait_event_exclusive_cmd(wq, condition, cmd1, cmd2) \
368do { \
369 if (condition) \
370 break; \
371 __wait_event_exclusive_cmd(wq, condition, cmd1, cmd2); \
372} while (0)
373
361#define __wait_event_cmd(wq, condition, cmd1, cmd2) \ 374#define __wait_event_cmd(wq, condition, cmd1, cmd2) \
362 (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ 375 (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
363 cmd1; schedule(); cmd2) 376 cmd1; schedule(); cmd2)