Date: Wed, 23 May 2018 23:50:28 -0700 From: Cy Schubert <Cy.Schubert@cschubert.com> To: Matt Macy <mmacy@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334134 - head/lib/libpmcstat Message-ID: <201805240650.w4O6oSLw003786@slippy.cwsent.com> In-Reply-To: Message from Matt Macy <mmacy@FreeBSD.org> of "Thu, 24 May 2018 06:47:40 -0000." <201805240647.w4O6lesD071041@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <201805240647.w4O6lesD071041@repo.freebsd.org>, Matt Macy writes: > Author: mmacy > Date: Thu May 24 06:47:40 2018 > New Revision: 334134 > URL: https://svnweb.freebsd.org/changeset/base/334134 > > Log: > libpmcstat: import aliases table and bug fixes Which bugs? > > Modified: > head/lib/libpmcstat/libpmcstat_pmu_util.c > > Modified: head/lib/libpmcstat/libpmcstat_pmu_util.c > ============================================================================= > = > --- head/lib/libpmcstat/libpmcstat_pmu_util.c Thu May 24 06:47:04 2018 > (r334133) > +++ head/lib/libpmcstat/libpmcstat_pmu_util.c Thu May 24 06:47:40 2018 > (r334134) > @@ -42,6 +42,39 @@ > #include "pmu-events/pmu-events.h" > > #if defined(__amd64__) > +struct pmu_alias { > + const char *pa_alias; > + const char *pa_name; > +}; > +static struct pmu_alias pmu_alias_table[] = { > + { "UNHALTED_CORE_CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"}, > + { "UNHALTED-CORE-CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"}, > + { "LLC_MISSES", "LONGEST_LAT_CACHE.MISS"}, > + { "LLC-MISSES", "LONGEST_LAT_CACHE.MISS"}, > + { "LLC_REFERENCE", "LONGEST_LAT_CACHE.REFERENCE"}, > + { "LLC-REFERENCE", "LONGEST_LAT_CACHE.REFERENCE"}, > + { "LLC_MISS_RHITM", "mem_load_l3_miss_retired.remote_hitm"}, > + { "LLC-MISS-RHITM", "mem_load_l3_miss_retired.remote_hitm"}, > + { "RESOURCE_STALL", "RESOURCE_STALLS.ANY"}, > + { "RESOURCE_STALLS_ANY", "RESOURCE_STALLS.ANY"}, > + { "BRANCH_INSTRUCTION_RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"}, > + { "BRANCH-INSTRUCTION-RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"}, > + { "BRANCH_MISSES_RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"}, > + { "BRANCH-MISSES-RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"}, > + { NULL, NULL }, > +}; > + > +static const char * > +pmu_alias_get(const char *name) > +{ > + struct pmu_alias *pa; > + > + for (pa = pmu_alias_table; pa->pa_alias != NULL; pa++) > + if (strcasecmp(name, pa->pa_alias) == 0) > + return (pa->pa_name); > + return (name); > +} > + > struct pmu_event_desc { > uint32_t ped_umask; > uint32_t ped_event; > @@ -75,9 +108,12 @@ pmu_event_get(const char *event_name) > > if ((pme = pmu_events_map_get()) == NULL) > return (NULL); > - for (pe = pme->table; pe->name != NULL; pe++) > - if (strcmp(pe->name, event_name) == 0) > + for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) { > + if (pe->name == NULL) > + continue; > + if (strcasecmp(pe->name, event_name) == 0) > return (pe); > + } > return (NULL); > } > > @@ -100,7 +136,7 @@ pmu_parse_event(struct pmu_event_desc *ped, const char > if (strcmp(key, "event") == 0) > ped->ped_event = strtol(value, NULL, 16); > if (strcmp(key, "period") == 0) > - ped->ped_umask = strtol(value, NULL, 10); > + ped->ped_period = strtol(value, NULL, 10); > } > free(event); > return (0); > @@ -112,6 +148,7 @@ pmcstat_pmu_sample_rate_get(const char *event_name) > const struct pmu_event *pe; > struct pmu_event_desc ped; > > + event_name = pmu_alias_get(event_name); > if ((pe = pmu_event_get(event_name)) == NULL) > return (DEFAULT_SAMPLE_COUNT); > if (pe->alias && (pe = pmu_event_get(pe->alias)) == NULL) > -- Cheers, Cy Schubert <Cy.Schubert@cschubert.com> FreeBSD UNIX: <cy@FreeBSD.org> Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805240650.w4O6oSLw003786>