Commit de654649 authored by Robert Richter's avatar Robert Richter

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: default avatarRobert Richter <robert.richter@amd.com>
parent 6ae56b55
...@@ -62,12 +62,16 @@ static int profile_exceptions_notify(struct notifier_block *self, ...@@ -62,12 +62,16 @@ static int profile_exceptions_notify(struct notifier_block *self,
{ {
struct die_args *args = (struct die_args *)data; struct die_args *args = (struct die_args *)data;
int ret = NOTIFY_DONE; int ret = NOTIFY_DONE;
int cpu = smp_processor_id();
switch (val) { switch (val) {
case DIE_NMI: case DIE_NMI:
case DIE_NMI_IPI: case DIE_NMI_IPI:
model->check_ctrs(args->regs, &per_cpu(cpu_msrs, cpu)); if (ctr_running)
model->check_ctrs(args->regs, &__get_cpu_var(cpu_msrs));
else if (!nmi_enabled)
break;
else
model->stop(&__get_cpu_var(cpu_msrs));
ret = NOTIFY_STOP; ret = NOTIFY_STOP;
break; break;
default: default:
...@@ -392,6 +396,9 @@ static int nmi_setup(void) ...@@ -392,6 +396,9 @@ static int nmi_setup(void)
mux_clone(cpu); mux_clone(cpu);
} }
nmi_enabled = 0;
ctr_running = 0;
barrier();
err = register_die_notifier(&profile_exceptions_nb); err = register_die_notifier(&profile_exceptions_nb);
if (err) if (err)
goto fail; goto fail;
...@@ -451,6 +458,7 @@ static void nmi_shutdown(void) ...@@ -451,6 +458,7 @@ static void nmi_shutdown(void)
nmi_enabled = 0; nmi_enabled = 0;
ctr_running = 0; ctr_running = 0;
put_online_cpus(); put_online_cpus();
barrier();
unregister_die_notifier(&profile_exceptions_nb); unregister_die_notifier(&profile_exceptions_nb);
msrs = &get_cpu_var(cpu_msrs); msrs = &get_cpu_var(cpu_msrs);
model->shutdown(msrs); model->shutdown(msrs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment