From patchwork Mon Mar 19 08:12:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 7351 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C287723E29 for ; Mon, 19 Mar 2012 08:07:21 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 89F3BA18571 for ; Mon, 19 Mar 2012 08:07:21 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so12136902iag.11 for ; Mon, 19 Mar 2012 01:07:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-ironport-av:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-mimetrack:x-gm-message-state; bh=VGUIKdh5DKNAdF67CFm06LHbv7trBffQKPx1T4TS+1E=; b=HgAg9r7fVQ/I+kGAVsoCwbQhr8N7u5kJ71gXouqWDZ5NukRNx3ZJ2KlwwcEhfvF4/b h1ar0IiWWnmbB//jinVkZLqdZPft54f+/8yNJsUp+m1JU4GVO+rk+Ef8XoPZ9T5T/usA KQqFzTMCORilrSledxUduAPX1zCCfwA0cxaL0w1fEMrDyNLqF6C/SuT+1lmHQacxMK9a vzpv2/gTX7xDXyOLCzOsTHJJnaEoSLp1mqZTvi8UYCLcIvhqxq3taOO37XE9jCvKpJD/ yiBoPUAoGFCYx+X7ZzDtfFw4eD5mmtuwvNVWveCR8Hhl1cb/zaxos/xauQyzORDuFY8X VHWw== Received: by 10.50.153.193 with SMTP id vi1mr5361689igb.2.1332144441341; Mon, 19 Mar 2012 01:07:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.203.79 with SMTP id fh15csp66179ibb; Mon, 19 Mar 2012 01:07:20 -0700 (PDT) Received: by 10.68.73.225 with SMTP id o1mr37529978pbv.77.1332144440157; Mon, 19 Mar 2012 01:07:20 -0700 (PDT) Received: from song.cn.fujitsu.com ([222.73.24.84]) by mx.google.com with ESMTP id g9si15858024pbd.161.2012.03.19.01.07.19; Mon, 19 Mar 2012 01:07:20 -0700 (PDT) Received-SPF: neutral (google.com: 222.73.24.84 is neither permitted nor denied by best guess record for domain of laijs@cn.fujitsu.com) client-ip=222.73.24.84; Authentication-Results: mx.google.com; spf=neutral (google.com: 222.73.24.84 is neither permitted nor denied by best guess record for domain of laijs@cn.fujitsu.com) smtp.mail=laijs@cn.fujitsu.com X-IronPort-AV: E=Sophos;i="4.73,611,1325433600"; d="scan'208";a="4567342" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 19 Mar 2012 16:07:05 +0800 Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q2J87CZU031171; Mon, 19 Mar 2012 16:07:12 +0800 Received: from localhost.localdomain ([10.167.225.146]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012031916050478-1090602 ; Mon, 19 Mar 2012 16:05:04 +0800 From: Lai Jiangshan To: "Paul E. McKenney" Cc: Lai Jiangshan , 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 Message-Id: <1332144734-9375-3-git-send-email-laijs@cn.fujitsu.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1332144734-9375-1-git-send-email-laijs@cn.fujitsu.com> References: <1332144734-9375-1-git-send-email-laijs@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-03-19 16:05:04, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-03-19 16:05:07, Serialize complete at 2012-03-19 16:05:07 X-Gm-Message-State: ALoCoQk37Rh45FBIMN4XefVMI9D5rJwtzmoe4ggv68wlU4sUXBfH0Ww2DHHn6+TIx1TBMk/Ykvuf Use the value of trycount for the strategy for expedited or not in srcu. Signed-off-by: Lai Jiangshan --- 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);