d790ead8a6
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>
27 lines
835 B
C
27 lines
835 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __PERF_TRACEPOINT_H
|
|
#define __PERF_TRACEPOINT_H
|
|
|
|
#include <dirent.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
int tp_event_has_id(const char *dir_path, struct dirent *evt_dir);
|
|
|
|
#define for_each_event(dir_path, evt_dir, evt_dirent) \
|
|
while ((evt_dirent = readdir(evt_dir)) != NULL) \
|
|
if (evt_dirent->d_type == DT_DIR && \
|
|
(strcmp(evt_dirent->d_name, ".")) && \
|
|
(strcmp(evt_dirent->d_name, "..")) && \
|
|
(!tp_event_has_id(dir_path, evt_dirent)))
|
|
|
|
#define for_each_subsystem(sys_dir, sys_dirent) \
|
|
while ((sys_dirent = readdir(sys_dir)) != NULL) \
|
|
if (sys_dirent->d_type == DT_DIR && \
|
|
(strcmp(sys_dirent->d_name, ".")) && \
|
|
(strcmp(sys_dirent->d_name, "..")))
|
|
|
|
bool is_valid_tracepoint(const char *event_string);
|
|
|
|
#endif /* __PERF_TRACEPOINT_H */
|