From patchwork Thu Jun 27 19:56:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 255175 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7048E2C0F93 for ; Fri, 28 Jun 2013 06:08:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754813Ab3F0UAK (ORCPT ); Thu, 27 Jun 2013 16:00:10 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:33739 "EHLO e28smtp05.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754781Ab3F0UAG (ORCPT ); Thu, 27 Jun 2013 16:00:06 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2013 01:24:57 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp05.in.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Jun 2013 01:24:54 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 7EE23E0055; Fri, 28 Jun 2013 01:29:34 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5RJxulF26738900; Fri, 28 Jun 2013 01:29:56 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5RJxuHE010705; Fri, 28 Jun 2013 05:59:59 +1000 Received: from srivatsabhat.in.ibm.com ([9.79.209.72]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r5RJxt3S010668; Fri, 28 Jun 2013 05:59:55 +1000 From: "Srivatsa S. Bhat" Subject: [PATCH v3 23/45] percpu_counter: Use _nocheck version of for_each_online_cpu() To: tglx@linutronix.de, peterz@infradead.org, tj@kernel.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com Cc: rostedt@goodmis.org, wangyun@linux.vnet.ibm.com, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, fweisbec@gmail.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro , Tejun Heo , "Srivatsa S. Bhat" Date: Fri, 28 Jun 2013 01:26:41 +0530 Message-ID: <20130627195641.29830.18825.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13062719-8256-0000-0000-0000081CBDD4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The percpu-counter-sum code does a for_each_online_cpu() protected by a spinlock, which makes it look like it needs to use get/put_online_cpus_atomic(), going forward. However, the code has adequate synchronization with CPU hotplug, via a hotplug callback and the fbc->lock. So use for_each_online_cpu_nocheck() to avoid false-positive warnings from the hotplug locking validator. And add a comment justifying the same. Cc: Al Viro Cc: Tejun Heo Signed-off-by: Srivatsa S. Bhat --- lib/percpu_counter.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index ba6085d..2d80e8a 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c @@ -98,9 +98,16 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc) s64 ret; int cpu; + /* + * CPU hotplug synchronization is explicitly handled via the + * hotplug callback, which synchronizes through fbc->lock. + * So it is safe to use the _nocheck() version of + * for_each_online_cpu() here (to avoid false-positive warnings + * from the CPU hotplug debug code). + */ raw_spin_lock(&fbc->lock); ret = fbc->count; - for_each_online_cpu(cpu) { + for_each_online_cpu_nocheck(cpu) { s32 *pcount = per_cpu_ptr(fbc->counters, cpu); ret += *pcount; }