summaryrefslogtreecommitdiffstats
path: root/lib/libpmc
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2006-03-26 12:20:54 +0000
committerjkoshy <jkoshy@FreeBSD.org>2006-03-26 12:20:54 +0000
commit48e5e4792dd834813dd543cce68867e07d6c6d65 (patch)
treec2617fc6b46499b2b7e9b7d1145b96e592acedb1 /lib/libpmc
parenta3688cc84e2cc795f00344b147ed53c98c15520e (diff)
downloadFreeBSD-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 'lib/libpmc')
-rw-r--r--lib/libpmc/pmclog.344
-rw-r--r--lib/libpmc/pmclog.c19
-rw-r--r--lib/libpmc/pmclog.h15
3 files changed, 52 insertions, 26 deletions
diff --git a/lib/libpmc/pmclog.3 b/lib/libpmc/pmclog.3
index 862f9cc..82674a9 100644
--- a/lib/libpmc/pmclog.3
+++ b/lib/libpmc/pmclog.3
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2005 Joseph Koshy. All rights reserved.
+.\" Copyright (c) 2005-2006 Joseph Koshy. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 1, 2005
+.Dd March 26, 2006
.Os
.Dt PMCLOG 3
.Sh NAME
@@ -82,15 +82,21 @@ struct pmclog_ev {
struct timespec pl_ts; /* log entry timestamp */
enum pmclog_type pl_type; /* log entry kind */
union { /* log entry data */
- struct pmclog_ev_allocate pl_a;
- struct pmclog_ev_proccsw pl_c;
- struct pmclog_ev_dropnotify pl_d;
- struct pmclog_ev_procexit pl_e;
- struct pmclog_ev_initialize pl_i;
- struct pmclog_ev_pcsample pl_s;
- struct pmclog_ev_pmcattach pl_t;
- struct pmclog_ev_userdata pl_u;
- struct pmclog_ev_procexec pl_x;
+ struct pmclog_ev_closelog pl_cl;
+ struct pmclog_ev_dropnotify pl_d;
+ struct pmclog_ev_initialize pl_i;
+ struct pmclog_ev_map_in pl_mi;
+ struct pmclog_ev_map_out pl_mo;
+ struct pmclog_ev_pcsample pl_s;
+ struct pmclog_ev_pmcallocate pl_a;
+ struct pmclog_ev_pmcattach pl_t;
+ struct pmclog_ev_pmcdetach pl_d;
+ struct pmclog_ev_proccsw pl_c;
+ struct pmclog_ev_procexec pl_x;
+ struct pmclog_ev_procexit pl_e;
+ struct pmclog_ev_procfork pl_f;
+ struct pmclog_ev_sysexit pl_e;
+ struct pmclog_ev_userdata pl_u;
} pl_u;
};
.Ed
@@ -149,8 +155,20 @@ had to drop data due to a resource constraint.
.It Dv PMCLOG_TYPE_INITIALIZE
An initialization record.
This is the first record in a log file.
-.It Dv PMCLOG_TYPE_MAPPINGCHANGE
-A record describing an address space change for a process.
+.It Dv PMCLOG_TYPE_MAP_IN
+A record describing the introduction of a mapping to an executable
+object by a
+.Xr kldload 2
+or
+.Xr mmap 2
+system call.
+.It Dv PMCLOG_TYPE_MAP_OUT
+A record describing the removal of a mapping to an executable
+object by a
+.Xr kldunload 2
+or
+.Xr munmap 2
+system call.
.It Dv PMCLOG_TYPE_PCSAMPLE
A record containing an instruction pointer sample.
.It Dv PMCLOG_TYPE_PMCALLOCATE
diff --git a/lib/libpmc/pmclog.c b/lib/libpmc/pmclog.c
index e5dd2fc..fcd4a4f 100644
--- a/lib/libpmc/pmclog.c
+++ b/lib/libpmc/pmclog.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 Joseph Koshy
+ * Copyright (c) 2005-2006 Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -322,13 +322,16 @@ pmclog_get_event(void *cookie, char **data, ssize_t *len,
ps->ps_arch = ev->pl_u.pl_i.pl_arch;
ps->ps_initialized = 1;
break;
- case PMCLOG_TYPE_MAPPINGCHANGE:
- PMCLOG_GET_PATHLEN(pathlen,evlen,pmclog_mappingchange);
- PMCLOG_READ32(le,ev->pl_u.pl_m.pl_type);
- PMCLOG_READADDR(le,ev->pl_u.pl_m.pl_start);
- PMCLOG_READADDR(le,ev->pl_u.pl_m.pl_end);
- PMCLOG_READ32(le,ev->pl_u.pl_m.pl_pid);
- PMCLOG_READSTRING(le, ev->pl_u.pl_m.pl_pathname, pathlen);
+ case PMCLOG_TYPE_MAP_IN:
+ PMCLOG_GET_PATHLEN(pathlen,evlen,pmclog_map_in);
+ PMCLOG_READ32(le,ev->pl_u.pl_mi.pl_pid);
+ PMCLOG_READADDR(le,ev->pl_u.pl_mi.pl_start);
+ PMCLOG_READSTRING(le, ev->pl_u.pl_mi.pl_pathname, pathlen);
+ break;
+ case PMCLOG_TYPE_MAP_OUT:
+ PMCLOG_READ32(le,ev->pl_u.pl_mo.pl_pid);
+ PMCLOG_READADDR(le,ev->pl_u.pl_mo.pl_start);
+ PMCLOG_READADDR(le,ev->pl_u.pl_mo.pl_end);
break;
case PMCLOG_TYPE_PCSAMPLE:
PMCLOG_READ32(le,ev->pl_u.pl_s.pl_pid);
diff --git a/lib/libpmc/pmclog.h b/lib/libpmc/pmclog.h
index bc3c476..90fb193 100644
--- a/lib/libpmc/pmclog.h
+++ b/lib/libpmc/pmclog.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 Joseph Koshy
+ * Copyright (c) 2005-2006 Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,14 +49,18 @@ struct pmclog_ev_initialize {
uint32_t pl_arch;
};
-struct pmclog_ev_mappingchange {
- uint32_t pl_type;
+struct pmclog_ev_map_in {
pid_t pl_pid;
uintfptr_t pl_start;
- uintfptr_t pl_end;
char pl_pathname[PATH_MAX];
};
+struct pmclog_ev_map_out {
+ pid_t pl_pid;
+ uintfptr_t pl_start;
+ uintfptr_t pl_end;
+};
+
struct pmclog_ev_pcsample {
uintfptr_t pl_pc;
pid_t pl_pid;
@@ -124,7 +128,8 @@ struct pmclog_ev {
struct pmclog_ev_closelog pl_cl;
struct pmclog_ev_dropnotify pl_dn;
struct pmclog_ev_initialize pl_i;
- struct pmclog_ev_mappingchange pl_m;
+ struct pmclog_ev_map_in pl_mi;
+ struct pmclog_ev_map_out pl_mo;
struct pmclog_ev_pcsample pl_s;
struct pmclog_ev_pmcallocate pl_a;
struct pmclog_ev_pmcattach pl_t;
OpenPOWER on IntegriCloud