[PATCH] arch/x86/oprofile/op_model_amd.c: perform initialisation on a single CPU

From: Robert Richter
Date: Mon Jan 03 2011 - 04:36:53 EST


Disable preemption in init_ibs(). The function only checks the ibs
capabilities and sets up pci devices (if necessary). It runs only on
one cpu but operates with the local APIC and some MSRs, thus it is
better to disable preemption.

[ 7.034377] BUG: using smp_processor_id() in preemptible [00000000] code:
modprobe/483
[ 7.034385] caller is setup_APIC_eilvt+0x155/0x180
[ 7.034389] Pid: 483, comm: modprobe Not tainted 2.6.37-rc1-20101110+ #1
[ 7.034392] Call Trace:
[ 7.034400] [<ffffffff812a2b72>] debug_smp_processor_id+0xd2/0xf0
[ 7.034404] [<ffffffff8101e985>] setup_APIC_eilvt+0x155/0x180
[ 7.034413] [<ffffffffa002e168>] op_amd_init+0x88/0x2b0 [oprofile]
[ 7.034420] [<ffffffffa0043000>] ? oprofile_init+0x0/0x42 [oprofile]
[ 7.034425] [<ffffffffa0043315>] op_nmi_init+0x249/0x2af [oprofile]
[ 7.034431] [<ffffffffa00430b4>] oprofile_arch_init+0x11/0x29 [oprofile]
[ 7.034437] [<ffffffffa0043010>] oprofile_init+0x10/0x42 [oprofile]
[ 7.034441] [<ffffffff810001e3>] do_one_initcall+0x43/0x170
[ 7.034445] [<ffffffff8108a52a>] sys_init_module+0xba/0x200
[ 7.034449] [<ffffffff8100285b>] system_call_fastpath+0x16/0x1b

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=22812

Reported-by: <atswartz@xxxxxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxx>
Cc: Dan Carpenter <error27@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxx> [2.6.37.x]
Signed-off-by: Robert Richter <robert.richter@xxxxxxx>
---
arch/x86/oprofile/op_model_amd.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index a011bcc..8d7d883 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -630,7 +630,14 @@ static int __init_ibs_nmi(void)
return 0;
}

-/* initialize the APIC for the IBS interrupts if available */
+/*
+ * check and reserve APIC extended interrupt LVT offset for IBS if
+ * available
+ *
+ * init_ibs() preforms implicitly cpu-local operations, so pin this
+ * thread to its current CPU
+ */
+
static void init_ibs(void)
{
ibs_caps = get_ibs_caps();
@@ -638,13 +645,15 @@ static void init_ibs(void)
if (!ibs_caps)
return;

- if (__init_ibs_nmi()) {
+ preempt_disable();
+
+ if (__init_ibs_nmi())
ibs_caps = 0;
- return;
- }
+ else
+ printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n",
+ (unsigned)ibs_caps);

- printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n",
- (unsigned)ibs_caps);
+ preempt_enable();
}

static int (*create_arch_files)(struct super_block *sb, struct dentry *root);
--
1.7.3.2



--
Advanced Micro Devices, Inc.
Operating System Research Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/