aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-06-06 02:48:09 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-06-06 02:48:09 +0000
commitb2ca2e50b9aaccc15efaf970f9139310429abfe5 (patch)
tree58fdce4833a3c09b5f49c4ce6d7ae2240621095e /sys/dev
parent64fe1b5e1d6bfe76e62871ba2ec8d598641ff92c (diff)
downloadsrc-b2ca2e50b9aaccc15efaf970f9139310429abfe5.tar.gz
src-b2ca2e50b9aaccc15efaf970f9139310429abfe5.zip
hwpmc: add summary command and further metadata extensions
metadata changes: - log pmc sample rate with pmcallocate - log proc flags with thread / process logging to identify user vs kernel threads fixes: - use log cpuid to translate event id to event name Implement rudimentary summary command to track sample counts by thread and process name within a pmc log. % make -j4 buildkernel >& /dev/null & % sudo pmcstat -S unhalted_core_cycles -S llc-misses -O foo sleep 15 % pmc summary foo cpu_clk_unhalted.thread_p_any: idle: 138108207162 clang-6.0: 105336158004 sh: 72340108510 make: 8642012963 kernel: 7754011631 longest_lat_cache.miss: clang-6.0: 87502625 sh: 40901227 make: 5500165 kernel: 3300099 awk: 2000060 % pmc summary -f ~/foo idx: 278 name: cpu_clk_unhalted.thread_p_any rate: 2000003 idle: 69054 clang-6.0: 52668 sh: 36170 make: 4321 kernel: 3877 hwpmc: proc(7445): 3319 awk: 1289 xargs: 357 rand_harvestq: 181 mtree: 102 intr: 53 zfskern: 31 usb: 7 pagedaemon: 4 ntpd: 3 syslogd: 1 acpi_thermal: 1 logger: 1 syncer: 1 snmptrapd: 1 sleep: 1 idx: 17 name: longest_lat_cache.miss rate: 100003 clang-6.0: 875 sh: 409 make: 55 kernel: 33 awk: 20 hwpmc: proc(7445): 14 xargs: 9 idle: 8 intr: 3 zfskern: 2
Notes
Notes: svn path=/head/; revision=334701
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/hwpmc/hwpmc_logging.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c6
2 files changed, 15 insertions, 3 deletions
diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c
index 49996229480b..1f314518549a 100644
--- a/sys/dev/hwpmc/hwpmc_logging.c
+++ b/sys/dev/hwpmc/hwpmc_logging.c
@@ -194,7 +194,7 @@ CTASSERT(sizeof(struct pmclog_map_in) == PATH_MAX +
CTASSERT(offsetof(struct pmclog_map_in,pl_pathname) ==
4*4 + sizeof(uintfptr_t));
CTASSERT(sizeof(struct pmclog_map_out) == 4*4 + 2*sizeof(uintfptr_t));
-CTASSERT(sizeof(struct pmclog_pmcallocate) == 6*4);
+CTASSERT(sizeof(struct pmclog_pmcallocate) == 8*4);
CTASSERT(sizeof(struct pmclog_pmcattach) == 6*4 + PATH_MAX);
CTASSERT(offsetof(struct pmclog_pmcattach,pl_pathname) == 6*4);
CTASSERT(sizeof(struct pmclog_pmcdetach) == 6*4);
@@ -991,6 +991,7 @@ pmclog_process_pmcallocate(struct pmc *pm)
PMCLOG_EMIT32(pm->pm_id);
PMCLOG_EMIT32(pm->pm_event);
PMCLOG_EMIT32(pm->pm_flags);
+ PMCLOG_EMIT64(pm->pm_sc.pm_reloadcount);
ps = pmc_soft_ev_acquire(pm->pm_event);
if (ps != NULL)
PMCLOG_EMITSTRING(ps->ps_ev.pm_ev_name,PMC_NAME_MAX);
@@ -1004,6 +1005,7 @@ pmclog_process_pmcallocate(struct pmc *pm)
PMCLOG_EMIT32(pm->pm_id);
PMCLOG_EMIT32(pm->pm_event);
PMCLOG_EMIT32(pm->pm_flags);
+ PMCLOG_EMIT64(pm->pm_sc.pm_reloadcount);
PMCLOG_DESPATCH_SYNC(po);
}
}
@@ -1050,11 +1052,15 @@ pmclog_process_proccreate(struct pmc_owner *po, struct proc *p, int sync)
if (sync) {
PMCLOG_RESERVE(po, PROC_CREATE, sizeof(struct pmclog_proccreate));
PMCLOG_EMIT32(p->p_pid);
+ PMCLOG_EMIT32(p->p_flag);
+ PMCLOG_EMIT32(0);
PMCLOG_EMITSTRING(p->p_comm, MAXCOMLEN+1);
PMCLOG_DESPATCH_SYNC(po);
} else {
PMCLOG_RESERVE(po, PROC_CREATE, sizeof(struct pmclog_proccreate));
PMCLOG_EMIT32(p->p_pid);
+ PMCLOG_EMIT32(p->p_flag);
+ PMCLOG_EMIT32(0);
PMCLOG_EMITSTRING(p->p_comm, MAXCOMLEN+1);
PMCLOG_DESPATCH(po);
}
@@ -1163,14 +1169,14 @@ pmclog_process_threadcreate(struct pmc_owner *po, struct thread *td, int sync)
PMCLOG_RESERVE(po, THR_CREATE, sizeof(struct pmclog_threadcreate));
PMCLOG_EMIT32(td->td_tid);
PMCLOG_EMIT32(p->p_pid);
- PMCLOG_EMIT32(0);
+ PMCLOG_EMIT32(p->p_flag);
PMCLOG_EMITSTRING(td->td_name, MAXCOMLEN+1);
PMCLOG_DESPATCH_SYNC(po);
} else {
PMCLOG_RESERVE(po, THR_CREATE, sizeof(struct pmclog_threadcreate));
PMCLOG_EMIT32(td->td_tid);
PMCLOG_EMIT32(p->p_pid);
- PMCLOG_EMIT32(0);
+ PMCLOG_EMIT32(p->p_flag);
PMCLOG_EMITSTRING(td->td_name, MAXCOMLEN+1);
PMCLOG_DESPATCH(po);
}
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 191f2554ee60..cb09592a61d1 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -3925,6 +3925,12 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
pmc->pm_caps = caps;
pmc->pm_flags = pa.pm_flags;
+ /* XXX set lower bound on sampling for process counters */
+ if (PMC_IS_SAMPLING_MODE(mode))
+ pmc->pm_sc.pm_reloadcount = pa.pm_count;
+ else
+ pmc->pm_sc.pm_initial = pa.pm_count;
+
/* switch thread to CPU 'cpu' */
pmc_save_cpu_binding(&pb);