summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_clock.c
diff options
context:
space:
mode:
authorfabient <fabient@FreeBSD.org>2012-03-28 20:58:30 +0000
committerfabient <fabient@FreeBSD.org>2012-03-28 20:58:30 +0000
commit5edfb77dd3a164bb9d2d40c6604faa6c9f3dce15 (patch)
treefadff08d26576c3d5c1cef9d47abd784602b237a /sys/kern/kern_clock.c
parent9a7982e5a0267c0421856f3a43a1ae75880058f3 (diff)
downloadFreeBSD-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_clock.c')
-rw-r--r--sys/kern/kern_clock.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index fdc1302..57dd632 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -74,6 +74,8 @@ __FBSDID("$FreeBSD$");
#ifdef HWPMC_HOOKS
#include <sys/pmckern.h>
+PMC_SOFT_DEFINE( , , clock, hard);
+PMC_SOFT_DEFINE( , , clock, stat);
#endif
#ifdef DEVICE_POLLING
@@ -446,9 +448,11 @@ hardclock_cpu(int usermode)
td->td_flags |= flags;
thread_unlock(td);
-#ifdef HWPMC_HOOKS
+#ifdef HWPMC_HOOKS
if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid)))
PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL);
+ if (td->td_intr_frame != NULL)
+ PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame);
#endif
callout_tick();
}
@@ -537,6 +541,8 @@ hardclock_cnt(int cnt, int usermode)
#ifdef HWPMC_HOOKS
if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid)))
PMC_CALL_HOOK_UNLOCKED(curthread, PMC_FN_DO_SAMPLES, NULL);
+ if (td->td_intr_frame != NULL)
+ PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame);
#endif
callout_tick();
/* We are in charge to handle this tick duty. */
@@ -758,6 +764,10 @@ statclock_cnt(int cnt, int usermode)
for ( ; cnt > 0; cnt--)
sched_clock(td);
thread_unlock(td);
+#ifdef HWPMC_HOOKS
+ if (td->td_intr_frame != NULL)
+ PMC_SOFT_CALL_TF( , , clock, stat, td->td_intr_frame);
+#endif
}
void
OpenPOWER on IntegriCloud