perfmon3: X86 OProfile hooks
PATCH 7/24 perfmon3: X86 OProfile hooks
Provides PMU access synchronization between Perfmon and OProfile. Both subsystems can be compiled in. Only one of them can be active at any one time. It is necessary to issue opcontrol --shutdown to terminate the OProfile session.
Signed-off-by Stephane Eranian <[email protected]>
--
arch/x86/oprofile/nmi_int.c +9 -1
@@ -16,6 +16,7 @@#include <linux/moduleparam.h> #include <linux/kdebug.h> #include <linux/cpu.h> +#include <linux/perfmon_kern.h> #include <asm/nmi.h> #include <asm/msr.h> #include <asm/apic.h>
@@ -217,12 +218,18 @@int err =0 ;int cpu; -if (!allocate_msrs ()) +if (pfm_session_allcpus_acquire ()) +return -EBUSY ; + +if (!allocate_msrs ()) { +pfm_session_allcpus_release ();return -ENOMEM ; + } err =register_die_notifier (&profile_exceptions_nb);if (err) {free_msrs (); +pfm_session_allcpus_release ();return err; }
@@ -303,6 +310,7 @@ msrs = &get_cpu_var (cpu_msrs); model->shutdown (msrs);free_msrs (); +pfm_session_allcpus_release ();put_cpu_var (cpu_msrs); }
include/linux/perfmon_kern.h +11 -0
@@ -192,6 +192,9 @@void pfm_interrupt_handler (unsigned long ip,struct pt_regs *regs); +int pfm_session_allcpus_acquire (void ); +void pfm_session_allcpus_release (void ); +static inline void pfm_exit_thread (void ) {if (current->pfm_context)
@@ -272,5 +275,13 @@static inline void pfm_ctxsw_out (struct task_struct *p,struct task_struct *n) {} + +static inline void pfm_session_allcpus_release (void ) +{} + +static inline int pfm_session_allcpus_acquire (void ) +{ +return 0 ; +}#endif /* CONFIG_PERFMON */ #endif /* __LINUX_PERFMON_KERN_H__ */
perfmon/perfmon_res.c +85 -0
94 lines not on this page · raw message