summaryrefslogtreecommitdiff
path: root/tools/perf/pmu-events/jevents.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/pmu-events/jevents.c')
-rw-r--r--tools/perf/pmu-events/jevents.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index e2837260ca4d..079c77b6a2fd 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -322,7 +322,8 @@ 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_group)
+ char *metric_name, char *metric_group,
+ char *deprecated)
{
struct perf_entry_data *pd = data;
FILE *outfp = pd->outfp;
@@ -354,6 +355,8 @@ static int print_events_table_entry(void *data, char *name, char *event,
fprintf(outfp, "\t.metric_name = \"%s\",\n", metric_name);
if (metric_group)
fprintf(outfp, "\t.metric_group = \"%s\",\n", metric_group);
+ if (deprecated)
+ fprintf(outfp, "\t.deprecated = \"%s\",\n", deprecated);
fprintf(outfp, "},\n");
return 0;
@@ -371,6 +374,7 @@ struct event_struct {
char *metric_expr;
char *metric_name;
char *metric_group;
+ char *deprecated;
};
#define ADD_EVENT_FIELD(field) do { if (field) { \
@@ -398,6 +402,7 @@ struct event_struct {
op(metric_expr); \
op(metric_name); \
op(metric_group); \
+ op(deprecated); \
} while (0)
static LIST_HEAD(arch_std_events);
@@ -416,7 +421,8 @@ static void free_arch_std_events(void)
static int save_arch_std_events(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_group)
+ char *metric_name, char *metric_group,
+ char *deprecated)
{
struct event_struct *es;
@@ -479,7 +485,8 @@ static int
try_fixup(const char *fn, char *arch_std, char **event, char **desc,
char **name, char **long_desc, char **pmu, char **filter,
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)
{
/* try to find matching event from arch standard values */
struct event_struct *es;
@@ -507,7 +514,8 @@ int json_events(const char *fn,
char *long_desc,
char *pmu, char *unit, char *perpkg,
char *metric_expr,
- char *metric_name, char *metric_group),
+ char *metric_name, char *metric_group,
+ char *deprecated),
void *data)
{
int err;
@@ -536,6 +544,7 @@ int json_events(const char *fn,
char *metric_expr = NULL;
char *metric_name = NULL;
char *metric_group = NULL;
+ char *deprecated = NULL;
char *arch_std = NULL;
unsigned long long eventcode = 0;
struct msrmap *msr = NULL;
@@ -614,6 +623,8 @@ int json_events(const char *fn,
addfield(map, &unit, "", "", val);
} else if (json_streq(map, field, "PerPkg")) {
addfield(map, &perpkg, "", "", val);
+ } else if (json_streq(map, field, "Deprecated")) {
+ addfield(map, &deprecated, "", "", val);
} else if (json_streq(map, field, "MetricName")) {
addfield(map, &metric_name, "", "", val);
} else if (json_streq(map, field, "MetricGroup")) {
@@ -658,12 +669,14 @@ int json_events(const char *fn,
err = try_fixup(fn, arch_std, &event, &desc, &name,
&long_desc, &pmu, &filter, &perpkg,
&unit, &metric_expr, &metric_name,
- &metric_group, eventcode);
+ &metric_group, eventcode,
+ &deprecated);
if (err)
goto free_strings;
}
err = func(data, name, real_event(name, event), desc, long_desc,
- pmu, unit, perpkg, metric_expr, metric_name, metric_group);
+ pmu, unit, perpkg, metric_expr, metric_name,
+ metric_group, deprecated);
free_strings:
free(event);
free(desc);
@@ -673,6 +686,7 @@ free_strings:
free(pmu);
free(filter);
free(perpkg);
+ free(deprecated);
free(unit);
free(metric_expr);
free(metric_name);
@@ -758,6 +772,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
char *line, *p;
int line_num;
char *tblname;
+ int ret = 0;
pr_info("%s: Processing mapfile %s\n", prog, fpath);
@@ -769,6 +784,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
if (!mapfp) {
pr_info("%s: Error %s opening %s\n", prog, strerror(errno),
fpath);
+ free(line);
return -1;
}
@@ -795,7 +811,8 @@ static int process_mapfile(FILE *outfp, char *fpath)
/* TODO Deal with lines longer than 16K */
pr_info("%s: Mapfile %s: line %d too long, aborting\n",
prog, fpath, line_num);
- return -1;
+ ret = -1;
+ goto out;
}
line[strlen(line)-1] = '\0';
@@ -825,7 +842,9 @@ static int process_mapfile(FILE *outfp, char *fpath)
out:
print_mapping_table_suffix(outfp);
- return 0;
+ fclose(mapfp);
+ free(line);
+ return ret;
}
/*
@@ -1122,6 +1141,7 @@ int main(int argc, char *argv[])
goto empty_map;
} else if (rc < 0) {
/* Make build fail */
+ fclose(eventsfp);
free_arch_std_events();
return 1;
} else if (rc) {
@@ -1134,6 +1154,7 @@ int main(int argc, char *argv[])
goto empty_map;
} else if (rc < 0) {
/* Make build fail */
+ fclose(eventsfp);
free_arch_std_events();
return 1;
} else if (rc) {
@@ -1151,6 +1172,8 @@ int main(int argc, char *argv[])
if (process_mapfile(eventsfp, mapfile)) {
pr_info("%s: Error processing mapfile %s\n", prog, mapfile);
/* Make build fail */
+ fclose(eventsfp);
+ free_arch_std_events();
return 1;
}