Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-09 Thread Jiri Olsa
On Thu, Feb 08, 2018 at 03:25:30PM +, John Garry wrote: > On 08/02/2018 13:55, Jiri Olsa wrote: > > On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: > > > > SNIP > > > > > > > > +static int is_json_file(const char *name) > > > +{ > > > + const char *suffix; > > > + > > > + if (str

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread John Garry
On 08/02/2018 13:54, Jiri Olsa wrote: On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: Hi Jirka, I'll try to combine some responses, below: SNIP +static void fixup_field(char *from, char **to) +{ + *to = malloc(strlen(from)); + + strcpy(*to, from); +} + +#define EVE

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread John Garry
On 08/02/2018 14:02, Alan Cox wrote: On Thu, 8 Feb 2018 14:54:23 +0100 Jiri Olsa wrote: On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP static void print_events_table_suffix(FILE *outfp) { fprintf(outfp, "{\n"); @@ -407,6 +469,52 @@ static char *real_event(const c

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread John Garry
On 08/02/2018 13:55, Jiri Olsa wrote: On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP +static int is_json_file(const char *name) +{ + const char *suffix; + + if (strlen(name) < 5) + return 0; + + suffix = name + strlen(name) - 5; + + if (

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread John Garry
On 08/02/2018 13:55, Jiri Olsa wrote: On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: For some architectures (like arm), there are architecture- defined events. Sometimes these events may be "recommended" according to the architecture standard, in that the implementer is free ignore

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Thu, Feb 08, 2018 at 02:45:37PM +, John Garry wrote: > On 08/02/2018 13:55, Jiri Olsa wrote: > > On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: > > > > SNIP > > > > > + char *perpkg; > > > + char *unit; > > > + char *metric_expr; > > > + char *metric_name; > > > + char *metric

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread John Garry
On 08/02/2018 13:55, Jiri Olsa wrote: On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP + char *perpkg; + char *unit; + char *metric_expr; + char *metric_name; + char *metric_group; + struct list_head list; + char strings[]; +}; + +stati

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Alan Cox
On Thu, 8 Feb 2018 14:54:23 +0100 Jiri Olsa wrote: > On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: > > SNIP > > > static void print_events_table_suffix(FILE *outfp) > > { > > fprintf(outfp, "{\n"); > > @@ -407,6 +469,52 @@ static char *real_event(const char *name, char *even

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: > For some architectures (like arm), there are architecture- > defined events. Sometimes these events may be "recommended" > according to the architecture standard, in that the > implementer is free ignore the "recommendation" and create >

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > > +static int is_json_file(const char *name) > +{ > + const char *suffix; > + > + if (strlen(name) < 5) > + return 0; > + > + suffix = name + strlen(name) - 5; > + > + if (strncmp(suffix, ".json", 5)

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > rc = nftw(ldirname, process_one_file, maxfds, 0); > if (rc && verbose) { > pr_info("%s: Error walking file tree %s\n", prog, ldirname); > - goto empty_map; > + goto free_standard_a

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > /* Call func with each event in the json file */ > int json_events(const char *fn, > int (*func)(void *data, char *name, char *event, char *desc, > @@ -442,6 +550,7 @@ int json_events(const char *fn, > char

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > + char *perpkg; > + char *unit; > + char *metric_expr; > + char *metric_name; > + char *metric_group; > + struct list_head list; > + char strings[]; > +}; > + > +static LIST_HEAD(arch_std_events); > + >

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > + rc = nftw(ldirname, preprocess_arch_std_files, get_maxfds(), 0); > + if (rc && verbose) { > + pr_info("%s: Error preprocessing arch standard files %s\n", > + prog, ldirname); > +

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > @@ -940,6 +1090,7 @@ int main(int argc, char *argv[]) > const char *output_file; > const char *start_dirname; > struct stat stbuf; > + struct event_struct *es1, *es2; > > prog = basename(argv[0]); >

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > static void print_events_table_suffix(FILE *outfp) > { > fprintf(outfp, "{\n"); > @@ -407,6 +469,52 @@ static char *real_event(const char *name, char *event) > return event; > } > > +static void fixup_field(char *

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > @@ -366,6 +367,67 @@ static int print_events_table_entry(void *data, char > *name, char *event, > return 0; > } > > +struct event_struct { > + char *name; > + char *event; > + char *desc; > + char *long_d

Re: [PATCH 5/9] perf utils: add support for arch standard events

2018-02-08 Thread Jiri Olsa
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote: SNIP > +static void fixup_field(char *from, char **to) > +{ > + *to = malloc(strlen(from)); > + > + strcpy(*to, from); > +} > + > +#define EVENT_PREFIX "event=" > + > +#define TRY_FIXUP_FIELD(string) do { if (es->string && !

[PATCH 5/9] perf utils: add support for arch standard events

2018-02-06 Thread John Garry
For some architectures (like arm), there are architecture- defined events. Sometimes these events may be "recommended" according to the architecture standard, in that the implementer is free ignore the "recommendation" and create its custom event. This patch adds support for parsing standard event