diff options
Diffstat (limited to 'arch/x86/oprofile/nmi_int.c')
-rw-r--r-- | arch/x86/oprofile/nmi_int.c | 12 |
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); |