Commit 03fe02b1 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf jevents: Support metric constraint

A new field "MetricConstraint" is introduced in JSON event list.

Extend jevents to parse the field and save the value in
metric_constraint.
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Link: http://lore.kernel.org/lkml/1582581564-184429-2-git-send-email-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e7950166
...@@ -323,7 +323,7 @@ static int print_events_table_entry(void *data, char *name, char *event, ...@@ -323,7 +323,7 @@ static int print_events_table_entry(void *data, char *name, char *event,
char *pmu, char *unit, char *perpkg, char *pmu, char *unit, char *perpkg,
char *metric_expr, char *metric_expr,
char *metric_name, char *metric_group, char *metric_name, char *metric_group,
char *deprecated) char *deprecated, char *metric_constraint)
{ {
struct perf_entry_data *pd = data; struct perf_entry_data *pd = data;
FILE *outfp = pd->outfp; FILE *outfp = pd->outfp;
...@@ -357,6 +357,8 @@ static int print_events_table_entry(void *data, char *name, char *event, ...@@ -357,6 +357,8 @@ static int print_events_table_entry(void *data, char *name, char *event,
fprintf(outfp, "\t.metric_group = \"%s\",\n", metric_group); fprintf(outfp, "\t.metric_group = \"%s\",\n", metric_group);
if (deprecated) if (deprecated)
fprintf(outfp, "\t.deprecated = \"%s\",\n", deprecated); fprintf(outfp, "\t.deprecated = \"%s\",\n", deprecated);
if (metric_constraint)
fprintf(outfp, "\t.metric_constraint = \"%s\",\n", metric_constraint);
fprintf(outfp, "},\n"); fprintf(outfp, "},\n");
return 0; return 0;
...@@ -375,6 +377,7 @@ struct event_struct { ...@@ -375,6 +377,7 @@ struct event_struct {
char *metric_name; char *metric_name;
char *metric_group; char *metric_group;
char *deprecated; char *deprecated;
char *metric_constraint;
}; };
#define ADD_EVENT_FIELD(field) do { if (field) { \ #define ADD_EVENT_FIELD(field) do { if (field) { \
...@@ -422,7 +425,7 @@ static int save_arch_std_events(void *data, char *name, char *event, ...@@ -422,7 +425,7 @@ static int save_arch_std_events(void *data, char *name, char *event,
char *desc, char *long_desc, char *pmu, char *desc, char *long_desc, char *pmu,
char *unit, char *perpkg, char *metric_expr, char *unit, char *perpkg, char *metric_expr,
char *metric_name, char *metric_group, char *metric_name, char *metric_group,
char *deprecated) char *deprecated, char *metric_constraint)
{ {
struct event_struct *es; struct event_struct *es;
...@@ -486,7 +489,7 @@ try_fixup(const char *fn, char *arch_std, char **event, char **desc, ...@@ -486,7 +489,7 @@ try_fixup(const char *fn, char *arch_std, char **event, char **desc,
char **name, char **long_desc, char **pmu, char **filter, char **name, char **long_desc, char **pmu, char **filter,
char **perpkg, char **unit, char **metric_expr, char **metric_name, char **perpkg, char **unit, char **metric_expr, char **metric_name,
char **metric_group, unsigned long long eventcode, char **metric_group, unsigned long long eventcode,
char **deprecated) char **deprecated, char **metric_constraint)
{ {
/* try to find matching event from arch standard values */ /* try to find matching event from arch standard values */
struct event_struct *es; struct event_struct *es;
...@@ -515,7 +518,7 @@ int json_events(const char *fn, ...@@ -515,7 +518,7 @@ int json_events(const char *fn,
char *pmu, char *unit, char *perpkg, char *pmu, char *unit, char *perpkg,
char *metric_expr, char *metric_expr,
char *metric_name, char *metric_group, char *metric_name, char *metric_group,
char *deprecated), char *deprecated, char *metric_constraint),
void *data) void *data)
{ {
int err; int err;
...@@ -545,6 +548,7 @@ int json_events(const char *fn, ...@@ -545,6 +548,7 @@ int json_events(const char *fn,
char *metric_name = NULL; char *metric_name = NULL;
char *metric_group = NULL; char *metric_group = NULL;
char *deprecated = NULL; char *deprecated = NULL;
char *metric_constraint = NULL;
char *arch_std = NULL; char *arch_std = NULL;
unsigned long long eventcode = 0; unsigned long long eventcode = 0;
struct msrmap *msr = NULL; struct msrmap *msr = NULL;
...@@ -629,6 +633,8 @@ int json_events(const char *fn, ...@@ -629,6 +633,8 @@ int json_events(const char *fn,
addfield(map, &metric_name, "", "", val); addfield(map, &metric_name, "", "", val);
} else if (json_streq(map, field, "MetricGroup")) { } else if (json_streq(map, field, "MetricGroup")) {
addfield(map, &metric_group, "", "", val); addfield(map, &metric_group, "", "", val);
} else if (json_streq(map, field, "MetricConstraint")) {
addfield(map, &metric_constraint, "", "", val);
} else if (json_streq(map, field, "MetricExpr")) { } else if (json_streq(map, field, "MetricExpr")) {
addfield(map, &metric_expr, "", "", val); addfield(map, &metric_expr, "", "", val);
for (s = metric_expr; *s; s++) for (s = metric_expr; *s; s++)
...@@ -670,13 +676,13 @@ int json_events(const char *fn, ...@@ -670,13 +676,13 @@ int json_events(const char *fn,
&long_desc, &pmu, &filter, &perpkg, &long_desc, &pmu, &filter, &perpkg,
&unit, &metric_expr, &metric_name, &unit, &metric_expr, &metric_name,
&metric_group, eventcode, &metric_group, eventcode,
&deprecated); &deprecated, &metric_constraint);
if (err) if (err)
goto free_strings; goto free_strings;
} }
err = func(data, name, real_event(name, event), desc, long_desc, 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, deprecated); metric_group, deprecated, metric_constraint);
free_strings: free_strings:
free(event); free(event);
free(desc); free(desc);
...@@ -691,6 +697,7 @@ int json_events(const char *fn, ...@@ -691,6 +697,7 @@ int json_events(const char *fn,
free(metric_expr); free(metric_expr);
free(metric_name); free(metric_name);
free(metric_group); free(metric_group);
free(metric_constraint);
free(arch_std); free(arch_std);
if (err) if (err)
......
...@@ -8,7 +8,7 @@ int json_events(const char *fn, ...@@ -8,7 +8,7 @@ int json_events(const char *fn,
char *pmu, char *pmu,
char *unit, char *perpkg, char *metric_expr, char *unit, char *perpkg, char *metric_expr,
char *metric_name, char *metric_group, char *metric_name, char *metric_group,
char *deprecated), char *deprecated, char *metric_constraint),
void *data); void *data);
char *get_cpu_str(void); char *get_cpu_str(void);
......
...@@ -18,6 +18,7 @@ struct pmu_event { ...@@ -18,6 +18,7 @@ struct pmu_event {
const char *metric_name; const char *metric_name;
const char *metric_group; const char *metric_group;
const char *deprecated; const char *deprecated;
const char *metric_constraint;
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment