Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf arm-spe: Extract evsel setting up

The evsel for Arm SPE PMU needs to be set up. Extract the setting up
into a function arm_spe_setup_evsel().

Signed-off-by: Leo Yan <leo.yan@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: James Clark <james.clark@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: <coresight@lists.linaro.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: <linux-perf-users@vger.kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Leo Yan and committed by
Arnaldo Carvalho de Melo
ccd6fcda 4ed0f392

+40 -34
+40 -34
tools/perf/arch/arm64/util/arm-spe.c
··· 132 132 return sample_period; 133 133 } 134 134 135 + static void arm_spe_setup_evsel(struct evsel *evsel, struct perf_cpu_map *cpus) 136 + { 137 + u64 bit; 138 + 139 + evsel->core.attr.freq = 0; 140 + evsel->core.attr.sample_period = arm_spe_pmu__sample_period(evsel->pmu); 141 + evsel->needs_auxtrace_mmap = true; 142 + 143 + /* 144 + * To obtain the auxtrace buffer file descriptor, the auxtrace event 145 + * must come first. 146 + */ 147 + evlist__to_front(evsel->evlist, evsel); 148 + 149 + /* 150 + * In the case of per-cpu mmaps, sample CPU for AUX event; 151 + * also enable the timestamp tracing for samples correlation. 152 + */ 153 + if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) { 154 + evsel__set_sample_bit(evsel, CPU); 155 + evsel__set_config_if_unset(evsel->pmu, evsel, "ts_enable", 1); 156 + } 157 + 158 + /* 159 + * Set this only so that perf report knows that SPE generates memory info. It has no effect 160 + * on the opening of the event or the SPE data produced. 161 + */ 162 + evsel__set_sample_bit(evsel, DATA_SRC); 163 + 164 + /* 165 + * The PHYS_ADDR flag does not affect the driver behaviour, it is used to 166 + * inform that the resulting output's SPE samples contain physical addresses 167 + * where applicable. 168 + */ 169 + bit = perf_pmu__format_bits(evsel->pmu, "pa_enable"); 170 + if (evsel->core.attr.config & bit) 171 + evsel__set_sample_bit(evsel, PHYS_ADDR); 172 + } 173 + 135 174 static int arm_spe_recording_options(struct auxtrace_record *itr, 136 175 struct evlist *evlist, 137 176 struct record_opts *opts) ··· 183 144 bool privileged = perf_event_paranoid_check(-1); 184 145 struct evsel *tracking_evsel; 185 146 int err; 186 - u64 bit; 187 147 188 148 sper->evlist = evlist; 189 149 ··· 192 154 pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n"); 193 155 return -EINVAL; 194 156 } 195 - evsel->core.attr.freq = 0; 196 - evsel->core.attr.sample_period = arm_spe_pmu__sample_period(arm_spe_pmu); 197 - evsel->needs_auxtrace_mmap = true; 198 157 arm_spe_evsel = evsel; 199 158 opts->full_auxtrace = true; 200 159 } ··· 257 222 pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, 258 223 opts->auxtrace_snapshot_size); 259 224 260 - /* 261 - * To obtain the auxtrace buffer file descriptor, the auxtrace event 262 - * must come first. 263 - */ 264 - evlist__to_front(evlist, arm_spe_evsel); 265 - 266 - /* 267 - * In the case of per-cpu mmaps, sample CPU for AUX event; 268 - * also enable the timestamp tracing for samples correlation. 269 - */ 270 - if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) { 271 - evsel__set_sample_bit(arm_spe_evsel, CPU); 272 - evsel__set_config_if_unset(arm_spe_pmu, arm_spe_evsel, 273 - "ts_enable", 1); 274 - } 275 - 276 - /* 277 - * Set this only so that perf report knows that SPE generates memory info. It has no effect 278 - * on the opening of the event or the SPE data produced. 279 - */ 280 - evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); 281 - 282 - /* 283 - * The PHYS_ADDR flag does not affect the driver behaviour, it is used to 284 - * inform that the resulting output's SPE samples contain physical addresses 285 - * where applicable. 286 - */ 287 - bit = perf_pmu__format_bits(arm_spe_pmu, "pa_enable"); 288 - if (arm_spe_evsel->core.attr.config & bit) 289 - evsel__set_sample_bit(arm_spe_evsel, PHYS_ADDR); 225 + arm_spe_setup_evsel(arm_spe_evsel, cpus); 290 226 291 227 /* Add dummy event to keep tracking */ 292 228 err = parse_event(evlist, "dummy:u");