[PATCH] oprofile: hotplug cpu fix

From: Chris J Arges
Date: Wed Oct 15 2008 - 14:09:58 EST


This is a multi-part message in MIME format.This patch addresses crashes when hotplugging cpus while profiling.
I used the following script to test :

#!/bin/bash
startup()
{
opcontrol --init
opcontrol --vmlinux=/boot/vmlinux
opcontrol --reset
opcontrol --start
opcontrol --dump
}
shutdown()
{
opcontrol --dump
opcontrol -h
}
startup
echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu1/online
shutdown
startup
echo 1 > /sys/devices/system/cpu/cpu2/online
echo 1 > /sys/devices/system/cpu/cpu1/online
shutdown
startup
echo 0 > /sys/devices/system/cpu/cpu2/online
shutdown
startup
echo 1 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu2/online
shutdown
echo 1 > /sys/devices/system/cpu/cpu2/online

Without the patch on my Power machine (ppc970mp) I get the following error:

Vector: 300 (Data Access) at [c000000276143950]
pc: d0000000000366e8: .add_event_entry+0x60/0xb0 [oprofile]
lr: d000000000035e60: .sync_buffer+0x68/0x4ac [oprofile]

Without the patch on my x86 (Core 2 Duo) machine:

mutex_lock +0x8/0x20
sync_buffer +0x29/0x3e0
wq_sync_buffer +0x0/0x70

Since I'm guessing hotplugging cpus and using oprofile is not a common occurrence, this patch is just a do-no-harm fix, instead
of a full solution with a hotplug callback, etc.

Thanks,
--chris