diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2006-03-26 12:20:54 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2006-03-26 12:20:54 +0000 |
commit | 48e5e4792dd834813dd543cce68867e07d6c6d65 (patch) | |
tree | c2617fc6b46499b2b7e9b7d1145b96e592acedb1 /sys/dev/hwpmc/hwpmc_logging.c | |
parent | a3688cc84e2cc795f00344b147ed53c98c15520e (diff) | |
download | FreeBSD-src-48e5e4792dd834813dd543cce68867e07d6c6d65.zip FreeBSD-src-48e5e4792dd834813dd543cce68867e07d6c6d65.tar.gz |
MFP4: Support for profiling dynamically loaded objects.
Kernel changes:
Inform hwpmc of executable objects brought into the system by
kldload() and mmap(), and of their removal by kldunload() and
munmap(). A helper function linker_hwpmc_list_objects() has been
added to "sys/kern/kern_linker.c" and is used by hwpmc to retrieve
the list of currently loaded kernel modules.
The unused `MAPPINGCHANGE' event has been deprecated in favour
of separate `MAP_IN' and `MAP_OUT' events; this change reduces
space wastage in the log.
Bump the hwpmc's ABI version to "2.0.00". Teach hwpmc(4) to
handle the map change callbacks.
Change the default per-cpu sample buffer size to hold
32 samples (up from 16).
Increment __FreeBSD_version.
libpmc(3) changes:
Update libpmc(3) to deal with the new events in the log file; bring
the pmclog(3) manual page in sync with the code.
pmcstat(8) changes:
Introduce new options to pmcstat(8): "-r" (root fs path), "-M"
(mapfile name), "-q"/"-v" (verbosity control). Option "-k" now
takes a kernel directory as its argument but will also work with
the older invocation syntax.
Rework string handling in pmcstat(8) to use an opaque type for
interned strings. Clean up ELF parsing code and add support for
tracking dynamic object mappings reported by a v2.0.00 hwpmc(4).
Report statistics at the end of a log conversion run depending
on the requested verbosity level.
Reviewed by: jhb, dds (kernel parts of an earlier patch)
Tested by: gallatin (earlier patch)
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_logging.c')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_logging.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index f901cbe..efa0c52 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -137,10 +137,11 @@ static struct mtx pmc_kthread_mtx; /* sleep lock */ CTASSERT(sizeof(struct pmclog_closelog) == 3*4); CTASSERT(sizeof(struct pmclog_dropnotify) == 3*4); -CTASSERT(sizeof(struct pmclog_mappingchange) == PATH_MAX + - 5*4 + 2*sizeof(uintfptr_t)); -CTASSERT(offsetof(struct pmclog_mappingchange,pl_pathname) == - 5*4 + 2*sizeof(uintfptr_t)); +CTASSERT(sizeof(struct pmclog_map_in) == PATH_MAX + + 4*4 + sizeof(uintfptr_t)); +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_pcsample) == 6*4 + sizeof(uintfptr_t)); CTASSERT(sizeof(struct pmclog_pmcallocate) == 6*4); CTASSERT(sizeof(struct pmclog_pmcattach) == 5*4 + PATH_MAX); @@ -728,24 +729,36 @@ pmclog_process_dropnotify(struct pmc_owner *po) } void -pmclog_process_mappingchange(struct pmc_owner *po, pid_t pid, int type, - uintfptr_t start, uintfptr_t end, char *path) +pmclog_process_map_in(struct pmc_owner *po, pid_t pid, uintfptr_t start, + const char *path) { int pathlen, recordlen; + KASSERT(path != NULL, ("[pmclog,%d] map-in, null path", __LINE__)); + pathlen = strlen(path) + 1; /* #bytes for path name */ - recordlen = offsetof(struct pmclog_mappingchange, pl_pathname) + + recordlen = offsetof(struct pmclog_map_in, pl_pathname) + pathlen; - PMCLOG_RESERVE(po,MAPPINGCHANGE,recordlen); - PMCLOG_EMIT32(type); - PMCLOG_EMITADDR(start); - PMCLOG_EMITADDR(end); + PMCLOG_RESERVE(po, MAP_IN, recordlen); PMCLOG_EMIT32(pid); + PMCLOG_EMITADDR(start); PMCLOG_EMITSTRING(path,pathlen); PMCLOG_DESPATCH(po); } +void +pmclog_process_map_out(struct pmc_owner *po, pid_t pid, uintfptr_t start, + uintfptr_t end) +{ + KASSERT(start <= end, ("[pmclog,%d] start > end", __LINE__)); + + PMCLOG_RESERVE(po, MAP_OUT, sizeof(struct pmclog_map_out)); + PMCLOG_EMIT32(pid); + PMCLOG_EMITADDR(start); + PMCLOG_EMITADDR(end); + PMCLOG_DESPATCH(po); +} void pmclog_process_pcsample(struct pmc *pm, struct pmc_sample *ps) |