perf c2c: fix '-e list'
Ian Rogers
reviewerPATCH v3 1/1 perf c2c: fix '-e list'
When the event is passed as list, the default events should be listed as per 'perf mem record -e list'. Previous behavior is:
$ perf c2c record -e list failed: event 'list' not found, use '-e list' to get list of available events
Usage: perf c2c record [<options>] [<command>]
or: perf c2c record [<options>] -- <command> [<options>]
-e, --event <event> event selector. Use 'perf mem record -e list' to list available events
New behavior:
$ perf c2c record -e list ldlat-loads : available ldlat-stores : available
v3: is a rebase.
v2: addresses review comments by Jiri Olsa.
https://lore.kernel.org/lkml/20191127081844.GH32367@krava/
--- tools/perf/Documentation/perf-c2c.txt | 2 +- tools/perf/builtin-c2c.c | 9 ++++++++- tools/perf/builtin-mem.c | 24 +++++++----------------- tools/perf/util/mem-events.c | 15 +++++++++++++++ tools/perf/util/mem-events.h | 2 ++ 5 files changed, 33 insertions(+), 19 deletions(-)
tools/perf/Documentation/perf-c2c.txt +1 -1
@@ -40,7 +40,7 @@ RECORD OPTIONS -------------- -e:: --event=:: - Select the PMU event. Use 'perf mem record -e list' + Select the PMU event. Use 'perf c2c record -e list' to list available events. -v::
tools/perf/builtin-c2c.c +8 -1
@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt, {bool *event_set = (bool *) opt->value; +if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); + } +if (perf_mem_events__parse (str)) +exit (-1 ); + *event_set = true; -return perf_mem_events__parse (str); +return 0 ; }
tools/perf/builtin-mem.c +7 -17
@@ -38,26 +38,16 @@ static int parse_record_events(const struct option *opt, const char *str, int unset __maybe_unused) {struct perf_mem *mem = *(struct perf_mem **)opt->value; -int j; -if (strcmp (str,"list" )) { -if (!perf_mem_events__parse (str)) { - mem->operation =0 ; -return 0 ; - } -exit (-1 ); +if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); } +if (perf_mem_events__parse (str)) +exit (-1 ); -for (j =0 ; j <PERF_MEM_EVENTS__MAX ; j++) { -struct perf_mem_event *e = &perf_mem_events[j]; - -fprintf (stderr,"%-13s%-*s%s\n" , - e->tag, - verbose >0 ?25 :0 , - verbose >0 ?perf_mem_events__name (j) :"" , - e->supported ?": available" :"" ); - } -exit (0 ); + mem->operation =0 ; +return 0 ; }static const char *const __usage[] = {
tools/perf/util/mem-events.c +15 -0
@@ -103,6 +103,21 @@ int perf_mem_events__init(void)return found ?0 : -ENOENT ; } +void perf_mem_events__list (void ) +{ +int j; + +for (j =0 ; j <PERF_MEM_EVENTS__MAX ; j++) { +struct perf_mem_event *e = &perf_mem_events[j]; + +fprintf (stderr,"%-13s%-*s%s\n" , + e->tag, + verbose >0 ?25 :0 , + verbose >0 ?perf_mem_events__name (j) :"" , + e->supported ?": available" :"" ); + } +} +static const char *const tlb_access[] = {"N/A" ,"HIT" ,
tools/perf/util/mem-events.h +2 -0
@@ -39,6 +39,8 @@ int perf_mem_events__init(void);char *perf_mem_events__name (int i); +void perf_mem_events__list (void ); +struct mem_info ;int perf_mem__tlb_scnprintf (char *out,size_t sz,struct mem_info *mem_info);int perf_mem__lvl_scnprintf (char *out,size_t sz,struct mem_info *mem_info);
Signature · 1 line
2.26.2.645.ge9eca65c58-goog
Em Thu, May 07, 2020 at 03:06:04PM -0700, Ian Rogers escreveu:
Quoted 11 lines
When the event is passed as list, the default events should be listed as per 'perf mem record -e list'. Previous behavior is:
$ perf c2c record -e list failed: event 'list' not found, use '-e list' to get list of available eventsUsage: perf c2c record [<options>] [<command>]
or: perf c2c record [<options>] -- <command> [<options>]-e, --event <event> event selector. Use 'perf mem record -e list' to list available events
Quoted 8 lines
New behavior:
$ perf c2c record -e list ldlat-loads : available ldlat-stores : availablev3: is a rebase.
v2: addresses review comments by Jiri Olsa.
Thanks, applied and tested, Jiri, can I have your Reviewed-by?
- Arnaldo
Quoted 124 lines
https://lore.kernel.org/lkml/20191127081844.GH32367@krava/
Signed-off-by Ian Rogers <[email protected]>--- tools/perf/Documentation/perf-c2c.txt | 2 +- tools/perf/builtin-c2c.c | 9 ++++++++- tools/perf/builtin-mem.c | 24 +++++++----------------- tools/perf/util/mem-events.c | 15 +++++++++++++++ tools/perf/util/mem-events.h | 2 ++ 5 files changed, 33 insertions(+), 19 deletions(-)tools/perf/Documentation/perf-c2c.txt +1
-1@@ -40,7 +40,7 @@ RECORD OPTIONS -------------- -e:: --event=:: - Select the PMU event. Use 'perf mem record -e list' + Select the PMU event. Use 'perf c2c record -e list' to list available events. -v::tools/perf/builtin-c2c.c +8
-1@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt, {bool *event_set = (bool *) opt->value; +if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); + } +if (perf_mem_events__parse (str)) +exit (-1 ); + *event_set = true; -return perf_mem_events__parse (str); +return 0 ; }tools/perf/builtin-mem.c +7
-17@@ -38,26 +38,16 @@ static int parse_record_events(const struct option *opt, const char *str, int unset __maybe_unused) {struct perf_mem *mem = *(struct perf_mem **)opt->value; -int j; -if (strcmp (str,"list" )) { -if (!perf_mem_events__parse (str)) { - mem->operation =0 ; -return 0 ; - } -exit (-1 ); +if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); } +if (perf_mem_events__parse (str)) +exit (-1 ); -for (j =0 ; j <PERF_MEM_EVENTS__MAX ; j++) { -struct perf_mem_event *e = &perf_mem_events[j]; - -fprintf (stderr,"%-13s%-*s%s\n" , - e->tag, - verbose >0 ?25 :0 , - verbose >0 ?perf_mem_events__name (j) :"" , - e->supported ?": available" :"" ); - } -exit (0 ); + mem->operation =0 ; +return 0 ; }static const char *const __usage[] = {tools/perf/util/mem-events.c +15
-0@@ -103,6 +103,21 @@ int perf_mem_events__init(void)return found ?0 : -ENOENT ; } +void perf_mem_events__list (void ) +{ +int j; + +for (j =0 ; j <PERF_MEM_EVENTS__MAX ; j++) { +struct perf_mem_event *e = &perf_mem_events[j]; + +fprintf (stderr,"%-13s%-*s%s\n" , + e->tag, + verbose >0 ?25 :0 , + verbose >0 ?perf_mem_events__name (j) :"" , + e->supported ?": available" :"" ); + } +} +static const char *const tlb_access[] = {"N/A" ,"HIT" ,tools/perf/util/mem-events.h +2
-0@@ -39,6 +39,8 @@ int perf_mem_events__init(void);char *perf_mem_events__name (int i); +void perf_mem_events__list (void ); +struct mem_info ;int perf_mem__tlb_scnprintf (char *out,size_t sz,struct mem_info *mem_info);int perf_mem__lvl_scnprintf (char *out,size_t sz,struct mem_info *mem_info);Signature · 1 line
2.26.2.645.ge9eca65c58-goog
Signature · 1 line
- Arnaldo
Quoted 47 lines · Ian Rogers
When the event is passed as list, the default events should be listed as per 'perf mem record -e list'. Previous behavior is:
$ perf c2c record -e list failed: event 'list' not found, use '-e list' to get list of available eventsUsage: perf c2c record [<options>] [<command>]
or: perf c2c record [<options>] -- <command> [<options>]-e, --event <event> event selector. Use 'perf mem record -e list' to list available events
New behavior:
$ perf c2c record -e list ldlat-loads : available ldlat-stores : availablev3: is a rebase.
v2: addresses review comments by Jiri Olsa.
https://lore.kernel.org/lkml/20191127081844.GH32367@krava/Signed-off-by Ian Rogers <[email protected]>--- tools/perf/Documentation/perf-c2c.txt | 2 +- tools/perf/builtin-c2c.c | 9 ++++++++- tools/perf/builtin-mem.c | 24 +++++++----------------- tools/perf/util/mem-events.c | 15 +++++++++++++++ tools/perf/util/mem-events.h | 2 ++ 5 files changed, 33 insertions(+), 19 deletions(-)tools/perf/Documentation/perf-c2c.txt +1
-1@@ -40,7 +40,7 @@ RECORD OPTIONS -------------- -e:: --event=:: - Select the PMU event. Use 'perf mem record -e list' + Select the PMU event. Use 'perf c2c record -e list' to list available events. -v::tools/perf/builtin-c2c.c +0
-0
tools/perf/builtin-c2c.c static int parse_record_events(const struct option *opt, · line 2895
Quoted 9 lines
tools/perf/builtin-c2c.c +6
-0@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt, {bool *event_set = (bool *) opt->value; +if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); + } +if (perf_mem_events__parse (str)) +exit (-1 );
won't this exit(-1) callsbreak the parsing stuff? like displaying the option values on error or such?
other than that it looks ok to me
jirka
Ian Rogers
reviewerQuoted 52 lines · Jiri Olsa
Quoted 50 lines · Ian Rogers
When the event is passed as list, the default events should be listed as per 'perf mem record -e list'. Previous behavior is:
$ perf c2c record -e list failed: event 'list' not found, use '-e list' to get list of available eventsUsage: perf c2c record [<options>] [<command>]
or: perf c2c record [<options>] -- <command> [<options>]-e, --event <event> event selector. Use 'perf mem record -e list' to list available events
New behavior:
$ perf c2c record -e list ldlat-loads : available ldlat-stores : availablev3: is a rebase.
v2: addresses review comments by Jiri Olsa.
https://lore.kernel.org/lkml/20191127081844.GH32367@krava/Signed-off-by Ian Rogers <[email protected]>--- tools/perf/Documentation/perf-c2c.txt | 2 +- tools/perf/builtin-c2c.c | 9 ++++++++- tools/perf/builtin-mem.c | 24 +++++++----------------- tools/perf/util/mem-events.c | 15 +++++++++++++++ tools/perf/util/mem-events.h | 2 ++ 5 files changed, 33 insertions(+), 19 deletions(-)tools/perf/Documentation/perf-c2c.txt +1
-1@@ -40,7 +40,7 @@ RECORD OPTIONS -------------- -e:: --event=:: - Select the PMU event. Use 'perf mem record -e list' + Select the PMU event. Use 'perf c2c record -e list' to list available events. -v::tools/perf/builtin-c2c.c +0
-0@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt, {bool *event_set = (bool *) opt->value;
Quoted 9 lines
tools/perf/builtin-c2c.c static int parse_record_events(const struct option *opt, · line 2895
Quoted 6 lines
tools/perf/builtin-c2c.c +6
-0+if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); + } +if (perf_mem_events__parse (str)) +exit (-1 );won't this exit(-1) callsbreak the parsing stuff? like displaying the option values on error or such?
The previous code was:
- if (strcmp(str, "list")) {
This is handled explicitly in the code above this.
- if (!perf_mem_events__parse(str)) {
- mem->operation = 0;
- return 0;
- }
- exit(-1);
This is the code where the exit -1 happens, I inverted the comparison so that exit was more the exceptional code path. The behavior should be identical.
Thanks,
Ian
Quoted 4 lines
other than that it looks ok to me
jirka
Jiri Olsa
Acked-byOn Mon, May 11, 2020 at 01:29:42PM -0700, Ian Rogers wrote:
SNIP
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
tools/perf/builtin-c2c.c +0
-0@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt, {bool *event_set = (bool *) opt->value;Quoted 9 lines
tools/perf/builtin-c2c.c static int parse_record_events(const struct option *opt, · line 2895
Quoted 6 lines
tools/perf/builtin-c2c.c +6
-0+if (!strcmp (str,"list" )) { +perf_mem_events__list (); +exit (0 ); + } +if (perf_mem_events__parse (str)) +exit (-1 );won't this exit(-1) callsbreak the parsing stuff? like displaying the option values on error or such?
The previous code was:
- if (strcmp(str, "list")) {
This is handled explicitly in the code above this.tools/perf/builtin-mem.c +0
-5-if (!perf_mem_events__parse (str)) { - mem->operation =0 ; -return 0 ; - } -exit (-1 );
Quoted 3 lines
This is the code where the exit -1 happens, I inverted the comparison so that exit was more the exceptional code path. The behavior should be identical.
ok
thanks,
jirka