diff options
author | Matt Macy <mmacy@FreeBSD.org> | 2018-05-26 19:29:19 +0000 |
---|---|---|
committer | Matt Macy <mmacy@FreeBSD.org> | 2018-05-26 19:29:19 +0000 |
commit | 959826ca1bb0a42ddd624bf1803ae2957a3282f3 (patch) | |
tree | c994717317a845c2afb2fd2d79beb650af57fafd /usr.sbin | |
parent | 5506ceb87fa19140863b4e3ee978f631ccc4cf74 (diff) | |
download | src-959826ca1bb0a42ddd624bf1803ae2957a3282f3.tar.gz src-959826ca1bb0a42ddd624bf1803ae2957a3282f3.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.
Notes
Notes:
svn path=/head/; revision=334244
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pmcstat/pmcstat.8 | 25 | ||||
-rw-r--r-- | usr.sbin/pmcstat/pmcstat.c | 59 | ||||
-rw-r--r-- | usr.sbin/pmcstat/pmcstat_log.c | 7 |
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, |