Skip to content

Commit f35488f

Browse files
Jiri Olsaacmel
authored andcommitted
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. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1355749718-4355-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0bd3f08 commit f35488f

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

‎tools/perf/util/parse-events.c‎

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ static int add_tracepoint(struct list_head **listp, int *idx,
380380
return 0;
381381
}
382382

383-
static int add_tracepoint_multi(struct list_head **list, int *idx,
384-
char *sys_name, char *evt_name)
383+
static int add_tracepoint_multi_event(struct list_head **list, int *idx,
384+
char *sys_name, char *evt_name)
385385
{
386386
char evt_path[MAXPATHLEN];
387387
struct dirent *evt_ent;
@@ -412,6 +412,46 @@ static int add_tracepoint_multi(struct list_head **list, int *idx,
412412
return ret;
413413
}
414414

415+
static int add_tracepoint_event(struct list_head **list, int *idx,
416+
char *sys_name, char *evt_name)
417+
{
418+
return strpbrk(evt_name, "*?") ?
419+
add_tracepoint_multi_event(list, idx, sys_name, evt_name) :
420+
add_tracepoint(list, idx, sys_name, evt_name);
421+
}
422+
423+
static int add_tracepoint_multi_sys(struct list_head **list, int *idx,
424+
char *sys_name, char *evt_name)
425+
{
426+
struct dirent *events_ent;
427+
DIR *events_dir;
428+
int ret = 0;
429+
430+
events_dir = opendir(tracing_events_path);
431+
if (!events_dir) {
432+
perror("Can't open event dir");
433+
return -1;
434+
}
435+
436+
while (!ret && (events_ent = readdir(events_dir))) {
437+
if (!strcmp(events_ent->d_name, ".")
438+
|| !strcmp(events_ent->d_name, "..")
439+
|| !strcmp(events_ent->d_name, "enable")
440+
|| !strcmp(events_ent->d_name, "header_event")
441+
|| !strcmp(events_ent->d_name, "header_page"))
442+
continue;
443+
444+
if (!strglobmatch(events_ent->d_name, sys_name))
445+
continue;
446+
447+
ret = add_tracepoint_event(list, idx, events_ent->d_name,
448+
evt_name);
449+
}
450+
451+
closedir(events_dir);
452+
return ret;
453+
}
454+
415455
int parse_events_add_tracepoint(struct list_head **list, int *idx,
416456
char *sys, char *event)
417457
{
@@ -421,9 +461,10 @@ int parse_events_add_tracepoint(struct list_head **list, int *idx,
421461
if (ret)
422462
return ret;
423463

424-
return strpbrk(event, "*?") ?
425-
add_tracepoint_multi(list, idx, sys, event) :
426-
add_tracepoint(list, idx, sys, event);
464+
if (strpbrk(sys, "*?"))
465+
return add_tracepoint_multi_sys(list, idx, sys, event);
466+
else
467+
return add_tracepoint_event(list, idx, sys, event);
427468
}
428469

429470
static int

0 commit comments

Comments
 (0)