mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
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.mckenney@linaro.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
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	[thread overview]
Message-ID: <1322937282-19846-6-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111203183417.GA18914@linux.vnet.ibm.com>

From: Paul E. McKenney <paul.mckenney@linaro.org>

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 <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 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",
-- 
1.7.3.2


  parent reply	other threads:[~2011-12-03 18:35 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03 18:34 [PATCH tip/core/rcu 0/7] Preview of fourth set of RCU changes for 3.3 Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 1/7] rcu: Don't check irq nesting from rcu idle entry/exit Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 2/7] rcu: Irq nesting is always 0 on rcu_enter_idle_common Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 3/7] rcu: Keep invoking callbacks if CPU otherwise idle Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 4/7] rcu: Adaptive dyntick-idle preparation Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 5/7] rcu: remove redundant rcu_cpu_stall_suppress declaration Paul E. McKenney
2011-12-03 18:34 ` Paul E. McKenney [this message]
2011-12-03 21:06   ` [PATCH RFC tip/core/rcu 6/7] driver-core/cpu: Add cpu_is_hotpluggable() for rcutorture error analysis Josh Triplett
2011-12-03 23:14     ` Paul E. McKenney
2011-12-03 18:34 ` [PATCH RFC tip/core/rcu 7/7] rcu: Quiet RCU-lockdep warnings involving interrupt disabling Paul E. McKenney
2011-12-05  9:19   ` Yong Zhang
2011-12-05 16:45     ` Paul E. McKenney
2011-12-06  1:26       ` Yong Zhang
2011-12-06  2:12         ` Paul E. McKenney
2011-12-06  3:27           ` [PATCH 1/3] kernel.h: sched: introduce might_sleep_disabled() Yong Zhang
2011-12-06  3:28           ` [PATCH 2/3] rtmutex: introduce rt_mutex_lock_irqdisabled() Yong Zhang
2011-12-06  3:29           ` [PATCH 3/3] rcu: use rt_mutex_lock_irqdisabled() in rcu_boost() Yong Zhang
2011-12-06  9:52         ` [PATCH RFC tip/core/rcu 7/7] rcu: Quiet RCU-lockdep warnings involving interrupt disabling Peter Zijlstra
2011-12-06 10:05           ` Yong Zhang
2011-12-06 10:32             ` Peter Zijlstra
2011-12-06 12:26               ` Steven Rostedt
2011-12-06 16:04                 ` Paul E. McKenney
2011-12-06 16:33                   ` Paul E. McKenney
2011-12-06 16:56                   ` Steven Rostedt
2011-12-06 17:16                     ` Paul E. McKenney
2011-12-06 10:27           ` Peter Zijlstra
2011-12-06 16:11             ` Paul E. McKenney
2011-12-06 16:14               ` Peter Zijlstra
2011-12-06 16:01           ` Paul E. McKenney
2011-12-05  9:41   ` Peter Zijlstra
2011-12-05 10:03     ` Yong Zhang
2011-12-05 16:48       ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322937282-19846-6-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=darren@dvhart.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=eric.dumazet@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=niv@us.ibm.com \
    --cc=patches@linaro.org \
    --cc=paul.mckenney@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®