perf parse-events: Reduce scope of is_event_supported
authorIan Rogers <irogers@google.com>
Tue, 2 May 2023 22:38:51 +0000 (15:38 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 15 May 2023 12:12:14 +0000 (09:12 -0300)
Move to print-events.c and make static.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ahmad Yasin <ahmad.yasin@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kang Minchul <tegongkang@gmail.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Samantha Alt <samantha.alt@intel.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20230502223851.2234828-45-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h
tools/perf/util/print-events.c

index 2dad88a..b93264f 100644 (file)
@@ -28,7 +28,6 @@
 #include "util/bpf-filter.h"
 #include "util/util.h"
 #include "tracepoint.h"
-#include "thread_map.h"
 
 #define MAX_NAME_LEN 100
 
@@ -133,44 +132,6 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
        },
 };
 
-bool is_event_supported(u8 type, u64 config)
-{
-       bool ret = true;
-       int open_return;
-       struct evsel *evsel;
-       struct perf_event_attr attr = {
-               .type = type,
-               .config = config,
-               .disabled = 1,
-       };
-       struct perf_thread_map *tmap = thread_map__new_by_tid(0);
-
-       if (tmap == NULL)
-               return false;
-
-       evsel = evsel__new(&attr);
-       if (evsel) {
-               open_return = evsel__open(evsel, NULL, tmap);
-               ret = open_return >= 0;
-
-               if (open_return == -EACCES) {
-                       /*
-                        * This happens if the paranoid value
-                        * /proc/sys/kernel/perf_event_paranoid is set to 2
-                        * Re-run with exclude_kernel set; we don't do that
-                        * by default as some ARM machines do not support it.
-                        *
-                        */
-                       evsel->core.attr.exclude_kernel = 1;
-                       ret = evsel__open(evsel, NULL, tmap) >= 0;
-               }
-               evsel__delete(evsel);
-       }
-
-       perf_thread_map__put(tmap);
-       return ret;
-}
-
 const char *event_type(int type)
 {
        switch (type) {
index 2a8cafe..2021fe1 100644 (file)
@@ -18,8 +18,6 @@ struct parse_events_error;
 struct option;
 struct perf_pmu;
 
-bool is_event_supported(u8 type, u64 config);
-
 const char *event_type(int type);
 
 /* Arguments encoded in opt->value. */
index d148842..69492cb 100644 (file)
@@ -27,6 +27,7 @@
 #include "tracepoint.h"
 #include "pfm.h"
 #include "pmu-hybrid.h"
+#include "thread_map.h"
 
 #define MAX_NAME_LEN 100
 
@@ -228,6 +229,44 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)
        strlist__delete(sdtlist);
 }
 
+static bool is_event_supported(u8 type, u64 config)
+{
+       bool ret = true;
+       int open_return;
+       struct evsel *evsel;
+       struct perf_event_attr attr = {
+               .type = type,
+               .config = config,
+               .disabled = 1,
+       };
+       struct perf_thread_map *tmap = thread_map__new_by_tid(0);
+
+       if (tmap == NULL)
+               return false;
+
+       evsel = evsel__new(&attr);
+       if (evsel) {
+               open_return = evsel__open(evsel, NULL, tmap);
+               ret = open_return >= 0;
+
+               if (open_return == -EACCES) {
+                       /*
+                        * This happens if the paranoid value
+                        * /proc/sys/kernel/perf_event_paranoid is set to 2
+                        * Re-run with exclude_kernel set; we don't do that
+                        * by default as some ARM machines do not support it.
+                        *
+                        */
+                       evsel->core.attr.exclude_kernel = 1;
+                       ret = evsel__open(evsel, NULL, tmap) >= 0;
+               }
+               evsel__delete(evsel);
+       }
+
+       perf_thread_map__put(tmap);
+       return ret;
+}
+
 int print_hwcache_events(const struct print_callbacks *print_cb, void *print_state)
 {
        struct perf_pmu *pmu = NULL;