Lines Matching +full:up +full:- +full:counting

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2003-2008, Joseph Koshy
73 * the system-wide and per-process variety. Each of these could be in
74 * 'counting mode' or in 'sampling mode'.
76 * For 'counting mode' PMCs, pmcstat(8) will periodically issue a
90 * - parent creates a socketpair for two way communication and
92 * - subsequently:
96 * - Wait for child's token.
97 * - Sends token.
98 * - Awaits signal to start.
99 * - Attaches PMCs to the child's pid
100 * and starts them. Sets up
102 * - Signals child to start.
103 * - Receives signal, attempts exec().
148 if (ev->ev_pmcid != PMC_ID_INVALID) { in pmcstat_cleanup()
149 if (pmc_stop(ev->ev_pmcid) < 0) in pmcstat_cleanup()
152 ev->ev_pmcid, ev->ev_name); in pmcstat_cleanup()
153 if (pmc_release(ev->ev_pmcid) < 0) in pmcstat_cleanup()
156 ev->ev_pmcid, ev->ev_name); in pmcstat_cleanup()
159 /* de-configure the log file if present. */ in pmcstat_cleanup()
161 (void) pmc_configure_logfile(-1); in pmcstat_cleanup()
186 pt->pt_pid = pid; in pmcstat_find_targets()
211 if ((rv = regexec(&reg, kp->ki_comm, 1, &regmatch, 0)) == 0) { in pmcstat_find_targets()
214 pt->pt_pid = kp->ki_pid; in pmcstat_find_targets()
241 * in the list, before any other processes specified by -t. in pmcstat_kill_process()
246 if (kill(pt->pt_pid, SIGINT) != 0) in pmcstat_kill_process()
257 assert(ev->ev_pmcid != PMC_ID_INVALID); in pmcstat_start_pmcs()
259 if (pmc_start(ev->ev_pmcid) < 0) { in pmcstat_start_pmcs()
261 ev->ev_pmcid, ev->ev_name); in pmcstat_start_pmcs()
277 if (PMC_IS_SAMPLING_MODE(ev->ev_mode)) in pmcstat_print_headers()
280 c = PMC_IS_SYSTEM_MODE(ev->ev_mode) ? 's' : 'p'; in pmcstat_print_headers()
282 if (ev->ev_fieldskip != 0) in pmcstat_print_headers()
284 ev->ev_fieldskip, ""); in pmcstat_print_headers()
285 w = ev->ev_fieldwidth - ev->ev_fieldskip - 2; in pmcstat_print_headers()
288 (void) fprintf(args.pa_printfile, "s/%02d/%-*s ", in pmcstat_print_headers()
289 ev->ev_cpu, w-3, ev->ev_name); in pmcstat_print_headers()
292 ev->ev_name); in pmcstat_print_headers()
305 extra_width = sizeof(PRINT_HEADER_PREFIX) - 1; in pmcstat_print_counters()
310 if (PMC_IS_SAMPLING_MODE(ev->ev_mode)) in pmcstat_print_counters()
313 if (pmc_read(ev->ev_pmcid, &value) < 0) in pmcstat_print_counters()
315 ev->ev_name); in pmcstat_print_counters()
318 ev->ev_fieldwidth + extra_width, in pmcstat_print_counters()
319 (uintmax_t) ev->ev_cumulative ? value : in pmcstat_print_counters()
320 (value - ev->ev_saved)); in pmcstat_print_counters()
322 if (ev->ev_cumulative == 0) in pmcstat_print_counters()
323 ev->ev_saved = value; in pmcstat_print_counters()
359 "\t -C\t\t (toggle) show cumulative counts\n" in pmcstat_show_usage()
360 "\t -D path\t create profiles in directory \"path\"\n" in pmcstat_show_usage()
361 "\t -E\t\t (toggle) show counts at process exit\n" in pmcstat_show_usage()
362 "\t -F file\t write a system-wide callgraph (Kcachegrind format)" in pmcstat_show_usage()
364 "\t -G file\t write a system-wide callgraph to \"file\"\n" in pmcstat_show_usage()
365 "\t -I\t\t don't resolve leaf function name, show address instead\n" in pmcstat_show_usage()
366 "\t -L\t\t list all counters available on this host\n" in pmcstat_show_usage()
367 "\t -M file\t print executable/gmon file map to \"file\"\n" in pmcstat_show_usage()
368 "\t -N\t\t (toggle) capture callchains\n" in pmcstat_show_usage()
369 "\t -O file\t send log output to \"file\"\n" in pmcstat_show_usage()
370 "\t -P spec\t allocate a process-private sampling PMC\n" in pmcstat_show_usage()
371 "\t -R file\t read events from \"file\"\n" in pmcstat_show_usage()
372 "\t -S spec\t allocate a system-wide sampling PMC\n" in pmcstat_show_usage()
373 "\t -T\t\t start in top mode\n" in pmcstat_show_usage()
374 "\t -U \t\t merged user kernel stack capture\n" in pmcstat_show_usage()
375 "\t -W\t\t (toggle) show counts per context switch\n" in pmcstat_show_usage()
376 "\t -a file\t print sampled PCs and callgraph to \"file\"\n" in pmcstat_show_usage()
377 "\t -c cpu-list\t set cpus for subsequent system-wide PMCs\n" in pmcstat_show_usage()
378 "\t -d\t\t (toggle) track descendants\n" in pmcstat_show_usage()
379 "\t -e\t\t use wide history counter for gprof(1) output\n" in pmcstat_show_usage()
380 "\t -f spec\t pass \"spec\" to as plugin option\n" in pmcstat_show_usage()
381 "\t -g\t\t produce gprof(1) compatible profiles\n" in pmcstat_show_usage()
382 "\t -i lwp\t\t filter on thread id \"lwp\" in post-processing\n" in pmcstat_show_usage()
383 "\t -l secs\t set duration time\n" in pmcstat_show_usage()
384 "\t -m file\t print sampled PCs to \"file\"\n" in pmcstat_show_usage()
385 "\t -n rate\t set sampling rate\n" in pmcstat_show_usage()
386 "\t -o file\t send print output to \"file\"\n" in pmcstat_show_usage()
387 "\t -p spec\t allocate a process-private counting PMC\n" in pmcstat_show_usage()
388 "\t -q\t\t suppress verbosity\n" in pmcstat_show_usage()
389 "\t -r fsroot\t specify FS root directory\n" in pmcstat_show_usage()
390 "\t -s spec\t allocate a system-wide counting PMC\n" in pmcstat_show_usage()
391 "\t -t process-spec attach to running processes matching " in pmcstat_show_usage()
392 "\"process-spec\"\n" in pmcstat_show_usage()
393 "\t -u spec \t provide short description of counters matching spec\n" in pmcstat_show_usage()
394 "\t -v\t\t increase verbosity\n" in pmcstat_show_usage()
395 "\t -w secs\t set printing time interval\n" in pmcstat_show_usage()
396 "\t -z depth\t limit callchain display depth" in pmcstat_show_usage()
477 graphfilename = "-"; in main()
481 args.pa_logfd = -1; in main()
509 if (sysctlbyname("vm.ndomains", &domains, &len, NULL, 0) == -1) in main()
516 if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, in main()
517 sizeof(rootmask), &rootmask) == -1) in main()
522 "ACD:EF:G:ILM:NO:P:R:S:TUWZa:c:def:gi:l:m:n:o:p:qr:s:t:u:vw:z:")) != -1) in main()
577 case 'F': /* produce a system-wide calltree */ in main()
585 err(EX_USAGE, "ERROR: Need -g/-G/-m/-T."); in main()
589 case 'G': /* produce a system-wide callgraph */ in main()
638 case 'p': /* process virtual counting PMC */ in main()
639 case 's': /* system-wide counting PMC */ in main()
641 case 'S': /* system-wide sampling PMC */ in main()
647 case 'p': ev->ev_mode = PMC_MODE_TC; break; in main()
648 case 's': ev->ev_mode = PMC_MODE_SC; break; in main()
649 case 'P': ev->ev_mode = PMC_MODE_TS; break; in main()
650 case 'S': ev->ev_mode = PMC_MODE_SS; break; in main()
671 ev->ev_spec = strdup(optarg); in main()
672 if (ev->ev_spec == NULL) in main()
676 …ev->ev_count = current_sampling_count ? current_sampling_count : pmc_pmu_sample_rate_get(ev->ev_sp… in main()
678 ev->ev_count = 0; in main()
681 ev->ev_cpu = CPU_FFS(&cpumask) - 1; in main()
683 ev->ev_cpu = PMC_CPU_ANY; in main()
685 ev->ev_flags = 0; in main()
687 ev->ev_flags |= PMC_F_CALLCHAIN; in main()
689 ev->ev_flags |= PMC_F_USERCALLCHAIN; in main()
692 ev->ev_flags |= PMC_F_DESCENDANTS; in main()
694 ev->ev_flags |= PMC_F_LOG_PROCEXIT; in main()
696 ev->ev_flags |= PMC_F_LOG_PROCCSW; in main()
698 ev->ev_cumulative = use_cumulative_counts; in main()
700 ev->ev_saved = 0LL; in main()
701 ev->ev_pmcid = PMC_ID_INVALID; in main()
705 ev->ev_name = malloc(c + 1); in main()
706 if (ev->ev_name == NULL) in main()
708 (void) strncpy(ev->ev_name, optarg, c); in main()
709 *(ev->ev_name + c) = '\0'; in main()
720 if (pmc_allocate(ev->ev_spec, ev->ev_mode, in main()
721 ev->ev_flags, ev->ev_cpu, &ev->ev_pmcid, in main()
722 ev->ev_count) < 0) in main()
724 "system-mode pmc with specification" in main()
725 " \"%s\"", ev->ev_spec); in main()
726 if (pmc_capabilities(ev->ev_pmcid, &caps)) { in main()
727 pmc_release(ev->ev_pmcid); in main()
736 pmc_release(ev->ev_pmcid); in main()
737 ev->ev_pmcid = PMC_ID_INVALID; in main()
756 CPU_SET(CPU_FFS(&dommask) - 1, &cpumask); in main()
761 CPU_CLR(ev->ev_cpu, &cpumask); in main()
763 CPU_SET(ev->ev_cpu, &cpumask); in main()
792 "ERROR: option -O may only be specified once."); in main()
808 "ERROR: option -R may only be specified once."); in main()
835 case 'U': /* toggle user-space callchain capture */ in main()
886 args.pa_argc = (argc -= optind); in main()
896 args.pa_cpumask = cpumask; /* For selecting CPUs using -R. */ in main()
909 /* disallow -O and -R together */ in main()
912 "ERROR: options -O and -R are mutually exclusive."); in main()
914 /* disallow -T and -l together */ in main()
917 errx(EX_USAGE, "ERROR: options -T and -l are mutually " in main()
920 /* -a and -m require -R */ in main()
923 args.pa_plugin == PMCSTAT_PL_ANNOTATE ? "-m" : "-a"); in main()
925 /* -m option is not allowed combined with -g or -G. */ in main()
929 "ERROR: option -m and -g | -G are mutually exclusive"); in main()
936 errmsg = "option -t"; in main()
941 "ERROR: option -R may not be used with %s.", in main()
947 /* check for -t pid without a process PMC spec */ in main()
952 "ERROR: option -t requires a process mode PMC to be specified." in main()
955 /* check for process-mode options without a command or -t pid */ in main()
959 "ERROR: options -d, -E, -p, -P, and -W require a command line or target process." in main()
962 /* check for -p | -P without a target process of some sort */ in main()
966 "ERROR: options -P and -p require a target process or a command line." in main()
969 /* check for process-mode options without a process-mode PMC */ in main()
973 "ERROR: options -d, -E, -t, and -W require a process mode PMC to be specified." in main()
976 /* check for -c cpu with no system mode PMCs or logfile. */ in main()
981 "ERROR: option -c requires at least one system mode PMC to be specified." in main()
984 /* check for counting mode options without a counting PMC */ in main()
988 "ERROR: options -C, -W and -o require at least one counting mode PMC to be specified." in main()
995 "ERROR: options -N, -n and -O require at least one sampling mode PMC to be specified." in main()
998 /* check if -g/-G/-m/-T are being used correctly */ in main()
1002 "ERROR: options -g/-G/-m/-T require sampling PMCs or -R to be specified." in main()
1005 /* check if -e was specified without -g */ in main()
1009 "ERROR: option -e requires gprof mode to be specified." in main()
1012 /* check if -O was spuriously specified */ in main()
1016 "ERROR: option -O is used only with options -E, -P, -S and -W." in main()
1019 /* -D only applies to gprof output mode (-g) */ in main()
1022 errx(EX_USAGE, "ERROR: option -D is only used with -g."); in main()
1024 /* -M mapfile requires -g or -R */ in main()
1028 errx(EX_USAGE, "ERROR: option -M is only used with -g/-R."); in main()
1031 * Disallow textual output of sampling PMCs if counting PMCs in main()
1039 "ERROR: option -O is required if counting and sampling PMCs are specified together." in main()
1046 if (strcmp(graphfilename, "-") == 0) in main()
1139 if (pmc_allocate(ev->ev_spec, ev->ev_mode, in main()
1140 ev->ev_flags, ev->ev_cpu, &ev->ev_pmcid, in main()
1141 ev->ev_count) < 0) in main()
1143 "ERROR: Cannot allocate %s-mode pmc with specification \"%s\"", in main()
1144 PMC_IS_SYSTEM_MODE(ev->ev_mode) ? in main()
1145 "system" : "process", ev->ev_spec); in main()
1147 if (PMC_IS_SAMPLING_MODE(ev->ev_mode) && in main()
1148 pmc_set(ev->ev_pmcid, ev->ev_count) < 0) in main()
1151 ev->ev_name); in main()
1160 (void) pmc_width(ev->ev_pmcid, &counter_width); in main()
1161 header_width = strlen(ev->ev_name) + 2; /* prefix '%c/' */ in main()
1164 if (PMC_IS_SYSTEM_MODE(ev->ev_mode)) in main()
1168 ev->ev_fieldskip = 0; in main()
1169 ev->ev_fieldwidth = header_width; in main()
1171 ev->ev_fieldskip = display_width - in main()
1173 ev->ev_fieldwidth = display_width; in main()
1187 pmcstat_displayheight = ws.ws_row - 1; in main()
1188 pmcstat_displaywidth = ws.ws_col - 1; in main()
1220 * kqueue to pick up the signal. in main()
1227 * Setup a timer if we have counting mode PMCs needing to be printed or in main()
1324 pmcstat_displayheight--; pmcstat_displaywidth--; in main()
1391 pmcstat_displayheight = ws.ws_row - 1; in main()
1392 pmcstat_displaywidth = ws.ws_col - 1; in main()
1404 /* print out counting PMCs */ in main()
1450 ds_end.pm_intr_bufferfull - in main()
1452 ((ds_end.pm_intr_bufferfull - in main()
1461 ds_end.pm_buffer_requests_failed - in main()
1463 ((ds_end.pm_buffer_requests_failed - in main()