Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031469AbbD2Bnt (ORCPT ); Tue, 28 Apr 2015 21:43:49 -0400 Received: from mga02.intel.com ([134.134.136.20]:22236 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031323AbbD2Bns (ORCPT ); Tue, 28 Apr 2015 21:43:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,668,1422950400"; d="scan'208";a="687185302" Date: Wed, 29 Apr 2015 09:45:14 +0800 From: Yuanhan Liu To: Peter Zijlstra Cc: neilb@suse.de, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH 1/3] wait: introduce wait_event_cmd_exclusive Message-ID: <20150429014514.GR17176@yliu-dev.sh.intel.com> References: <1430110263-23977-1-git-send-email-yuanhan.liu@linux.intel.com> <20150428141315.GD23123@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150428141315.GD23123@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2450 Lines: 66 On Tue, Apr 28, 2015 at 04:13:15PM +0200, Peter Zijlstra wrote: > On Mon, Apr 27, 2015 at 12:51:01PM +0800, Yuanhan Liu wrote: > > 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 > > Cc: Peter Zijlstra > > Signed-off-by: Yuanhan Liu > > --- > > 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) > > > > No, that's wrong, its assumed that wait*() and __wait*() have the same > arguments. Thanks. Will send an updated patch soon. --yliu -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/