From patchwork Tue Mar 6 09:57:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 7106 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 C3D6923E64 for ; Tue, 6 Mar 2012 09:53:16 +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 8E1ADA182F9 for ; Tue, 6 Mar 2012 09:53:16 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so9163325iag.11 for ; Tue, 06 Mar 2012 01:53:16 -0800 (PST) Received: from mr.google.com ([10.42.147.199]) by 10.42.147.199 with SMTP id o7mr15788010icv.50.1331027596365 (num_hops = 1); Tue, 06 Mar 2012 01:53:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.147.199 with SMTP id o7mr12988392icv.50.1331027596300; Tue, 06 Mar 2012 01:53:16 -0800 (PST) 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.53.18 with SMTP id k18csp52107ibg; Tue, 6 Mar 2012 01:53:16 -0800 (PST) Received: by 10.50.95.195 with SMTP id dm3mr8432615igb.9.1331027595903; Tue, 06 Mar 2012 01:53:15 -0800 (PST) Received: from song.cn.fujitsu.com ([222.73.24.84]) by mx.google.com with ESMTP id l7si24145400pbd.320.2012.03.06.01.53.14; Tue, 06 Mar 2012 01:53:15 -0800 (PST) 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,539,1325433600"; d="scan'208";a="4464392" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 06 Mar 2012 17:53:10 +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 q269rBRf019495; Tue, 6 Mar 2012 17:53:11 +0800 Received: from localhost.localdomain ([10.167.225.146]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012030617511684-893320 ; Tue, 6 Mar 2012 17:51:16 +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 4/6] remove flip_idx_and_wait() Date: Tue, 6 Mar 2012 17:57:36 +0800 Message-Id: <1331027858-7648-4-git-send-email-laijs@cn.fujitsu.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1331027858-7648-1-git-send-email-laijs@cn.fujitsu.com> References: <1331023359-6987-1-git-send-email-laijs@cn.fujitsu.com> <1331027858-7648-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-06 17:51:16, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-03-06 17:51:20, Serialize complete at 2012-03-06 17:51:20 X-Gm-Message-State: ALoCoQmDPk9NnwpBw7gJL4PsIqcvUFpiFQX/OC8S87MA3b2lcceKXzVNcnPD1Lx4VTHWl213kICi flip and check are the basic steps of gp. call them directly. Signed-off-by: Lai Jiangshan --- kernel/srcu.c | 35 +++++++++++++++++------------------ 1 files changed, 17 insertions(+), 18 deletions(-) diff --git a/kernel/srcu.c b/kernel/srcu.c index d5f3450..d101ed5 100644 --- a/kernel/srcu.c +++ b/kernel/srcu.c @@ -300,23 +300,12 @@ static void wait_idx(struct srcu_struct *sp, int idx, int trycount) } /* - * Flip the readers' index by incrementing ->completed, then wait - * until there are no more readers using the counters referenced by - * the old index value. (Recall that the index is the bottom bit - * of ->completed.) - * - * Of course, it is possible that a reader might be delayed for the - * full duration of flip_idx_and_wait() between fetching the - * index and incrementing its counter. This possibility is handled - * by the next __synchronize_srcu() invoking wait_idx() for such readers - * before starting a new grace period. + * Flip the readers' index by incrementing ->completed, then new + * readers will use counters referenced on new index value. */ -static void flip_idx_and_wait(struct srcu_struct *sp, int trycount) +static void srcu_flip(struct srcu_struct *sp) { - int idx; - - idx = sp->completed++ & 0x1; - wait_idx(sp, idx, trycount); + ACCESS_ONCE(sp->completed)++; } /* @@ -362,10 +351,20 @@ static void __synchronize_srcu(struct srcu_struct *sp, int trycount) /* * Now that wait_idx() has waited for the really old readers, - * invoke flip_idx_and_wait() to flip the counter and wait - * for current SRCU readers. + * + * Flip the readers' index by incrementing ->completed, then wait + * until there are no more readers using the counters referenced by + * the old index value. (Recall that the index is the bottom bit + * of ->completed.) + * + * Of course, it is possible that a reader might be delayed for the + * full duration of flip_idx_and_wait() between fetching the + * index and incrementing its counter. This possibility is handled + * by the next __synchronize_srcu() invoking wait_idx() for such + * readers before starting a new grace period. */ - flip_idx_and_wait(sp, trycount); + srcu_flip(sp); + wait_idx(sp, (sp->completed - 1) & 0x1, trycount); mutex_unlock(&sp->mutex); }