From: Pekka Paalanen <pq@iki.fi>
To: Ingo Molnar <mingo@elte.hu>
Cc: Pekka Paalanen <pq@iki.fi>, Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Subject: [PATCH v2] x86 mmiotrace: dynamically disable non-boot CPUs
Date: Thu, 24 Apr 2008 22:39:47 +0300 [thread overview]
Message-ID: <20080424223947.55c053f6@daedalus.pq.iki.fi> (raw)
In-Reply-To: <20080413230552.33ca587a@daedalus.pq.iki.fi>
>From 8979ee55cb6a429c4edd72ebec2244b849f6a79a Mon Sep 17 00:00:00 2001
From: Pekka Paalanen <pq@iki.fi>
Date: Sat, 12 Apr 2008 00:18:57 +0300
Subject: [PATCH] x86 mmiotrace: dynamically disable non-boot CPUs
Mmiotrace is not reliable with multiple CPUs and may
miss events. Drop to single CPU when mmiotrace is activated.
Signed-off-by: Pekka Paalanen <pq@iki.fi>
---
I've tested this patch on my Core 2 Duo laptop, and with
"[PATCH v2] Check for breakpoint in text_poke to eliminate bug_on"
cpu hotplug seems to work fine on a sched-devel/latest SMP kernel
both with and without CONFIG_HOTPLUG_CPU.
One strange thing was a stack trace printed just before the CPU resets
for "shutdown -r now", but I could not see what it was about. I'll ignore
that for now, hopefully it's something unrelated.
arch/x86/mm/mmio-mod.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
index 6d6cac8..1f77d85 100644
--- a/arch/x86/mm/mmio-mod.c
+++ b/arch/x86/mm/mmio-mod.c
@@ -32,6 +32,7 @@
#include <asm/e820.h> /* for ISA_START_ADDRESS */
#include <asm/atomic.h>
#include <linux/percpu.h>
+#include <linux/cpu.h>
#include "pf_in.h"
@@ -400,6 +401,64 @@ static void clear_trace_list(void)
}
}
+#ifdef CONFIG_HOTPLUG_CPU
+static cpumask_t downed_cpus;
+
+static void enter_uniprocessor(void)
+{
+ int cpu;
+ int err;
+
+ get_online_cpus();
+ downed_cpus = cpu_online_map;
+ cpu_clear(first_cpu(cpu_online_map), downed_cpus);
+ if (num_online_cpus() > 1)
+ pr_notice(NAME "Disabling non-boot CPUs...\n");
+ put_online_cpus();
+
+ for_each_cpu_mask(cpu, downed_cpus) {
+ err = cpu_down(cpu);
+ if (!err) {
+ pr_info(NAME "CPU%d is down.\n", cpu);
+ } else {
+ pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err);
+ }
+ }
+ if (num_online_cpus() > 1)
+ pr_warning(NAME "multiple CPUs still online, "
+ "may miss events.\n");
+}
+
+static void leave_uniprocessor(void)
+{
+ int cpu;
+ int err;
+
+ if (cpus_weight(downed_cpus) == 0)
+ return;
+ pr_notice(NAME "Re-enabling CPUs...\n");
+ for_each_cpu_mask(cpu, downed_cpus) {
+ err = cpu_up(cpu);
+ if (!err)
+ pr_info(NAME "enabled CPU%d.\n", cpu);
+ else
+ pr_err(NAME "cannot re-enable CPU%d: %d\n", cpu, err);
+ }
+}
+
+#else /* !CONFIG_HOTPLUG_CPU */
+static void enter_uniprocessor(void)
+{
+ if (num_online_cpus() > 1)
+ pr_warning(NAME "multiple CPUs are online, may miss events. "
+ "Suggest booting with maxcpus=1 kernel argument.\n");
+}
+
+static void leave_uniprocessor(void)
+{
+}
+#endif
+
#if 0 /* XXX: out of order */
static struct file_operations fops_marker = {
.owner = THIS_MODULE,
@@ -422,6 +481,7 @@ void enable_mmiotrace(void)
if (nommiotrace)
pr_info(NAME "MMIO tracing disabled.\n");
+ enter_uniprocessor();
spin_lock_irq(&trace_lock);
atomic_inc(&mmiotrace_enabled);
spin_unlock_irq(&trace_lock);
@@ -442,6 +502,7 @@ void disable_mmiotrace(void)
spin_unlock_irq(&trace_lock);
clear_trace_list(); /* guarantees: no more kmmio callbacks */
+ leave_uniprocessor();
if (marker_file) {
debugfs_remove(marker_file);
marker_file = NULL;
--
1.5.3.7
next prev parent reply other threads:[~2008-04-24 19:40 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080413224207.4430a09c@daedalus.pq.iki.fi>
2008-04-13 19:48 ` [PATCH] mmiotrace: add user documentation Pekka Paalanen
2008-04-14 15:49 ` Steven Rostedt
2008-04-14 18:20 ` Pekka Paalanen
2008-04-13 20:05 ` [BUG/PATCH] x86 mmiotrace: dynamically disable non-boot CPUs Pekka Paalanen
2008-04-14 6:57 ` Ingo Molnar
2008-04-14 18:02 ` Pekka Paalanen
2008-04-16 11:46 ` Ingo Molnar
2008-04-16 17:59 ` Pekka Paalanen
2008-04-16 18:32 ` Ingo Molnar
2008-04-16 19:07 ` Steven Rostedt
2008-04-16 20:42 ` Pekka Paalanen
2008-04-16 20:47 ` Ingo Molnar
2008-07-24 15:34 ` [Nouveau] " Stephane Marchesin
2008-04-19 15:41 ` [BUG] kmalloc_node(GFP_KERNEL) while smp_alt spinlocked Pekka Paalanen
2008-04-19 16:19 ` [PATCH] Fix SMP alternatives : use mutex instead of spinlock, text_poke is sleepable Mathieu Desnoyers
2008-04-19 21:06 ` Pekka Paalanen
2008-04-19 21:52 ` [BUG] CPU hotplug reboots machine (Re: [PATCH] Fix SMP alternatives : use mutex instead of spinlock, text_poke is sleepable) Pekka Paalanen
2008-04-19 21:58 ` [PATCH] Check for breakpoint in text_poke to eliminate bug_on Mathieu Desnoyers
2008-04-19 22:42 ` Pekka Paalanen
2008-04-20 0:05 ` Mathieu Desnoyers
2008-04-20 7:14 ` Pekka Paalanen
2008-04-20 19:44 ` Mathieu Desnoyers
2008-04-20 20:18 ` Pekka Paalanen
2008-04-20 20:25 ` Mathieu Desnoyers
2008-04-21 18:48 ` [PATCH] x86_64: fix kernel rodata NX setting Pekka Paalanen
2008-04-21 18:57 ` Steven Rostedt
2008-04-21 19:03 ` Ingo Molnar
2008-04-22 18:42 ` [repost PATCH] Fix SMP alternatives : use mutex instead of spinlock, text_poke is sleepable Pekka Paalanen
2008-04-22 19:09 ` Ingo Molnar
2008-04-22 20:22 ` Mathieu Desnoyers
2008-04-24 19:39 ` Pekka Paalanen [this message]
2008-04-26 11:13 ` [PATCH v2] x86 mmiotrace: dynamically disable non-boot CPUs Ingo Molnar
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=20080424223947.55c053f6@daedalus.pq.iki.fi \
--to=pq@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
/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®