]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf tools arm-spe: Pull out functions for aux buffer and tracking setup
authorJames Clark <james.clark@linaro.org>
Wed, 8 Jan 2025 14:28:58 +0000 (14:28 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Jan 2025 14:43:15 +0000 (11:43 -0300)
These won't be used in the next commit in discard mode, so put them in
their own functions. No functional changes intended.

Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Graham Woodward <graham.woodward@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250108142904.401139-4-james.clark@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/arm64/util/arm-spe.c

index 22b19dcc6beb8ec2f1f1abfa09888be84146cb03..1b543855f2066b1ffd3cd317c4a5b55c75f3a504 100644 (file)
@@ -274,33 +274,9 @@ static void arm_spe_setup_evsel(struct evsel *evsel, struct perf_cpu_map *cpus)
                evsel__set_sample_bit(evsel, PHYS_ADDR);
 }
 
-static int arm_spe_recording_options(struct auxtrace_record *itr,
-                                    struct evlist *evlist,
-                                    struct record_opts *opts)
+static int arm_spe_setup_aux_buffer(struct record_opts *opts)
 {
-       struct arm_spe_recording *sper =
-                       container_of(itr, struct arm_spe_recording, itr);
-       struct evsel *evsel, *tmp;
-       struct perf_cpu_map *cpus = evlist->core.user_requested_cpus;
        bool privileged = perf_event_paranoid_check(-1);
-       struct evsel *tracking_evsel;
-       int err;
-
-       sper->evlist = evlist;
-
-       evlist__for_each_entry(evlist, evsel) {
-               if (evsel__is_aux_event(evsel)) {
-                       if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) {
-                               pr_err("Found unexpected auxtrace event: %s\n",
-                                      evsel->pmu->name);
-                               return -EINVAL;
-                       }
-                       opts->full_auxtrace = true;
-               }
-       }
-
-       if (!opts->full_auxtrace)
-               return 0;
 
        /*
         * we are in snapshot mode.
@@ -330,6 +306,9 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
                        pr_err("Failed to calculate default snapshot size and/or AUX area tracing mmap pages\n");
                        return -EINVAL;
                }
+
+               pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME,
+                         opts->auxtrace_snapshot_size);
        }
 
        /* We are in full trace mode but '-m,xyz' wasn't specified */
@@ -355,14 +334,15 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
                }
        }
 
-       if (opts->auxtrace_snapshot_mode)
-               pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME,
-                         opts->auxtrace_snapshot_size);
+       return 0;
+}
 
-       evlist__for_each_entry_safe(evlist, tmp, evsel) {
-               if (evsel__is_aux_event(evsel))
-                       arm_spe_setup_evsel(evsel, cpus);
-       }
+static int arm_spe_setup_tracking_event(struct evlist *evlist,
+                                       struct record_opts *opts)
+{
+       int err;
+       struct evsel *tracking_evsel;
+       struct perf_cpu_map *cpus = evlist->core.user_requested_cpus;
 
        /* Add dummy event to keep tracking */
        err = parse_event(evlist, "dummy:u");
@@ -388,6 +368,45 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
        return 0;
 }
 
+static int arm_spe_recording_options(struct auxtrace_record *itr,
+                                    struct evlist *evlist,
+                                    struct record_opts *opts)
+{
+       struct arm_spe_recording *sper =
+                       container_of(itr, struct arm_spe_recording, itr);
+       struct evsel *evsel, *tmp;
+       struct perf_cpu_map *cpus = evlist->core.user_requested_cpus;
+
+       int err;
+
+       sper->evlist = evlist;
+
+       evlist__for_each_entry(evlist, evsel) {
+               if (evsel__is_aux_event(evsel)) {
+                       if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) {
+                               pr_err("Found unexpected auxtrace event: %s\n",
+                                      evsel->pmu->name);
+                               return -EINVAL;
+                       }
+                       opts->full_auxtrace = true;
+               }
+       }
+
+       if (!opts->full_auxtrace)
+               return 0;
+
+       evlist__for_each_entry_safe(evlist, tmp, evsel) {
+               if (evsel__is_aux_event(evsel))
+                       arm_spe_setup_evsel(evsel, cpus);
+       }
+
+       err = arm_spe_setup_aux_buffer(opts);
+       if (err)
+               return err;
+
+       return arm_spe_setup_tracking_event(evlist, opts);
+}
+
 static int arm_spe_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused,
                                         struct record_opts *opts,
                                         const char *str)