Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pmcstat/pmcstat.c
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
int pmcstat_displaywidth = DEFAULT_DISPLAY_WIDTH; | int pmcstat_displaywidth = DEFAULT_DISPLAY_WIDTH; | ||||
static int pmcstat_sockpair[NSOCKPAIRFD]; | static int pmcstat_sockpair[NSOCKPAIRFD]; | ||||
static int pmcstat_kq; | static int pmcstat_kq; | ||||
static kvm_t *pmcstat_kvm; | static kvm_t *pmcstat_kvm; | ||||
static struct kinfo_proc *pmcstat_plist; | static struct kinfo_proc *pmcstat_plist; | ||||
struct pmcstat_args args; | struct pmcstat_args args; | ||||
static bool libpmc_initialized = false; | static bool libpmc_initialized = false; | ||||
/* Allow for a 3 digit CPU ID */ | |||||
#define PMC_CPU_WIDTH 3 | |||||
static void | static void | ||||
pmcstat_get_cpumask(const char *cpuspec, cpuset_t *cpumask) | pmcstat_get_cpumask(const char *cpuspec, cpuset_t *cpumask) | ||||
{ | { | ||||
int cpu; | int cpu; | ||||
const char *s; | const char *s; | ||||
char *end; | char *end; | ||||
CPU_ZERO(cpumask); | CPU_ZERO(cpumask); | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | STAILQ_FOREACH(ev, &args.pa_events, ev_next) { | ||||
c = PMC_IS_SYSTEM_MODE(ev->ev_mode) ? 's' : 'p'; | c = PMC_IS_SYSTEM_MODE(ev->ev_mode) ? 's' : 'p'; | ||||
if (ev->ev_fieldskip != 0) | if (ev->ev_fieldskip != 0) | ||||
(void) fprintf(args.pa_printfile, "%*s", | (void) fprintf(args.pa_printfile, "%*s", | ||||
ev->ev_fieldskip, ""); | ev->ev_fieldskip, ""); | ||||
w = ev->ev_fieldwidth - ev->ev_fieldskip - 2; | w = ev->ev_fieldwidth - ev->ev_fieldskip - 2; | ||||
if (c == 's') | if (c == 's') | ||||
(void) fprintf(args.pa_printfile, "s/%02d/%-*s ", | (void) fprintf(args.pa_printfile, | ||||
ev->ev_cpu, w-3, ev->ev_name); | "s/%0"__XSTRING(PMC_CPU_WIDTH)"d/%-*s ", | ||||
ev->ev_cpu, w - PMC_CPU_WIDTH - 1, ev->ev_name); | |||||
else | else | ||||
(void) fprintf(args.pa_printfile, "p/%*s ", w, | (void) fprintf(args.pa_printfile, "p/%*s ", w, | ||||
ev->ev_name); | ev->ev_name); | ||||
} | } | ||||
(void) fflush(args.pa_printfile); | (void) fflush(args.pa_printfile); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 907 Lines • ▼ Show 20 Lines | STAILQ_FOREACH(ev, &args.pa_events, ev_next) { | ||||
int display_width; | int display_width; | ||||
int header_width; | int header_width; | ||||
(void) pmc_width(ev->ev_pmcid, &counter_width); | (void) pmc_width(ev->ev_pmcid, &counter_width); | ||||
header_width = strlen(ev->ev_name) + 2; /* prefix '%c/' */ | header_width = strlen(ev->ev_name) + 2; /* prefix '%c/' */ | ||||
display_width = (int) floor(counter_width / 3.32193) + 1; | display_width = (int) floor(counter_width / 3.32193) + 1; | ||||
if (PMC_IS_SYSTEM_MODE(ev->ev_mode)) | if (PMC_IS_SYSTEM_MODE(ev->ev_mode)) | ||||
header_width += 3; /* 2 digit CPU number + '/' */ | /* CPU number + '/' */ | ||||
header_width += PMC_CPU_WIDTH + 1; | |||||
if (header_width > display_width) { | if (header_width > display_width) { | ||||
ev->ev_fieldskip = 0; | ev->ev_fieldskip = 0; | ||||
ev->ev_fieldwidth = header_width; | ev->ev_fieldwidth = header_width; | ||||
} else { | } else { | ||||
ev->ev_fieldskip = display_width - | ev->ev_fieldskip = display_width - | ||||
header_width; | header_width; | ||||
ev->ev_fieldwidth = display_width; | ev->ev_fieldwidth = display_width; | ||||
▲ Show 20 Lines • Show All 296 Lines • Show Last 20 Lines |