From patchwork Sat Dec 3 21:06:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Triplett X-Patchwork-Id: 5444 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 934F023E0C for ; Sat, 3 Dec 2011 21:07:12 +0000 (UTC) Received: from mail-lpp01m010-f52.google.com (mail-lpp01m010-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 5E59FA18672 for ; Sat, 3 Dec 2011 21:07:12 +0000 (UTC) Received: by laah2 with SMTP id h2so2336773laa.11 for ; Sat, 03 Dec 2011 13:07:12 -0800 (PST) Received: by 10.152.105.67 with SMTP id gk3mr2213588lab.48.1322946431957; Sat, 03 Dec 2011 13:07:11 -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.152.41.198 with SMTP id h6cs197577lal; Sat, 3 Dec 2011 13:07:11 -0800 (PST) Received: by 10.229.69.205 with SMTP id a13mr749871qcj.102.1322946428782; Sat, 03 Dec 2011 13:07:08 -0800 (PST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net. [217.70.183.196]) by mx.google.com with ESMTP id hp8si6357778qab.90.2011.12.03.13.07.08; Sat, 03 Dec 2011 13:07:08 -0800 (PST) Received-SPF: neutral (google.com: 217.70.183.196 is neither permitted nor denied by best guess record for domain of josh@joshtriplett.org) client-ip=217.70.183.196; Authentication-Results: mx.google.com; spf=neutral (google.com: 217.70.183.196 is neither permitted nor denied by best guess record for domain of josh@joshtriplett.org) smtp.mail=josh@joshtriplett.org X-Originating-IP: 217.70.178.146 Received: from mfilter18-d.gandi.net (mfilter18-d.gandi.net [217.70.178.146]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 9A4EE172097; Sat, 3 Dec 2011 22:07:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter18-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter18-d.gandi.net (mfilter18-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id UrSYMTT+Shyw; Sat, 3 Dec 2011 22:07:06 +0100 (CET) X-Originating-IP: 50.43.15.19 Received: from leaf (static-50-43-15-19.bvtn.or.frontiernet.net [50.43.15.19]) (Authenticated sender: josh@joshtriplett.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 254C6172076; Sat, 3 Dec 2011 22:06:52 +0100 (CET) Date: Sat, 3 Dec 2011 13:06:50 -0800 From: Josh Triplett To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, 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" Subject: Re: [PATCH RFC tip/core/rcu 6/7] driver-core/cpu: Add cpu_is_hotpluggable() for rcutorture error analysis Message-ID: <20111203210650.GA17377@leaf> References: <20111203183417.GA18914@linux.vnet.ibm.com> <1322937282-19846-6-git-send-email-paulmck@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1322937282-19846-6-git-send-email-paulmck@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) On Sat, Dec 03, 2011 at 10:34:41AM -0800, Paul E. McKenney wrote: > The rcutorture test now can automatically exercise CPU hotplug and > collect success statistics, which can be correlated with other rcutorture > activity. This permits rcutorture to completely exercise RCU regardless > of what sort of userspace and filesystem layout is in use. Unfortunately, > rcutorture is happy to attempt to offline CPUs that cannot be offlined, > for example, CPU 0 in both the x86 and ARM architectures. Although this > allows rcutorture testing to proceed normally, it confounds attempts at > error analysis due to the resulting flood of spurious CPU-hotplug errors. > > Therefore, this commit creates a cpu_is_hotpluggable() function that > allows rcutorture to avoid attempting to offline CPUs that are not > hotpluggable, which in turn allows rcutorture to avoid reporting spurious > CPU-hotplug errors. Note that this function is EXPORT_SYMBOL_GPL() > to allow rcutorture to use it when compiled as a kernel module. > This commit also includes modifications to rcutorture to use this > new function. I'd suggest writing this as a two-patch series: add the API, then use it. I'd also suggest making the more general case for this API, beyond just rcutorture. > --- a/drivers/base/cpu.c > +++ b/drivers/base/cpu.c > @@ -23,6 +23,7 @@ struct sysdev_class cpu_sysdev_class = { > EXPORT_SYMBOL(cpu_sysdev_class); > > static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); > +static DEFINE_PER_CPU(bool, is_hotpluggable); [...] > @@ -224,8 +226,10 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) > > error = sysdev_register(&cpu->sysdev); > > - if (!error && cpu->hotpluggable) > + if (!error && cpu->hotpluggable) { > register_cpu_control(cpu); > + per_cpu(is_hotpluggable, num) = 1; > + } This information already exists in the ->hotpluggable field of "struct cpu". I'd suggest an alternate approach (included as a patch below), which avoids the need to add a new per_cpu property redundant with ->hotpluggable. Note that you can get to the patch below via "git am --scissors", or just by copy/pasting it. ---8<--- From: Josh Triplett Subject: [PATCH] driver-core/cpu: Expose hotpluggability to the rest of the kernel When architectures register CPUs, they indicate whether the CPU allows hotplugging; notably, x86 and ARM don't allow hotplugging CPU 0. Userspace can easily query the hotpluggability of a CPU via sysfs; however, the kernel has no convenient way of accessing that property in an architecture-independent way. While the kernel can simply try it and see, some code needs to distinguish between "hotplug failed" and "hotplug has no hope of working on this CPU"; for example, rcutorture's CPU hotplug tests want to avoid drowning out real hotplug failures with expected failures. Expose this property via a new cpu_is_hotpluggable function, so that the rest of the kernel can access it in an architecture-independent way. Signed-off-by: Josh Triplett --- drivers/base/cpu.c | 7 +++++++ include/linux/cpu.h | 1 + 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 251acea..3991502 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -247,6 +247,13 @@ struct sys_device *get_cpu_sysdev(unsigned cpu) } EXPORT_SYMBOL_GPL(get_cpu_sysdev); +bool cpu_is_hotpluggable(unsigned cpu) +{ + struct sys_device *dev = get_cpu_sysdev(cpu); + return dev && container_of(dev, struct cpu, sysdev)->hotpluggable; +} +EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); + int __init cpu_dev_init(void) { int err; diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 6cb60fd..305c263 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -27,6 +27,7 @@ struct cpu { extern int register_cpu(struct cpu *cpu, int num); extern struct sys_device *get_cpu_sysdev(unsigned cpu); +extern bool cpu_is_hotpluggable(unsigned cpu); extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr); extern void cpu_remove_sysdev_attr(struct sysdev_attribute *attr);