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

perf auxtrace: Add mmap_needed to auxtrace_mmap_params

Add mmap_needed to auxtrace_mmap_params.

Currently an auxtrace mmap is always attempted even if the event is not an
auxtrace event. That works because, when AUX area tracing, there is always
an auxtrace event first for every mmap. Prepare for that not being the
case, which it won't be when sideband tracking events are allowed on
all CPUs even when auxtrace is limited to selected CPUs.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Link: https://lore.kernel.org/r/20220524075436.29144-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
d01508f2 1097b38f

+21 -6
+8 -2
tools/perf/util/auxtrace.c
··· 125 125 mm->tid = mp->tid; 126 126 mm->cpu = mp->cpu.cpu; 127 127 128 - if (!mp->len) { 128 + if (!mp->len || !mp->mmap_needed) { 129 129 mm->base = NULL; 130 130 return 0; 131 131 } ··· 168 168 } 169 169 170 170 void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, 171 - struct evlist *evlist, int idx, 171 + struct evlist *evlist, 172 + struct evsel *evsel, int idx, 172 173 bool per_cpu) 173 174 { 175 + mp->mmap_needed = evsel->needs_auxtrace_mmap; 176 + 177 + if (!mp->mmap_needed) 178 + return; 179 + 174 180 mp->idx = idx; 175 181 176 182 if (per_cpu) {
+9 -2
tools/perf/util/auxtrace.h
··· 344 344 * @idx: index of this mmap 345 345 * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu 346 346 * mmap) otherwise %0 347 + * @mmap_needed: set to %false for non-auxtrace events. This is needed because 348 + * auxtrace mmapping is done in the same code path as non-auxtrace 349 + * mmapping but not every evsel that needs non-auxtrace mmapping 350 + * also needs auxtrace mmapping. 347 351 * @cpu: cpu number for a per-cpu mmap otherwise %-1 348 352 */ 349 353 struct auxtrace_mmap_params { ··· 357 353 int prot; 358 354 int idx; 359 355 pid_t tid; 356 + bool mmap_needed; 360 357 struct perf_cpu cpu; 361 358 }; 362 359 ··· 495 490 unsigned int auxtrace_pages, 496 491 bool auxtrace_overwrite); 497 492 void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, 498 - struct evlist *evlist, int idx, 493 + struct evlist *evlist, 494 + struct evsel *evsel, int idx, 499 495 bool per_cpu); 500 496 501 497 typedef int (*process_auxtrace_t)(struct perf_tool *tool, ··· 869 863 unsigned int auxtrace_pages, 870 864 bool auxtrace_overwrite); 871 865 void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, 872 - struct evlist *evlist, int idx, 866 + struct evlist *evlist, 867 + struct evsel *evsel, int idx, 873 868 bool per_cpu); 874 869 875 870 #define ITRACE_HELP ""
+3 -2
tools/perf/util/evlist.c
··· 747 747 748 748 static void 749 749 perf_evlist__mmap_cb_idx(struct perf_evlist *_evlist, 750 - struct perf_evsel *_evsel __maybe_unused, 750 + struct perf_evsel *_evsel, 751 751 struct perf_mmap_param *_mp, 752 752 int idx) 753 753 { 754 754 struct evlist *evlist = container_of(_evlist, struct evlist, core); 755 755 struct mmap_params *mp = container_of(_mp, struct mmap_params, core); 756 756 bool per_cpu = !perf_cpu_map__empty(_evlist->user_requested_cpus); 757 + struct evsel *evsel = container_of(_evsel, struct evsel, core); 757 758 758 - auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, idx, per_cpu); 759 + auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, evsel, idx, per_cpu); 759 760 } 760 761 761 762 static struct perf_mmap*
+1
tools/perf/util/mmap.c
··· 62 62 63 63 void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __maybe_unused, 64 64 struct evlist *evlist __maybe_unused, 65 + struct evsel *evsel __maybe_unused, 65 66 int idx __maybe_unused, 66 67 bool per_cpu __maybe_unused) 67 68 {