aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-05-26 18:12:50 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-05-26 18:12:50 +0000
commit4928135658a9d0eaee37003df6137ab363fcb0b4 (patch)
treec994717317a845c2afb2fd2d79beb650af57fafd /usr.sbin
parent70d66bcf28f9d17a4c1949d1066e5bb2fccc9e9a (diff)
downloadsrc-4928135658a9d0eaee37003df6137ab363fcb0b4.tar.gz
src-4928135658a9d0eaee37003df6137ab363fcb0b4.zip
pmc(3)/hwpmc(4): update supported Intel processors to rely fully on the
vendor provided pmu-events tables and sundry cleanups. The vendor pmu-events tables provide counter descriptions, default sample rates, event, umask, and flag values for all the counter configuration permutations. Using this gives us: - much simpler kernel code for the MD component - helpful long and short event descriptions - simpler user code - sample rates that won't overload the system Update man page with newer sample types and remove unused sample type. Squashed commit of the following: commit 4459d43eff815bec08ccc5533dbe5de846f03128 Author: Matt Macy <mmacy@mattmacy.io> Date: Sat May 26 00:06:31 2018 -0700 libpmc: fix pmu function signatures for non amd64 commit a2cb8bbc586c65d41f9b291430a2261ec67b59fe Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 22:38:11 2018 -0700 pmcstat: fix indentation of usage commit f686954b15ff56a833ac80404898977cb80a265b Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 22:19:49 2018 -0700 pmclog(3): add callchain and pmcallocatedyn, remove pcsample commit 73e13a0d2e9498c81c150d14d022050cee7511bb Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 22:19:00 2018 -0700 pmclog.h: GC pcsample field commit 3e93ffd65da641fa657539dad3c48e281f8b5798 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 22:05:57 2018 -0700 hwpmc: make Intel core CPUs use external event tables commit 634f5fae1e1644ac324003136c66cd9c619d1c93 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 22:00:06 2018 -0700 pmclog: update log record types, bump PMC_MAJOR - explicitly make log record types a multiple of 8 bytes - hook in pmu event types for pmc_allocate records - remove references to no longer PCSAMPLE record commit 83d84fcd2d65bdf6ddcb2e155a22f0cfa2a9c225 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 21:52:10 2018 -0700 libpmc: add support for having vendor table driven pmc_allocate commit 9e6ad63c40c2fce8404847ace5078ca6cb33a736 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 19:11:33 2018 -0700 hwpmc_core: add accessors for EVSEL & UMASK, make IAP_UMASK useful to user commit 859dceb93daa6419a48c794db99b6758e5b041c9 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 19:09:45 2018 -0700 pmcstat: update usage and man page as well as make -L consistent with pmccontrol commit 79c7d8597e28c2eb13f5f9113e65ec2792ca57b1 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 18:07:03 2018 -0700 pmu_util: add support for all current intel event keywords commit d8089c7f6a6c8527f38324252b1ffb47004694c6 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 17:45:00 2018 -0700 add description for new arguments commit 058336740bab53c62ec88a3a026ea848cf3878c6 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 17:38:15 2018 -0700 libpmc: move pmu_events table and pmu_utils out of libpmcstat so that they can be used by pmc_allocate commit 049b66b382e2f833c3f47bc8df9e750cb265709f Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 16:12:41 2018 -0700 pmcstat: hook pmu_events counter description utility routines in commit f5e01e7b37a691dc045e1aa16b3ebdd162515de8 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 16:11:59 2018 -0700 pmu_events: add utility routines for listing counters and their descriptions commit cba4d4f8907f772279f86f18f915e0d74d33ac56 Author: Matt Macy <mmacy@mattmacy.io> Date: Fri May 25 16:09:50 2018 -0700 pmu-events: expand out skylake regex to simplify string matches
Notes
Notes: svn path=/head/; revision=334242
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pmcstat/pmcstat.825
-rw-r--r--usr.sbin/pmcstat/pmcstat.c59
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c7
3 files changed, 62 insertions, 29 deletions
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index fa68a39a1483..f6ff4fbb32cb 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -39,7 +39,7 @@
.Op Fl F Ar pathname
.Op Fl G Ar pathname
.Op Fl I
-.Op Fl L Ar lwp
+.Op Fl L
.Op Fl M Ar mapfilename
.Op Fl N
.Op Fl O Ar logfilename
@@ -47,6 +47,7 @@
.Op Fl R Ar logfilename
.Op Fl S Ar event-spec
.Op Fl T
+.Op Fl U Ar event-spec
.Op Fl W
.Op Fl a Ar pathname
.Op Fl c Ar cpu-spec
@@ -54,6 +55,7 @@
.Op Fl e
.Op Fl f Ar pluginopt
.Op Fl g
+.Op Fl i Ar lwp
.Op Fl k Ar kerneldir
.Op Fl l Ar secs
.Op Fl m Ar pathname
@@ -64,6 +66,7 @@
.Op Fl r Ar fsroot
.Op Fl s Ar event-spec
.Op Fl t Ar process-spec
+.Op Fl u Ar event-spec
.Op Fl v
.Op Fl w Ar secs
.Op Fl z Ar graphdepth
@@ -159,13 +162,8 @@ this information is sent to the output file specified by the
option.
.It Fl I
Skip symbol lookup and display address instead.
-.It Fl L Ar lwp
-Filter on thread ID
-.Ar lwp ,
-which you can get from
-.Xr ps 1
-.Fl o
-.Li lwp .
+.It Fl L
+List all event names.
.It Fl M Ar mapfilename
Write the mapping between executable objects encountered in the event
log and the abbreviated pathnames used for
@@ -228,6 +226,8 @@ can be used: 'c+a' switch to accumulative mode, 'c+d' switch
to delta mode, 'm' merge PMCs, 'n' change view, 'p' show next
PMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold
is seen as a dot.
+.It Fl U Ar event-spec
+Provide long description of event.
.It Fl W
Toggle logging the incremental counts seen by the threads of a
tracked process each time they are scheduled on a CPU.
@@ -291,6 +291,13 @@ A separate profile file is generated for each executable object
encountered.
Profile files are placed in sub-directories named by their PMC
event name.
+.It Fl i Ar lwp
+Filter on thread ID
+.Ar lwp ,
+which you can get from
+.Xr ps 1
+.Fl o
+.Li lwp .
.It Fl k Ar kerneldir
Set the pathname of the kernel directory to argument
.Ar kerneldir .
@@ -363,6 +370,8 @@ Argument
.Ar process-spec
may be a non-negative integer denoting a specific process id, or a
regular expression for selecting processes based on their command names.
+.It Fl u Ar event-spec
+Provide short description of event.
.It Fl v
Increase verbosity.
.It Fl w Ar secs
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 63716e0e5c0d..45b272b60b59 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -365,8 +365,8 @@ pmcstat_show_usage(void)
"\t -F file\t write a system-wide callgraph (Kcachegrind format)"
" to \"file\"\n"
"\t -G file\t write a system-wide callgraph to \"file\"\n"
- "\t -I don't resolve leaf function name, show address instead\n"
- "\t -L lwp\t filter on thread id \"lwp\" in post-processing\n"
+ "\t -I\t\t don't resolve leaf function name, show address instead\n"
+ "\t -L\t\t list all counters available on this host\n"
"\t -M file\t print executable/gmon file map to \"file\"\n"
"\t -N\t\t (toggle) capture callchains\n"
"\t -O file\t send log output to \"file\"\n"
@@ -374,6 +374,7 @@ pmcstat_show_usage(void)
"\t -R file\t read events from \"file\"\n"
"\t -S spec\t allocate a system-wide sampling PMC\n"
"\t -T\t\t start in top mode\n"
+ "\t -U spec \t provide long description of counters matching spec\n"
"\t -W\t\t (toggle) show counts per context switch\n"
"\t -a file\t print sampled PCs and callgraph to \"file\"\n"
"\t -c cpu-list\t set cpus for subsequent system-wide PMCs\n"
@@ -381,6 +382,7 @@ pmcstat_show_usage(void)
"\t -e\t\t use wide history counter for gprof(1) output\n"
"\t -f spec\t pass \"spec\" to as plugin option\n"
"\t -g\t\t produce gprof(1) compatible profiles\n"
+ "\t -i lwp\t\t filter on thread id \"lwp\" in post-processing\n"
"\t -k dir\t\t set the path to the kernel\n"
"\t -l secs\t set duration time\n"
"\t -m file\t print sampled PCs to \"file\"\n"
@@ -392,6 +394,7 @@ pmcstat_show_usage(void)
"\t -s spec\t allocate a system-wide counting PMC\n"
"\t -t process-spec attach to running processes matching "
"\"process-spec\"\n"
+ "\t -u spec \t provide short description of counters matching spec\n"
"\t -v\t\t increase verbosity\n"
"\t -w secs\t set printing time interval\n"
"\t -z depth\t limit callchain display depth"
@@ -429,14 +432,14 @@ main(int argc, char **argv)
int option, npmc;
int c, check_driver_stats;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
- int do_print, do_read;
+ int do_print, do_read, do_listcounters, do_descr, do_long_descr;
size_t len;
int graphdepth;
int pipefd[2], rfd;
int use_cumulative_counts;
short cf, cb;
uint64_t current_sampling_count;
- char *end, *tmp;
+ char *end, *tmp, *event;
const char *errmsg, *graphfilename;
enum pmcstat_state runstate;
struct pmc_driverstats ds_start, ds_end;
@@ -450,9 +453,12 @@ main(int argc, char **argv)
check_driver_stats = 0;
current_sampling_count = 0;
do_callchain = 1;
+ do_descr = 0;
do_descendants = 0;
+ do_long_descr = 0;
do_logproccsw = 0;
do_logprocexit = 0;
+ do_listcounters = 0;
use_cumulative_counts = 0;
graphfilename = "-";
args.pa_required = 0;
@@ -503,7 +509,7 @@ main(int argc, char **argv)
CPU_COPY(&rootmask, &cpumask);
while ((option = getopt(argc, argv,
- "CD:EF:G:IL:M:NO:P:R:S:TWa:c:def:gk:l:m:n:o:p:qr:s:t:vw:z:")) != -1)
+ "CD:EF:G:ILM:NO:P:R:S:TU:WZa:c:def:gi:k:l:m:n:o:p:qr:s:t:u:vw:z:")) != -1)
switch (option) {
case 'a': /* Annotate + callgraph */
args.pa_flags |= FLAG_DO_ANNOTATE;
@@ -544,6 +550,12 @@ main(int argc, char **argv)
args.pa_required |= FLAG_HAS_PROCESS_PMCS;
break;
+ case 'E': /* log process exit */
+ do_logprocexit = !do_logprocexit;
+ args.pa_required |= (FLAG_HAS_PROCESS_PMCS |
+ FLAG_HAS_COUNTING_PMCS | FLAG_HAS_OUTPUT_LOGFILE);
+ break;
+
case 'e': /* wide gprof metrics */
args.pa_flags |= FLAG_DO_WIDE_GPROF_HC;
break;
@@ -575,6 +587,11 @@ main(int argc, char **argv)
case 'I':
args.pa_flags |= FLAG_SKIP_TOP_FN_RES;
break;
+ case 'i':
+ args.pa_flags |= FLAG_FILTER_THREAD_ID;
+ args.pa_tid = strtol(optarg, &end, 0);
+ break;
+
case 'k': /* pathname to the kernel */
free(args.pa_kernel);
args.pa_kernel = strdup(optarg);
@@ -585,9 +602,9 @@ main(int argc, char **argv)
break;
case 'L':
- args.pa_flags |= FLAG_FILTER_THREAD_ID;
- args.pa_tid = strtol(optarg, &end, 0);
+ do_listcounters = 1;
break;
+
case 'l': /* time duration in seconds */
duration = strtod(optarg, &end);
if (*end != '\0' || duration <= 0)
@@ -603,12 +620,6 @@ main(int argc, char **argv)
graphfilename = optarg;
break;
- case 'E': /* log process exit */
- do_logprocexit = !do_logprocexit;
- args.pa_required |= (FLAG_HAS_PROCESS_PMCS |
- FLAG_HAS_COUNTING_PMCS | FLAG_HAS_OUTPUT_LOGFILE);
- break;
-
case 'M': /* mapfile */
args.pa_mapfilename = optarg;
break;
@@ -655,7 +666,7 @@ main(int argc, char **argv)
errx(EX_SOFTWARE, "ERROR: Out of memory.");
if (option == 'S' || option == 'P')
- ev->ev_count = current_sampling_count ? current_sampling_count : pmcstat_pmu_sample_rate_get(ev->ev_spec);
+ ev->ev_count = current_sampling_count ? current_sampling_count : pmc_pmu_sample_rate_get(ev->ev_spec);
else
ev->ev_count = -1;
@@ -760,6 +771,14 @@ main(int argc, char **argv)
args.pa_printfile = stdout;
break;
+ case 'u':
+ do_descr = 1;
+ event = optarg;
+ break;
+ case 'U':
+ do_long_descr = 1;
+ event = optarg;
+ break;
case 'v': /* verbose */
args.pa_verbosity++;
break;
@@ -796,6 +815,18 @@ main(int argc, char **argv)
break;
}
+ if ((do_listcounters | do_descr | do_long_descr) &&
+ pmc_pmu_enabled() == 0)
+ errx(EX_USAGE, "pmu features not supported on host or hwpmc not loaded");
+ if (do_listcounters) {
+ pmc_pmu_print_counters();
+ } else if (do_descr) {
+ pmc_pmu_print_counter_desc(event);
+ } else if (do_long_descr) {
+ pmc_pmu_print_counter_desc_long(event);
+ }
+ if (do_listcounters | do_descr | do_long_descr)
+ exit(0);
args.pa_argc = (argc -= optind);
args.pa_argv = (argv += optind);
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index cc3e9c49203f..5f88d274f393 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -423,13 +423,6 @@ pmcstat_print_log(void)
(void *) ev.pl_u.pl_mo.pl_start,
(void *) ev.pl_u.pl_mo.pl_end);
break;
- case PMCLOG_TYPE_PCSAMPLE:
- PMCSTAT_PRINT_ENTRY("sample","0x%x %d %p %c",
- ev.pl_u.pl_s.pl_pmcid,
- ev.pl_u.pl_s.pl_pid,
- (void *) ev.pl_u.pl_s.pl_pc,
- ev.pl_u.pl_s.pl_usermode ? 'u' : 's');
- break;
case PMCLOG_TYPE_PMCALLOCATE:
PMCSTAT_PRINT_ENTRY("allocate","0x%x \"%s\" 0x%x",
ev.pl_u.pl_a.pl_pmcid,