aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile
diff options
context:
space:
mode:
authorSantosh Shilimkar <santosh.shilimkar@ti.com>2010-10-27 11:17:15 -0400
committerRobert Richter <robert.richter@amd.com>2010-10-29 05:52:53 -0400
commit4ac3dbec800d93485a5c84e37af676278eea657c (patch)
treeaa1a3e7065ed3f40e880de786df9b8077b278e59 /drivers/oprofile
parent0b849ee88846e3488a34007c5b8b4249579ff159 (diff)
oprofile: Fix the hang while taking the cpu offline
The kernel build with CONFIG_OPROFILE and CPU_HOTPLUG enabled. The oprofile is initialised using system timer in absence of hardware counters supports. Oprofile isn't started from userland. In this setup while doing a CPU offline the kernel hangs in infinite for loop inside lock_hrtimer_base() function This happens because as part of oprofile_cpu_notify(, it tries to stop an hrtimer which was never started. These per-cpu hrtimers are started when the oprfile is started. echo 1 > /dev/oprofile/enable This problem also existwhen the cpu is booted with maxcpus parameter set. When bringing the remaining cpus online the timers are started even if oprofile is not yet enabled. This patch fix this issue by adding a state variable so that these hrtimer start/stop is only attempted when oprofile is started For stable kernels v2.6.35.y and v2.6.36.y. Reported-by: Jan Sebastien <s-jan@ti.com> Tested-by: sricharan <r.sricharan@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Cc: stable@kernel.org Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile')
-rw-r--r--drivers/oprofile/timer_int.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index dc0ae4d14dff..010725117dbb 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -21,6 +21,7 @@
21#include "oprof.h" 21#include "oprof.h"
22 22
23static DEFINE_PER_CPU(struct hrtimer, oprofile_hrtimer); 23static DEFINE_PER_CPU(struct hrtimer, oprofile_hrtimer);
24static int ctr_running;
24 25
25static enum hrtimer_restart oprofile_hrtimer_notify(struct hrtimer *hrtimer) 26static enum hrtimer_restart oprofile_hrtimer_notify(struct hrtimer *hrtimer)
26{ 27{
@@ -33,6 +34,9 @@ static void __oprofile_hrtimer_start(void *unused)
33{ 34{
34 struct hrtimer *hrtimer = &__get_cpu_var(oprofile_hrtimer); 35 struct hrtimer *hrtimer = &__get_cpu_var(oprofile_hrtimer);
35 36
37 if (!ctr_running)
38 return;
39
36 hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 40 hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
37 hrtimer->function = oprofile_hrtimer_notify; 41 hrtimer->function = oprofile_hrtimer_notify;
38 42
@@ -42,7 +46,10 @@ static void __oprofile_hrtimer_start(void *unused)
42 46
43static int oprofile_hrtimer_start(void) 47static int oprofile_hrtimer_start(void)
44{ 48{
49 get_online_cpus();
50 ctr_running = 1;
45 on_each_cpu(__oprofile_hrtimer_start, NULL, 1); 51 on_each_cpu(__oprofile_hrtimer_start, NULL, 1);
52 put_online_cpus();
46 return 0; 53 return 0;
47} 54}
48 55
@@ -50,6 +57,9 @@ static void __oprofile_hrtimer_stop(int cpu)
50{ 57{
51 struct hrtimer *hrtimer = &per_cpu(oprofile_hrtimer, cpu); 58 struct hrtimer *hrtimer = &per_cpu(oprofile_hrtimer, cpu);
52 59
60 if (!ctr_running)
61 return;
62
53 hrtimer_cancel(hrtimer); 63 hrtimer_cancel(hrtimer);
54} 64}
55 65
@@ -57,8 +67,11 @@ static void oprofile_hrtimer_stop(void)
57{ 67{
58 int cpu; 68 int cpu;
59 69
70 get_online_cpus();
60 for_each_online_cpu(cpu) 71 for_each_online_cpu(cpu)
61 __oprofile_hrtimer_stop(cpu); 72 __oprofile_hrtimer_stop(cpu);
73 ctr_running = 0;
74 put_online_cpus();
62} 75}
63 76
64static int __cpuinit oprofile_cpu_notify(struct notifier_block *self, 77static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,