From patchwork Fri Jun 22 15:35:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 9572 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 755A223E55 for ; Fri, 22 Jun 2012 15:36:15 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 467BDA188F9 for ; Fri, 22 Jun 2012 15:36:15 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so1758023ghb.11 for ; Fri, 22 Jun 2012 08:36:15 -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:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=PKQ2p7tJbcI7in77Gh9a2FgS8auNHFZNVs9X7PxS3mM=; b=OTwFTizgt/0qGsUcL/sD/erBLW4yrVqSrz/wuI6XNXYf9TsdSkbetxq4D/POr/tSXQ Qrkg172TUvQmIV/TO3KskXVayPpu0ZlQVgO3HtjxIf/xC269rgTzFWdye9qu6ZnyPlHk AD2dW4ZPiYLfHy38UzN1Epcr/ap7QWdVvGN19LLXsFDTYeJZHqA/YlO7K4qTWwJdDOtD KjN3ufvH6VtgpviYMa4VNCVMVu6i/ZLV9esEqHnRihJfI7I4AJ3uRKkp8KKyJRD5ZqZ5 36knq7nQc4AyvZxJpWapr7p1mvv4LsvJtLgshY5tyM/bZ1d7nIaj8mzu0emcrk/I+ZH0 y0IQ== Received: by 10.50.57.167 with SMTP id j7mr2133179igq.53.1340379374816; Fri, 22 Jun 2012 08:36:14 -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.24.148 with SMTP id v20csp72390ibb; Fri, 22 Jun 2012 08:36:14 -0700 (PDT) Received: by 10.50.154.201 with SMTP id vq9mr2176732igb.2.1340379374345; Fri, 22 Jun 2012 08:36:14 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id nf5si6432793icb.89.2012.06.22.08.36.14 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jun 2012 08:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.139 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Jun 2012 11:36:13 -0400 Received: from d01dlp02.pok.ibm.com (9.56.224.85) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 22 Jun 2012 11:36:11 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 05A056E8063 for ; Fri, 22 Jun 2012 11:36:10 -0400 (EDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5MFa8v410158236 for ; Fri, 22 Jun 2012 11:36:09 -0400 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5MFZGPZ023464 for ; Fri, 22 Jun 2012 09:35:19 -0600 Received: from paulmck-ThinkPad-W500 ([9.47.24.152]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5MFZGeP023352; Fri, 22 Jun 2012 09:35:16 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id A7FA8E71A0; Fri, 22 Jun 2012 08:35:15 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, 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, sbw@mit.edu, patches@linaro.org, "Paul E. McKenney" Subject: [PATCH tip/core/rcu 16/17] rcu: Disable preemption in rcu_blocking_is_gp() Date: Fri, 22 Jun 2012 08:35:11 -0700 Message-Id: <1340379312-6684-16-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1340379312-6684-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20120622153501.GA6626@linux.vnet.ibm.com> <1340379312-6684-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12062215-7182-0000-0000-000001D2BDFB X-Gm-Message-State: ALoCoQke+3oTacdiCoYtk1nJO5JdSoJeDZQhybk67xEXheThsnn6FiD3/IdQKKIsy1vdvz7s/FUs From: "Paul E. McKenney" It is time to optimize CONFIG_TREE_PREEMPT_RCU's synchronize_rcu() for uniprocessor optimization, which means that rcu_blocking_is_gp() can no longer rely on RCU read-side critical sections having disabled preemption. This commit therefore disables preemption across rcu_blocking_is_gp()'s scan of the cpu_online_mask. Signed-off-by: Paul E. McKenney --- kernel/rcutree.c | 19 ++----------------- 1 files changed, 2 insertions(+), 17 deletions(-) diff --git a/kernel/rcutree.c b/kernel/rcutree.c index ce175b6..c0cc41f 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c @@ -1978,28 +1978,13 @@ EXPORT_SYMBOL_GPL(call_rcu_bh); * occasionally incorrectly indicate that there are multiple CPUs online * when there was in fact only one the whole time, as this just adds * some overhead: RCU still operates correctly. - * - * Of course, sampling num_online_cpus() with preemption enabled can - * give erroneous results if there are concurrent CPU-hotplug operations. - * For example, given a demonic sequence of preemptions in num_online_cpus() - * and CPU-hotplug operations, there could be two or more CPUs online at - * all times, but num_online_cpus() might well return one (or even zero). - * - * However, all such demonic sequences require at least one CPU-offline - * operation. Furthermore, rcu_blocking_is_gp() giving the wrong answer - * is only a problem if there is an RCU read-side critical section executing - * throughout. But RCU-sched and RCU-bh read-side critical sections - * disable either preemption or bh, which prevents a CPU from going offline. - * Therefore, the only way that rcu_blocking_is_gp() can incorrectly return - * that there is only one CPU when in fact there was more than one throughout - * is when there were no RCU readers in the system. If there are no - * RCU readers, the grace period by definition can be of zero length, - * regardless of the number of online CPUs. */ static inline int rcu_blocking_is_gp(void) { might_sleep(); /* Check for RCU read-side critical section. */ + preempt_disable(); return num_online_cpus() <= 1; + preempt_enable(); } /**