Skip to contentSkip to conversation

perfmon2 minimal: X86 OProfile hooks

PATCH In review [email protected] 1 participant 1 message Jun 9, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 8/21 perfmon2 minimal: X86 OProfile hooks

Provides PMU access synchronization between Perfmon2 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.

--

arch/x86/oprofile/nmi_int.c +9 -1
Index: o/arch/x86/oprofile/nmi_int.c
===================================================================
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/kdebug.h>
+#include <linux/perfmon_kern.h>
 #include <asm/nmi.h>
 #include <asm/msr.h>
 #include <asm/apic.h>
@@ -191,12 +192,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;
 	}
 
@@ -275,6 +282,7 @@
 	unregister_die_notifier(&profile_exceptions_nb);
 	model->shutdown(msrs);
 	free_msrs();
+	pfm_session_allcpus_release();
 }
 
 static void nmi_cpu_start(void *dummy)
include/linux/perfmon_kern.h +5 -0
Index: o/include/linux/perfmon_kern.h
===================================================================
@@ -180,6 +180,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)
@@ -256,6 +259,8 @@
 #define pfm_copy_thread(_t)		do { } while (0)
 #define pfm_ctxsw_in(_p, _n)    	do { } while (0)
 #define pfm_ctxsw_out(_p, _n)      	do { } while (0)
+#define pfm_session_allcpus_release()	do { } while (0)
+#define pfm_session_allcpus_acquire()	(0)
 
 #endif /* CONFIG_PERFMON */
 
perfmon/perfmon_res.c +85 -0

94 lines not on this page · raw message