aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/oprofile
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2010-05-03 08:41:22 -0400
committerRobert Richter <robert.richter@amd.com>2010-05-04 05:39:38 -0400
commitde654649737696ecf32873c341b305e30f3dc777 (patch)
tree242e9a9f7d03b4da10b9786c895f46a8451a1725 /arch/x86/oprofile
parent6ae56b55bc364bc2f2342f599b46581627ba22da (diff)
oprofile/x86: stop disabled counters in nmi handler
This patch adds checks to the nmi handler. Now samples are only generated and counters reenabled, if the counters are running. Otherwise the counters are stopped, if oprofile is using the nmi. In other cases it will ignore the nmi notification. Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'arch/x86/oprofile')
-rw-r--r--arch/x86/oprofile/nmi_int.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index b56601eaf29d..94b5481bb6c6 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -62,12 +62,16 @@ static int profile_exceptions_notify(struct notifier_block *self,
62{ 62{
63 struct die_args *args = (struct die_args *)data; 63 struct die_args *args = (struct die_args *)data;
64 int ret = NOTIFY_DONE; 64 int ret = NOTIFY_DONE;
65 int cpu = smp_processor_id();
66 65
67 switch (val) { 66 switch (val) {
68 case DIE_NMI: 67 case DIE_NMI:
69 case DIE_NMI_IPI: 68 case DIE_NMI_IPI:
70 model->check_ctrs(args->regs, &per_cpu(cpu_msrs, cpu)); 69 if (ctr_running)
70 model->check_ctrs(args->regs, &__get_cpu_var(cpu_msrs));
71 else if (!nmi_enabled)
72 break;
73 else
74 model->stop(&__get_cpu_var(cpu_msrs));
71 ret = NOTIFY_STOP; 75 ret = NOTIFY_STOP;
72 break; 76 break;
73 default: 77 default:
@@ -392,6 +396,9 @@ static int nmi_setup(void)
392 mux_clone(cpu); 396 mux_clone(cpu);
393 } 397 }
394 398
399 nmi_enabled = 0;
400 ctr_running = 0;
401 barrier();
395 err = register_die_notifier(&profile_exceptions_nb); 402 err = register_die_notifier(&profile_exceptions_nb);
396 if (err) 403 if (err)
397 goto fail; 404 goto fail;
@@ -451,6 +458,7 @@ static void nmi_shutdown(void)
451 nmi_enabled = 0; 458 nmi_enabled = 0;
452 ctr_running = 0; 459 ctr_running = 0;
453 put_online_cpus(); 460 put_online_cpus();
461 barrier();
454 unregister_die_notifier(&profile_exceptions_nb); 462 unregister_die_notifier(&profile_exceptions_nb);
455 msrs = &get_cpu_var(cpu_msrs); 463 msrs = &get_cpu_var(cpu_msrs);
456 model->shutdown(msrs); 464 model->shutdown(msrs);