perf tool: Add support for wildcard in tracepoint system name
cover perf tool: Add support for wildcard in tracepoint system name
hi,
Attached patches:
1/3 perf tools: Add missing closedir in multi tracepoint processing 2/3 perf tools: Add support for wildcard in tracepoint system name 3/3 perf tests: Add event parsing test for '*:*' tracepoints
The automated test (patch 3) exposes warnings from traceevent lib about not being able to parse some tracepoints' format data. Exposing these messages in the automated test suite will probably speed up the fix ;-)
I've already talked to Steve about the solution. Additional parsing plugins need to be added (some moved from trace-cmd) into traceevent lib.
thanks,
jirka
--- tools/perf/tests/parse-events.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/parse-events.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 109 insertions(+), 5 deletions(-)
PATCH 1/3 perf tools: Add missing closedir in multi tracepoint processing
We don't close 'events' directory when reading multiple tracepoint events. Adding missing closedir.
--- tools/perf/util/parse-events.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/parse-events.c +1 -0
@@ -408,6 +408,7 @@ static int add_tracepoint_multi(struct list_head **list, int *idx, ret =add_tracepoint (list, idx, sys_name, evt_ent->d_name); } +closedir (evt_dir);return ret; }
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tools: Add missing closedir in multi tracepoint processing
Commit-ID: 0bd3f0840bf4bc900b4beb8e792ad499b43dad3b Gitweb: http://git.kernel.org/tip/0bd3f0840bf4bc900b4beb8e792ad499b43dad3b Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 17 Dec 2012 14:08:36 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:10 -0300
perf tools: Add missing closedir in multi tracepoint processing
We don't close 'events' directory when reading multiple tracepoint events. Adding missing closedir.
--- tools/perf/util/parse-events.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/parse-events.c +1 -0
@@ -408,6 +408,7 @@ static int add_tracepoint_multi(struct list_head **list, int *idx, ret =add_tracepoint (list, idx, sys_name, evt_ent->d_name); } +closedir (evt_dir);return ret; }
PATCH 2/3 perf tools: Add support for wildcard in tracepoint system name
In reply to Jiri OlsaAdding support for wildcards '*?" in the tracepoint system part.
It's now possible to open all available tracepoints like:
# perf stat -e '*:*' ls
You might need to increase limit for open files via ulimit.
If ftrace events tracepoints are configured in, the record command fails on above event selection because of them. The stat command disables counters that fails to open, the record command fails completely. We probably want to be smarter here.
--- tools/perf/util/parse-events.c | 51 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-)
tools/perf/util/parse-events.c +46 -5
@@ -380,8 +380,8 @@ static int add_tracepoint(struct list_head **listp, int *idx,return 0 ; } -static int add_tracepoint_multi (struct list_head **list,int *idx, -char *sys_name,char *evt_name) +static int add_tracepoint_multi_event (struct list_head **list,int *idx, +char *sys_name,char *evt_name) {char evt_path[MAXPATHLEN ];struct dirent *evt_ent;
@@ -412,6 +412,46 @@ static int add_tracepoint_multi(struct list_head **list, int *idx,return ret; } +static int add_tracepoint_event (struct list_head **list,int *idx, +char *sys_name,char *evt_name) +{ +return strpbrk (evt_name,"*?" ) ? +add_tracepoint_multi_event (list, idx, sys_name, evt_name) : +add_tracepoint (list, idx, sys_name, evt_name); +} + +static int add_tracepoint_multi_sys (struct list_head **list,int *idx, +char *sys_name,char *evt_name) +{ +struct dirent *events_ent; +DIR *events_dir; +int ret =0 ; + + events_dir =opendir (tracing_events_path); +if (!events_dir) { +perror ("Can't open event dir" ); +return -1 ; + } + +while (!ret && (events_ent =readdir (events_dir))) { +if (!strcmp (events_ent->d_name,"." ) + || !strcmp (events_ent->d_name,".." ) + || !strcmp (events_ent->d_name,"enable" ) + || !strcmp (events_ent->d_name,"header_event" ) + || !strcmp (events_ent->d_name,"header_page" )) +continue ; + +if (!strglobmatch (events_ent->d_name, sys_name)) +continue ; + + ret =add_tracepoint_event (list, idx, events_ent->d_name, + evt_name); + } + +closedir (events_dir); +return ret; +} +int parse_events_add_tracepoint (struct list_head **list,int *idx,char *sys,char *event) {
@@ -421,9 +461,10 @@ int parse_events_add_tracepoint(struct list_head **list, int *idx,if (ret)return ret; -return strpbrk (event,"*?" ) ? -add_tracepoint_multi (list, idx, sys, event) : -add_tracepoint (list, idx, sys, event); +if (strpbrk (sys,"*?" )) +return add_tracepoint_multi_sys (list, idx, sys, event); +else +return add_tracepoint_event (list, idx, sys, event); } static int
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tools: Add support for wildcard in tracepoint system name
Commit-ID: f35488f97b4b49cb76d87bb7e8da9e93fc70b4e9 Gitweb: http://git.kernel.org/tip/f35488f97b4b49cb76d87bb7e8da9e93fc70b4e9 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 17 Dec 2012 14:08:37 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:10 -0300
perf tools: Add support for wildcard in tracepoint system name
Adding support for wildcards '*?" in the tracepoint system part.
It's now possible to open all available tracepoints like:
# perf stat -e '*:*' ls
You might need to increase limit for open files via ulimit.
If ftrace events tracepoints are configured in, the record command fails on above event selection because of them.
The stat command disables counters that fails to open, the record command fails completely. We probably want to be smarter here.
--- tools/perf/util/parse-events.c | 51 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-)
tools/perf/util/parse-events.c +46 -5
@@ -380,8 +380,8 @@ static int add_tracepoint(struct list_head **listp, int *idx,return 0 ; } -static int add_tracepoint_multi (struct list_head **list,int *idx, -char *sys_name,char *evt_name) +static int add_tracepoint_multi_event (struct list_head **list,int *idx, +char *sys_name,char *evt_name) {char evt_path[MAXPATHLEN ];struct dirent *evt_ent;
@@ -412,6 +412,46 @@ static int add_tracepoint_multi(struct list_head **list, int *idx,return ret; } +static int add_tracepoint_event (struct list_head **list,int *idx, +char *sys_name,char *evt_name) +{ +return strpbrk (evt_name,"*?" ) ? +add_tracepoint_multi_event (list, idx, sys_name, evt_name) : +add_tracepoint (list, idx, sys_name, evt_name); +} + +static int add_tracepoint_multi_sys (struct list_head **list,int *idx, +char *sys_name,char *evt_name) +{ +struct dirent *events_ent; +DIR *events_dir; +int ret =0 ; + + events_dir =opendir (tracing_events_path); +if (!events_dir) { +perror ("Can't open event dir" ); +return -1 ; + } + +while (!ret && (events_ent =readdir (events_dir))) { +if (!strcmp (events_ent->d_name,"." ) + || !strcmp (events_ent->d_name,".." ) + || !strcmp (events_ent->d_name,"enable" ) + || !strcmp (events_ent->d_name,"header_event" ) + || !strcmp (events_ent->d_name,"header_page" )) +continue ; + +if (!strglobmatch (events_ent->d_name, sys_name)) +continue ; + + ret =add_tracepoint_event (list, idx, events_ent->d_name, + evt_name); + } + +closedir (events_dir); +return ret; +} +int parse_events_add_tracepoint (struct list_head **list,int *idx,char *sys,char *event) {
@@ -421,9 +461,10 @@ int parse_events_add_tracepoint(struct list_head **list, int *idx,if (ret)return ret; -return strpbrk (event,"*?" ) ? -add_tracepoint_multi (list, idx, sys, event) : -add_tracepoint (list, idx, sys, event); +if (strpbrk (sys,"*?" )) +return add_tracepoint_multi_sys (list, idx, sys, event); +else +return add_tracepoint_event (list, idx, sys, event); } static int
PATCH 3/3 perf tests: Add event parsing test for '*:*' tracepoints
In reply to Jiri OlsaAdding event parsing test for '*:*' tracepoints. Checking the count matches all the tracepoints available plus current standard tracepoint perf_event_attr check.
This test exposes warnings from traceevent lib about not being able to parse some tracepoints' format data. Exposing these messages in the automated test suite will probably speed up the fix ;-)
--- tools/perf/tests/parse-events.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
tools/perf/tests/parse-events.c +62 -0
@@ -3,6 +3,7 @@#include "evsel.h" #include "evlist.h" #include "sysfs.h" +#include "debugfs.h" #include "tests.h" #include <linux/hw_breakpoint.h>
@@ -782,6 +783,63 @@ static int test__group5(struct perf_evlist *evlist __maybe_unused)return 0 ; } +static int count_tracepoints (void ) +{ +char events_path[PATH_MAX ]; +struct dirent *events_ent; +DIR *events_dir; +int cnt =0 ; + +scnprintf (events_path,PATH_MAX ,"%s/tracing/events" , +debugfs_find_mountpoint ()); + + events_dir =opendir (events_path); + +TEST_ASSERT_VAL ("Can't open events dir" , events_dir); + +while ((events_ent =readdir (events_dir))) { +char sys_path[PATH_MAX ]; +struct dirent *sys_ent; +DIR *sys_dir; + +if (!strcmp (events_ent->d_name,"." ) + || !strcmp (events_ent->d_name,".." ) + || !strcmp (events_ent->d_name,"enable" ) + || !strcmp (events_ent->d_name,"header_event" ) + || !strcmp (events_ent->d_name,"header_page" )) +continue ; + +scnprintf (sys_path,PATH_MAX ,"%s/%s" , + events_path, events_ent->d_name); + + sys_dir =opendir (sys_path); +TEST_ASSERT_VAL ("Can't open sys dir" , sys_dir); + +while ((sys_ent =readdir (sys_dir))) { +if (!strcmp (sys_ent->d_name,"." ) + || !strcmp (sys_ent->d_name,".." ) + || !strcmp (sys_ent->d_name,"enable" ) + || !strcmp (sys_ent->d_name,"filter" )) +continue ; + + cnt++; + } + +closedir (sys_dir); + } + +closedir (events_dir); +return cnt; +} + +static int test__all_tracepoints (struct perf_evlist *evlist) +{ +TEST_ASSERT_VAL ("wrong events count" , +count_tracepoints () == evlist->nr_entries); + +return test__checkevent_tracepoint_multi (evlist); +} +struct test__event_st {const char *name;__u32 type;
@@ -921,6 +979,10 @@ static struct test__event_st test__events[] = { .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", .check = test__group5, }, + [33] = { + .name = "*:*", + .check = test__all_tracepoints, + }, }; static struct test__event_st test__events_pmu[] = {
Signature · 1 line
1.7.11.7
Re: [PATCH 3/3] perf tests: Add event parsing test for '*:*' tracepoints
Em Mon, Dec 17, 2012 at 02:08:38PM +0100, Jiri Olsa escreveu:
Quoted 8 lines
Adding event parsing test for '*:*' tracepoints. Checking the count matches all the tracepoints available plus current standard tracepoint
perf_event_attrcheck.This test exposes warnings from traceevent lib about not being able to parse some tracepoints' format data. Exposing these messages in the automated test suite will probably speed up the fix ;-)
Ok, merged, now where is that speedup? ;-)
- Arnaldo
Re: [PATCH 3/3] perf tests: Add event parsing test for '*:*' tracepoints
Quoted 11 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 17, 2012 at 02:08:38PM +0100, Jiri Olsa escreveu:
Quoted 8 lines
Adding event parsing test for '*:*' tracepoints. Checking the count matches all the tracepoints available plus current standard tracepoint
perf_event_attrcheck.This test exposes warnings from traceevent lib about not being able to parse some tracepoints' format data. Exposing these messages in the automated test suite will probably speed up the fix ;-)
Ok, merged, now where is that speedup? ;-)
well.. I did say 'probably' ;-)
thanks,
jirka
[tip:perf/core] perf tests: Add event parsing test for '*:*' tracepoints
In reply to Jiri OlsaCommit-ID: 82ce75d93335f7079afc17fb7f2a4e549d2fbecb Gitweb: http://git.kernel.org/tip/82ce75d93335f7079afc17fb7f2a4e549d2fbecb Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 17 Dec 2012 14:08:38 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:10 -0300
perf tests: Add event parsing test for '*:*' tracepoints
Adding event parsing test for '*:*' tracepoints. Checking the count matches all the tracepoints available plus current standard tracepoint perf_event_attr check.
This test exposes warnings from traceevent lib about not being able to parse some tracepoints' format data. Exposing these messages in the automated test suite will probably speed up the fix ;-)
--- tools/perf/tests/parse-events.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
tools/perf/tests/parse-events.c +62 -0
@@ -3,6 +3,7 @@#include "evsel.h" #include "evlist.h" #include "sysfs.h" +#include "debugfs.h" #include "tests.h" #include <linux/hw_breakpoint.h>
@@ -782,6 +783,63 @@ static int test__group5(struct perf_evlist *evlist __maybe_unused)return 0 ; } +static int count_tracepoints (void ) +{ +char events_path[PATH_MAX ]; +struct dirent *events_ent; +DIR *events_dir; +int cnt =0 ; + +scnprintf (events_path,PATH_MAX ,"%s/tracing/events" , +debugfs_find_mountpoint ()); + + events_dir =opendir (events_path); + +TEST_ASSERT_VAL ("Can't open events dir" , events_dir); + +while ((events_ent =readdir (events_dir))) { +char sys_path[PATH_MAX ]; +struct dirent *sys_ent; +DIR *sys_dir; + +if (!strcmp (events_ent->d_name,"." ) + || !strcmp (events_ent->d_name,".." ) + || !strcmp (events_ent->d_name,"enable" ) + || !strcmp (events_ent->d_name,"header_event" ) + || !strcmp (events_ent->d_name,"header_page" )) +continue ; + +scnprintf (sys_path,PATH_MAX ,"%s/%s" , + events_path, events_ent->d_name); + + sys_dir =opendir (sys_path); +TEST_ASSERT_VAL ("Can't open sys dir" , sys_dir); + +while ((sys_ent =readdir (sys_dir))) { +if (!strcmp (sys_ent->d_name,"." ) + || !strcmp (sys_ent->d_name,".." ) + || !strcmp (sys_ent->d_name,"enable" ) + || !strcmp (sys_ent->d_name,"filter" )) +continue ; + + cnt++; + } + +closedir (sys_dir); + } + +closedir (events_dir); +return cnt; +} + +static int test__all_tracepoints (struct perf_evlist *evlist) +{ +TEST_ASSERT_VAL ("wrong events count" , +count_tracepoints () == evlist->nr_entries); + +return test__checkevent_tracepoint_multi (evlist); +} +struct test__event_st {const char *name;__u32 type;
@@ -921,6 +979,10 @@ static struct test__event_st test__events[] = { .name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", .check = test__group5, }, + [33] = { + .name = "*:*", + .check = test__all_tracepoints, + }, }; static struct test__event_st test__events_pmu[] = {