From patchwork Sat Dec 3 18:34:41 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: 5443 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 DA43423E03 for ; Sat, 3 Dec 2011 18:35:27 +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 C082BA182CB for ; Sat, 3 Dec 2011 18:35:27 +0000 (UTC) Received: by mail-lpp01m010-f52.google.com with SMTP id h2so2304486laa.11 for ; Sat, 03 Dec 2011 10:35:27 -0800 (PST) Received: by 10.152.145.233 with SMTP id sx9mr2059208lab.6.1322937327503; Sat, 03 Dec 2011 10:35:27 -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 h6cs193923lal; Sat, 3 Dec 2011 10:35:27 -0800 (PST) Received: by 10.50.169.33 with SMTP id ab1mr3896692igc.0.1322937325197; Sat, 03 Dec 2011 10:35:25 -0800 (PST) Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com. [32.97.182.137]) by mx.google.com with ESMTPS id g10si7212466icw.90.2011.12.03.10.35.24 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Dec 2011 10:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.137 as permitted sender) client-ip=32.97.182.137; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.137 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 3 Dec 2011 13:35:24 -0500 Received: from d01relay07.pok.ibm.com (9.56.227.147) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 3 Dec 2011 13:34:50 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB3IYnl93334148; Sat, 3 Dec 2011 13:34:49 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB3IYlbg019868; Sat, 3 Dec 2011 13:34:49 -0500 Received: from paulmck-ThinkPad-W500 (sig-9-65-206-211.mts.ibm.com [9.65.206.211]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pB3IYk8G019806; Sat, 3 Dec 2011 13:34:46 -0500 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 1A4ABEAA08; Sat, 3 Dec 2011 10:34:44 -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 6/7] driver-core/cpu: Add cpu_is_hotpluggable() for rcutorture error analysis Date: Sat, 3 Dec 2011 10:34:41 -0800 Message-Id: <1322937282-19846-6-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <20111203183417.GA18914@linux.vnet.ibm.com> References: <20111203183417.GA18914@linux.vnet.ibm.com> x-cbid: 11120318-5806-0000-0000-0000103C567C From: Paul E. McKenney 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. Suggested-by: Josh Triplett Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney --- drivers/base/cpu.c | 12 +++++++++++- include/linux/cpu.h | 1 + kernel/rcutorture.c | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 251acea..17f9b58 100644 --- 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); #ifdef CONFIG_HOTPLUG_CPU static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr, @@ -76,6 +77,7 @@ void unregister_cpu(struct cpu *cpu) sysdev_unregister(&cpu->sysdev); per_cpu(cpu_sys_devices, logical_cpu) = NULL; + per_cpu(is_hotpluggable, logical_cpu) = 0; return; } @@ -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; + } if (!error) per_cpu(cpu_sys_devices, num) = &cpu->sysdev; if (!error) @@ -238,6 +242,12 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) return error; } +bool cpu_is_hotpluggable(int num) +{ + return per_cpu(is_hotpluggable, num); +} +EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); + struct sys_device *get_cpu_sysdev(unsigned cpu) { if (cpu < nr_cpu_ids && cpu_possible(cpu)) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 6cb60fd..be140ef 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -26,6 +26,7 @@ struct cpu { }; extern int register_cpu(struct cpu *cpu, int num); +extern bool cpu_is_hotpluggable(int num); extern struct sys_device *get_cpu_sysdev(unsigned cpu); extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr); diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index 1e422ae..186ead9 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c @@ -1388,7 +1388,7 @@ rcu_torture_onoff(void *arg) WARN_ON(maxcpu < 0); while (!kthread_should_stop()) { cpu = (rcu_random(&rand) >> 4) % (maxcpu + 1); - if (cpu_online(cpu)) { + if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "rcu_torture_onoff task: offlining %d\n", @@ -1402,7 +1402,7 @@ rcu_torture_onoff(void *arg) torture_type, cpu); n_offline_successes++; } - } else { + } else if (cpu_is_hotpluggable(cpu)) { if (verbose) printk(KERN_ALERT "%s" TORTURE_FLAG "rcu_torture_onoff task: onlining %d\n",