summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libpmc/pmc.soft.34
-rw-r--r--sys/dev/hwpmc/hwpmc_soft.c9
-rw-r--r--sys/kern/kern_clock.c5
-rw-r--r--sys/kern/kern_clocksource.c24
4 files changed, 29 insertions, 13 deletions
diff --git a/lib/libpmc/pmc.soft.3 b/lib/libpmc/pmc.soft.3
index a8674ba..a6919ae 100644
--- a/lib/libpmc/pmc.soft.3
+++ b/lib/libpmc/pmc.soft.3
@@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 28, 2012
+.Dd February 26, 2013
.Dt PMC.SOFT 3
.Os
.Sh NAME
@@ -61,6 +61,8 @@ The event specifiers supported by software are:
Hard clock ticks.
.It Li CLOCK.STAT
Stat clock ticks.
+.It Li CLOCK.PROF
+Profiling clock ticks.
.It Li LOCK.FAILED
Lock acquisition failed.
.It Li PAGE_FAULT.ALL
diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c
index 0ed2262..48e297e 100644
--- a/sys/dev/hwpmc/hwpmc_soft.c
+++ b/sys/dev/hwpmc/hwpmc_soft.c
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
#define SOFT_CAPS (PMC_CAP_READ | PMC_CAP_WRITE | PMC_CAP_INTERRUPT | \
PMC_CAP_USER | PMC_CAP_SYSTEM)
+PMC_SOFT_DECLARE( , , clock, prof);
+
struct soft_descr {
struct pmc_descr pm_descr; /* "base class" */
};
@@ -125,6 +127,8 @@ soft_allocate_pmc(int cpu, int ri, struct pmc *pm,
return (EINVAL);
pmc_soft_ev_release(ps);
+ if (ev == pmc___clock_prof.ps_ev.pm_ev_code)
+ cpu_startprofclock();
return (0);
}
@@ -324,9 +328,8 @@ soft_release_pmc(int cpu, int ri, struct pmc *pmc)
KASSERT(phw->phw_pmc == NULL,
("[soft,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
- /*
- * Nothing to do.
- */
+ if (pmc->pm_event == pmc___clock_prof.ps_ev.pm_ev_code)
+ cpu_stopprofclock();
return (0);
}
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 9d62c58..55a2bff 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#include <sys/pmckern.h>
PMC_SOFT_DEFINE( , , clock, hard);
PMC_SOFT_DEFINE( , , clock, stat);
+PMC_SOFT_DEFINE( , , clock, prof);
#endif
#ifdef DEVICE_POLLING
@@ -817,6 +818,10 @@ profclock_cnt(int cnt, int usermode, uintfptr_t pc)
}
}
#endif
+#ifdef HWPMC_HOOKS
+ if (td->td_intr_frame != NULL)
+ PMC_SOFT_CALL_TF( , , clock, prof, td->td_intr_frame);
+#endif
}
/*
diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c
index 6fd40a8..33f21e9 100644
--- a/sys/kern/kern_clocksource.c
+++ b/sys/kern/kern_clocksource.c
@@ -732,12 +732,15 @@ cpu_startprofclock(void)
{
ET_LOCK();
- if (periodic) {
- configtimer(0);
- profiling = 1;
- configtimer(1);
+ if (profiling == 0) {
+ if (periodic) {
+ configtimer(0);
+ profiling = 1;
+ configtimer(1);
+ } else
+ profiling = 1;
} else
- profiling = 1;
+ profiling++;
ET_UNLOCK();
}
@@ -749,12 +752,15 @@ cpu_stopprofclock(void)
{
ET_LOCK();
- if (periodic) {
- configtimer(0);
+ if (profiling == 1) {
+ if (periodic) {
+ configtimer(0);
+ profiling = 0;
+ configtimer(1);
+ } else
profiling = 0;
- configtimer(1);
} else
- profiling = 0;
+ profiling--;
ET_UNLOCK();
}
OpenPOWER on IntegriCloud