From owner-svn-src-all@freebsd.org Thu May 24 06:50:34 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46A61F5D3B0; Thu, 24 May 2018 06:50:34 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9AA3E79A87; Thu, 24 May 2018 06:50:33 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id Lk4zfGi75vB5RLk50fyFYV; Thu, 24 May 2018 00:50:31 -0600 X-Authority-Analysis: v=2.3 cv=PvS9kTE3 c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=VUJBJC2UJ8kA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=4XXRiJT-kNww1N-uVO8A:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id B556E8C6; Wed, 23 May 2018 23:50:28 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w4O6oSMk003789; Wed, 23 May 2018 23:50:28 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w4O6oSLw003786; Wed, 23 May 2018 23:50:28 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201805240650.w4O6oSLw003786@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Matt Macy cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334134 - head/lib/libpmcstat In-Reply-To: Message from Matt Macy of "Thu, 24 May 2018 06:47:40 -0000." <201805240647.w4O6lesD071041@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 23 May 2018 23:50:28 -0700 X-CMAE-Envelope: MS4wfEbrUFsRjBF+wlMPF+WEcwvmeApPIwAJm5TiUAW1P6/jhjD0xdM+/omTKWocj16IzM9OneVJ9RPr7BlmwWfFfWajglnko/Ka4BEbfkU/8gUjiBvB4HHu b26OSK+AgfM6UYIOh0PdWA4btXGqKc1WTX9Shro3rQ6RZxV+W6HmNLo4lfPOeAgdO/fzmRqbceHYi1wGPtTuZGmUEOWH7XuHAbZxBc+lh1U+rg+f2Rq6IRZM KYjKcB+DaDK33EFSWzTTUGdcVmgortefU4medUZPvCg+lpEOIgYqQirGdfxo9ZC0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2018 06:50:34 -0000 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 FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.