summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c12
-rw-r--r--sys/kern/kern_pmc.c21
-rw-r--r--sys/sys/pmckern.h3
3 files changed, 29 insertions, 7 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index bb94906..111eccb 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -3917,6 +3917,18 @@ pmc_initialize(void)
PMCDBG(MOD,INI,0, "PMC Initialize (version %x)", PMC_VERSION);
+ /* check kernel version */
+ if (pmc_kernel_version != PMC_VERSION) {
+ if (pmc_kernel_version == 0)
+ printf("hwpmc: this kernel has not been compiled with "
+ "'options HWPMC_HOOKS'.\n");
+ else
+ printf("hwpmc: kernel version (0x%x) does not match "
+ "module version (0x%x).\n", pmc_kernel_version,
+ PMC_VERSION);
+ return EPROGMISMATCH;
+ }
+
/*
* check sysctl parameters
*/
diff --git a/sys/kern/kern_pmc.c b/sys/kern/kern_pmc.c
index 43059cc..ed4de59 100644
--- a/sys/kern/kern_pmc.c
+++ b/sys/kern/kern_pmc.c
@@ -26,10 +26,20 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_hwpmc_hooks.h"
+
+#include <sys/types.h>
+#include <sys/pmc.h>
#include <sys/pmckern.h>
#include <sys/smp.h>
-struct sx pmc_sx;
+#if HWPMC_HOOKS
+#define PMC_KERNEL_VERSION PMC_VERSION
+#else
+#define PMC_KERNEL_VERSION 0
+#endif
+
+const int pmc_kernel_version = PMC_KERNEL_VERSION;
/* Hook variable. */
int (*pmc_hook)(struct thread *td, int function, void *arg) = NULL;
@@ -37,13 +47,13 @@ int (*pmc_hook)(struct thread *td, int function, void *arg) = NULL;
/* Interrupt handler */
int (*pmc_intr)(int cpu, uintptr_t pc, int usermode) = NULL;
+/* Bitmask of CPUs requiring servicing at hardclock time */
volatile cpumask_t pmc_cpumask;
/*
* A global count of SS mode PMCs. When non-zero, this means that
* we have processes that are sampling the system as a whole.
*/
-
volatile int pmc_ss_count;
/*
@@ -55,14 +65,11 @@ volatile int pmc_ss_count;
* shared (sx) lock -- thus making the process of calling into PMC(4)
* somewhat more expensive than a simple 'if' check and indirect call.
*/
-
-
+struct sx pmc_sx;
SX_SYSINIT(pmc, &pmc_sx, "pmc shared lock");
/*
- * pmc_cpu_is_disabled
- *
- * return TRUE if the cpu specified has been disabled.
+ * Helper functions
*/
int
diff --git a/sys/sys/pmckern.h b/sys/sys/pmckern.h
index 0d689b2..d489fe6 100644
--- a/sys/sys/pmckern.h
+++ b/sys/sys/pmckern.h
@@ -62,6 +62,9 @@ extern volatile cpumask_t pmc_cpumask;
/* Count of system-wide sampling PMCs in existence */
extern volatile int pmc_ss_count;
+/* kernel version number */
+extern const int pmc_kernel_version;
+
/* Hook invocation; for use within the kernel */
#define PMC_CALL_HOOK(t, cmd, arg) \
do { \
OpenPOWER on IntegriCloud