diff options
author | fabient <fabient@FreeBSD.org> | 2012-03-28 20:58:30 +0000 |
---|---|---|
committer | fabient <fabient@FreeBSD.org> | 2012-03-28 20:58:30 +0000 |
commit | 5edfb77dd3a164bb9d2d40c6604faa6c9f3dce15 (patch) | |
tree | fadff08d26576c3d5c1cef9d47abd784602b237a /sys/kern/kern_sx.c | |
parent | 9a7982e5a0267c0421856f3a43a1ae75880058f3 (diff) | |
download | FreeBSD-src-5edfb77dd3a164bb9d2d40c6604faa6c9f3dce15.zip FreeBSD-src-5edfb77dd3a164bb9d2d40c6604faa6c9f3dce15.tar.gz |
Add software PMC support.
New kernel events can be added at various location for sampling or counting.
This will for example allow easy system profiling whatever the processor is
with known tools like pmcstat(8).
Simultaneous usage of software PMC and hardware PMC is possible, for example
looking at the lock acquire failure, page fault while sampling on
instructions.
Sponsored by: NETASQ
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_sx.c')
-rw-r--r-- | sys/kern/kern_sx.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 9cb9995..bcd7acd 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -37,6 +37,7 @@ */ #include "opt_ddb.h" +#include "opt_hwpmc_hooks.h" #include "opt_kdtrace.h" #include "opt_no_adaptive_sx.h" @@ -67,6 +68,11 @@ __FBSDID("$FreeBSD$"); CTASSERT((SX_NOADAPTIVE & LO_CLASSFLAGS) == SX_NOADAPTIVE); +#ifdef HWPMC_HOOKS +#include <sys/pmckern.h> +PMC_SOFT_DECLARE( , , lock, failed); +#endif + /* Handy macros for sleep queues. */ #define SQ_EXCLUSIVE_QUEUE 0 #define SQ_SHARED_QUEUE 1 @@ -524,6 +530,9 @@ _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, const char *file, #ifdef KDTRACE_HOOKS spin_cnt++; #endif +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); +#endif lock_profile_obtain_lock_failed(&sx->lock_object, &contested, &waittime); #ifdef ADAPTIVE_SX @@ -811,6 +820,9 @@ _sx_slock_hard(struct sx *sx, int opts, const char *file, int line) } continue; } +#ifdef HWPMC_HOOKS + PMC_SOFT_CALL( , , lock, failed); +#endif lock_profile_obtain_lock_failed(&sx->lock_object, &contested, &waittime); |