perf tracepoint: Don't scan all tracepoints to test if one exists
authorIan Rogers <irogers@google.com>
Thu, 9 May 2024 15:32:45 +0000 (08:32 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 9 May 2024 21:46:43 +0000 (18:46 -0300)
commitd790ead8a60c0f687446f7d8faa96943dc158912
tree2071b914210e436e25ec5a1c3cd5ff24cd647fe0
parentc9d492378faec5c1fb8ea1534c620f7320bbb23a
perf tracepoint: Don't scan all tracepoints to test if one exists

In is_valid_tracepoint, rather than scanning
"/sys/kernel/tracing/events/*/*" skipping any path where
"/sys/kernel/tracing/events/*/*/id" doesn't exist, and then testing if
"*:*" matches the tracepoint name, just use the given tracepoint name
replace the ':' with '/' and see if the id file exists.

This turns a nested directory search into a single file available test.

Rather than return 1 for valid and 0 for invalid, return true and false.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240509153245.1990426-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/tracepoint.c
tools/perf/util/tracepoint.h