From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/41] perf vendor events: Support metric_group and no event name in JSON parser
Date: Tue, 12 Sep 2017 12:09:51 -0300 [thread overview]
Message-ID: <20170912151029.6612-4-acme@kernel.org> (raw)
In-Reply-To: <20170912151029.6612-1-acme@kernel.org>
From: Andi Kleen <ak@linux.intel.com>
Some enhancements to the JSON parser to prepare for metrics support
- Parse the new MetricGroup field
- Support JSON events with no event name, that have only MetricName.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170831194036.30146-3-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/pmu-events/jevents.c | 24 ++++++++++++++++++------
tools/perf/pmu-events/jevents.h | 2 +-
tools/perf/pmu-events/pmu-events.h | 1 +
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index d51dc9ca8861..9eb7047bafe4 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -292,7 +292,7 @@ static int print_events_table_entry(void *data, char *name, char *event,
char *desc, char *long_desc,
char *pmu, char *unit, char *perpkg,
char *metric_expr,
- char *metric_name)
+ char *metric_name, char *metric_group)
{
struct perf_entry_data *pd = data;
FILE *outfp = pd->outfp;
@@ -304,8 +304,10 @@ static int print_events_table_entry(void *data, char *name, char *event,
*/
fprintf(outfp, "{\n");
- fprintf(outfp, "\t.name = \"%s\",\n", name);
- fprintf(outfp, "\t.event = \"%s\",\n", event);
+ if (name)
+ fprintf(outfp, "\t.name = \"%s\",\n", name);
+ if (event)
+ fprintf(outfp, "\t.event = \"%s\",\n", event);
fprintf(outfp, "\t.desc = \"%s\",\n", desc);
fprintf(outfp, "\t.topic = \"%s\",\n", topic);
if (long_desc && long_desc[0])
@@ -320,6 +322,8 @@ static int print_events_table_entry(void *data, char *name, char *event,
fprintf(outfp, "\t.metric_expr = \"%s\",\n", metric_expr);
if (metric_name)
fprintf(outfp, "\t.metric_name = \"%s\",\n", metric_name);
+ if (metric_group)
+ fprintf(outfp, "\t.metric_group = \"%s\",\n", metric_group);
fprintf(outfp, "},\n");
return 0;
@@ -357,6 +361,9 @@ static char *real_event(const char *name, char *event)
{
int i;
+ if (!name)
+ return NULL;
+
for (i = 0; fixed[i].name; i++)
if (!strcasecmp(name, fixed[i].name))
return (char *)fixed[i].event;
@@ -369,7 +376,7 @@ int json_events(const char *fn,
char *long_desc,
char *pmu, char *unit, char *perpkg,
char *metric_expr,
- char *metric_name),
+ char *metric_name, char *metric_group),
void *data)
{
int err = -EIO;
@@ -397,6 +404,7 @@ int json_events(const char *fn,
char *unit = NULL;
char *metric_expr = NULL;
char *metric_name = NULL;
+ char *metric_group = NULL;
unsigned long long eventcode = 0;
struct msrmap *msr = NULL;
jsmntok_t *msrval = NULL;
@@ -476,6 +484,8 @@ int json_events(const char *fn,
addfield(map, &perpkg, "", "", val);
} else if (json_streq(map, field, "MetricName")) {
addfield(map, &metric_name, "", "", val);
+ } else if (json_streq(map, field, "MetricGroup")) {
+ addfield(map, &metric_group, "", "", val);
} else if (json_streq(map, field, "MetricExpr")) {
addfield(map, &metric_expr, "", "", val);
for (s = metric_expr; *s; s++)
@@ -501,10 +511,11 @@ int json_events(const char *fn,
addfield(map, &event, ",", filter, NULL);
if (msr != NULL)
addfield(map, &event, ",", msr->pname, msrval);
- fixname(name);
+ if (name)
+ fixname(name);
err = func(data, name, real_event(name, event), desc, long_desc,
- pmu, unit, perpkg, metric_expr, metric_name);
+ pmu, unit, perpkg, metric_expr, metric_name, metric_group);
free(event);
free(desc);
free(name);
@@ -516,6 +527,7 @@ int json_events(const char *fn,
free(unit);
free(metric_expr);
free(metric_name);
+ free(metric_group);
if (err)
break;
tok += j;
diff --git a/tools/perf/pmu-events/jevents.h b/tools/perf/pmu-events/jevents.h
index 611fac01913d..557994754410 100644
--- a/tools/perf/pmu-events/jevents.h
+++ b/tools/perf/pmu-events/jevents.h
@@ -6,7 +6,7 @@ int json_events(const char *fn,
char *long_desc,
char *pmu,
char *unit, char *perpkg, char *metric_expr,
- char *metric_name),
+ char *metric_name, char *metric_group),
void *data);
char *get_cpu_str(void);
diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
index 569eab3688dd..94fa1720f6fd 100644
--- a/tools/perf/pmu-events/pmu-events.h
+++ b/tools/perf/pmu-events/pmu-events.h
@@ -15,6 +15,7 @@ struct pmu_event {
const char *perpkg;
const char *metric_expr;
const char *metric_name;
+ const char *metric_group;
};
/*
--
2.13.5
next prev parent reply other threads:[~2017-09-12 15:10 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 15:09 [GIT PULL 00/41] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 01/41] perf sched timehist: Add pid and tid options Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 02/41] perf tools: Support weak groups in 'perf stat' Arnaldo Carvalho de Melo
2017-09-12 15:09 ` Arnaldo Carvalho de Melo [this message]
2017-09-12 15:09 ` [PATCH 04/41] perf stat: Factor out generic metric printing Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 05/41] perf stat: Print generic metric header even for failed expressions Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 06/41] perf pmu: Extract function to get JSON alias map Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 07/41] perf stat: Support JSON metrics in perf stat Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 08/41] perf list: Add metric groups to perf list Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 09/41] perf stat: Don't use ctx for saved values lookup Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 10/41] perf stat: Support duration_time for metrics Arnaldo Carvalho de Melo
2017-09-12 15:09 ` [PATCH 11/41] perf stat: Hide internal duration_time counter Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 12/41] perf stat: Update walltime_nsecs_stats in interval mode Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 13/41] tools include linux: Guard against redefinition of some macros Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 14/41] perf record: Support direct --user-regs arguments Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 15/41] perf script: Support user regs Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 16/41] perf tests: Fix compile when libunwind's unwind.h is available Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 17/41] tools lib api: Fix make DEBUG=1 build Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 18/41] perf tools: Open perf.data with O_CLOEXEC flag Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 19/41] perf tools: Add python-clean target Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 20/41] perf ui progress: Make sure we always define step value Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 21/41] perf ui progress: Fix progress update Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 22/41] perf ui progress: Add ui specific init function Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 23/41] perf ui progress: Add size info into progress bar Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 24/41] perf tools: Use scandir() to replace readdir() Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 25/41] perf config: Check not only section->from_system_config but also item's Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 26/41] perf config: Write a config file just once Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 27/41] perf config: Allow creating empty config set for config file autogeneration Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 28/41] perf tools: Make copyfile_offset() static Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 29/41] perf tools: Support running perf binaries with a dash in their name Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 30/41] perf stat: Fall weak group back even for EBADF Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 31/41] perf vendor events: Add JSON metrics for Broadwell Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 32/41] perf vendor events: Add JSON metrics for Skylake Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 33/41] perf vendor events: Add JSON metrics for Sandy Bridge Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 34/41] perf vendor events: Add JSON metrics for Sandy Bridge EP Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 35/41] perf vendor events: Add JSON metrics for Ivy Bridge Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 36/41] perf vendor events: Add JSON metrics for Haswell Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 37/41] perf vendor events: Add JSON metrics for Ivy Town Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 38/41] perf vendor events: Add JSON metrics for Haswell EP Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 39/41] perf vendor events: Add JSON metrics for Broadwell Server Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 40/41] perf vendor events: Add JSON metrics for Broadwell DE Arnaldo Carvalho de Melo
2017-09-12 15:10 ` [PATCH 41/41] perf vendor events: Add JSON metrics for Skylake server Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170912151029.6612-4-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).