Commit 794ba54a authored by Sukadev Bhattiprolu's avatar Sukadev Bhattiprolu Committed by Arnaldo Carvalho de Melo

perf jevents: Add support for long descriptions

Implement support in jevents to parse long descriptions for events that
may have them in the JSON files. A follow on patch will make this long
description available to user through the 'perf list' command.
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1473978296-20712-11-git-send-email-sukadev@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fc06e2a5
...@@ -269,7 +269,7 @@ static void print_events_table_prefix(FILE *fp, const char *tblname) ...@@ -269,7 +269,7 @@ static void print_events_table_prefix(FILE *fp, const char *tblname)
} }
static int print_events_table_entry(void *data, char *name, char *event, static int print_events_table_entry(void *data, char *name, char *event,
char *desc) char *desc, char *long_desc)
{ {
struct perf_entry_data *pd = data; struct perf_entry_data *pd = data;
FILE *outfp = pd->outfp; FILE *outfp = pd->outfp;
...@@ -285,6 +285,8 @@ static int print_events_table_entry(void *data, char *name, char *event, ...@@ -285,6 +285,8 @@ static int print_events_table_entry(void *data, char *name, char *event,
fprintf(outfp, "\t.event = \"%s\",\n", event); fprintf(outfp, "\t.event = \"%s\",\n", event);
fprintf(outfp, "\t.desc = \"%s\",\n", desc); fprintf(outfp, "\t.desc = \"%s\",\n", desc);
fprintf(outfp, "\t.topic = \"%s\",\n", topic); fprintf(outfp, "\t.topic = \"%s\",\n", topic);
if (long_desc && long_desc[0])
fprintf(outfp, "\t.long_desc = \"%s\",\n", long_desc);
fprintf(outfp, "},\n"); fprintf(outfp, "},\n");
...@@ -306,7 +308,8 @@ static void print_events_table_suffix(FILE *outfp) ...@@ -306,7 +308,8 @@ static void print_events_table_suffix(FILE *outfp)
/* Call func with each event in the json file */ /* Call func with each event in the json file */
int json_events(const char *fn, int json_events(const char *fn,
int (*func)(void *data, char *name, char *event, char *desc), int (*func)(void *data, char *name, char *event, char *desc,
char *long_desc),
void *data) void *data)
{ {
int err = -EIO; int err = -EIO;
...@@ -325,6 +328,8 @@ int json_events(const char *fn, ...@@ -325,6 +328,8 @@ int json_events(const char *fn,
tok = tokens + 1; tok = tokens + 1;
for (i = 0; i < tokens->size; i++) { for (i = 0; i < tokens->size; i++) {
char *event = NULL, *desc = NULL, *name = NULL; char *event = NULL, *desc = NULL, *name = NULL;
char *long_desc = NULL;
char *extra_desc = NULL;
struct msrmap *msr = NULL; struct msrmap *msr = NULL;
jsmntok_t *msrval = NULL; jsmntok_t *msrval = NULL;
jsmntok_t *precise = NULL; jsmntok_t *precise = NULL;
...@@ -350,6 +355,10 @@ int json_events(const char *fn, ...@@ -350,6 +355,10 @@ int json_events(const char *fn,
} else if (json_streq(map, field, "BriefDescription")) { } else if (json_streq(map, field, "BriefDescription")) {
addfield(map, &desc, "", "", val); addfield(map, &desc, "", "", val);
fixdesc(desc); fixdesc(desc);
} else if (json_streq(map, field,
"PublicDescription")) {
addfield(map, &long_desc, "", "", val);
fixdesc(long_desc);
} else if (json_streq(map, field, "PEBS") && nz) { } else if (json_streq(map, field, "PEBS") && nz) {
precise = val; precise = val;
} else if (json_streq(map, field, "MSRIndex") && nz) { } else if (json_streq(map, field, "MSRIndex") && nz) {
...@@ -358,10 +367,10 @@ int json_events(const char *fn, ...@@ -358,10 +367,10 @@ int json_events(const char *fn,
msrval = val; msrval = val;
} else if (json_streq(map, field, "Errata") && } else if (json_streq(map, field, "Errata") &&
!json_streq(map, val, "null")) { !json_streq(map, val, "null")) {
addfield(map, &desc, ". ", addfield(map, &extra_desc, ". ",
" Spec update: ", val); " Spec update: ", val);
} else if (json_streq(map, field, "Data_LA") && nz) { } else if (json_streq(map, field, "Data_LA") && nz) {
addfield(map, &desc, ". ", addfield(map, &extra_desc, ". ",
" Supports address when precise", " Supports address when precise",
NULL); NULL);
} }
...@@ -369,19 +378,26 @@ int json_events(const char *fn, ...@@ -369,19 +378,26 @@ int json_events(const char *fn,
} }
if (precise && desc && !strstr(desc, "(Precise Event)")) { if (precise && desc && !strstr(desc, "(Precise Event)")) {
if (json_streq(map, precise, "2")) if (json_streq(map, precise, "2"))
addfield(map, &desc, " ", "(Must be precise)", addfield(map, &extra_desc, " ",
NULL); "(Must be precise)", NULL);
else else
addfield(map, &desc, " ", addfield(map, &extra_desc, " ",
"(Precise event)", NULL); "(Precise event)", NULL);
} }
if (desc && extra_desc)
addfield(map, &desc, " ", extra_desc, NULL);
if (long_desc && extra_desc)
addfield(map, &long_desc, " ", extra_desc, NULL);
if (msr != NULL) if (msr != NULL)
addfield(map, &event, ",", msr->pname, msrval); addfield(map, &event, ",", msr->pname, msrval);
fixname(name); fixname(name);
err = func(data, name, event, desc);
err = func(data, name, event, desc, long_desc);
free(event); free(event);
free(desc); free(desc);
free(name); free(name);
free(long_desc);
free(extra_desc);
if (err) if (err)
break; break;
tok += j; tok += j;
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#define JEVENTS_H 1 #define JEVENTS_H 1
int json_events(const char *fn, int json_events(const char *fn,
int (*func)(void *data, char *name, char *event, char *desc), int (*func)(void *data, char *name, char *event, char *desc,
char *long_desc),
void *data); void *data);
char *get_cpu_str(void); char *get_cpu_str(void);
......
...@@ -9,6 +9,7 @@ struct pmu_event { ...@@ -9,6 +9,7 @@ struct pmu_event {
const char *event; const char *event;
const char *desc; const char *desc;
const char *topic; const char *topic;
const char *long_desc;
}; };
/* /*
......
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