From patchwork Tue Dec 13 00:42:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5610 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 D8B8323E0C for ; Tue, 13 Dec 2011 00:42:37 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id C0400A184C7 for ; Tue, 13 Dec 2011 00:42:37 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 17so8350001bke.11 for ; Mon, 12 Dec 2011 16:42:37 -0800 (PST) Received: by 10.204.157.12 with SMTP id z12mr8483759bkw.18.1323736957489; Mon, 12 Dec 2011 16:42:37 -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.205.129.2 with SMTP id hg2cs64405bkc; Mon, 12 Dec 2011 16:42:37 -0800 (PST) Received: by 10.68.201.136 with SMTP id ka8mr38401441pbc.1.1323736955218; Mon, 12 Dec 2011 16:42:35 -0800 (PST) Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com. [32.97.182.145]) by mx.google.com with ESMTPS id j7si85098pbd.87.2011.12.12.16.42.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Dec 2011 16:42:35 -0800 (PST) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.145 as permitted sender) client-ip=32.97.182.145; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.145 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Dec 2011 19:42:33 -0500 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e5.ny.us.ibm.com (192.168.1.105) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Dec 2011 19:42:31 -0500 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBD0gU2n325346; Mon, 12 Dec 2011 19:42:30 -0500 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 pBD0gQcC018573; Mon, 12 Dec 2011 17:42:29 -0700 Received: from paulmck-ThinkPad-W500 ([9.47.24.246]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBD0gQ2x018553; Mon, 12 Dec 2011 17:42:26 -0700 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id D6B6CE5188; Mon, 12 Dec 2011 16:42:25 -0800 (PST) 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, patches@linaro.org, "Paul E. McKenney" , "Paul E. McKenney" Subject: [PATCH RFC tip/core/rcu 5/6] rcu: Apply ACCESS_ONCE() to rcu_boost() return value Date: Mon, 12 Dec 2011 16:42:23 -0800 Message-Id: <1323736944-32575-5-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1323736944-32575-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20111213004144.GA32120@linux.vnet.ibm.com> <1323736944-32575-1-git-send-email-paulmck@linux.vnet.ibm.com> x-cbid: 11121300-5930-0000-0000-0000031E1BEC From: "Paul E. McKenney" Both TINY_RCU's and TREE_RCU's implementations of rcu_boost() access the ->boost_tasks and ->exp_tasks fields without preventing concurrent changes to these fields. This commit therefore applies ACCESS_ONCE in order to prevent compiler mischief. Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney --- kernel/rcutiny_plugin.h | 4 ++-- kernel/rcutree_plugin.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h index dfa97cb..9cb1ae4 100644 --- a/kernel/rcutiny_plugin.h +++ b/kernel/rcutiny_plugin.h @@ -312,8 +312,8 @@ static int rcu_boost(void) rt_mutex_lock(&mtx); rt_mutex_unlock(&mtx); /* Keep lockdep happy. */ - return rcu_preempt_ctrlblk.boost_tasks != NULL || - rcu_preempt_ctrlblk.exp_tasks != NULL; + return ACCESS_ONCE(rcu_preempt_ctrlblk.boost_tasks) != NULL || + ACCESS_ONCE(rcu_preempt_ctrlblk.exp_tasks) != NULL; } /* diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index f55f10b..8bb35d7 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h @@ -1232,7 +1232,8 @@ static int rcu_boost(struct rcu_node *rnp) rt_mutex_lock(&mtx); /* Side effect: boosts task t's priority. */ rt_mutex_unlock(&mtx); /* Keep lockdep happy. */ - return rnp->exp_tasks != NULL || rnp->boost_tasks != NULL; + return ACCESS_ONCE(rnp->exp_tasks) != NULL || + ACCESS_ONCE(rnp->boost_tasks) != NULL; } /*