Commit d01508f2 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

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: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarNamhyung 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1097b38f
...@@ -125,7 +125,7 @@ int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, ...@@ -125,7 +125,7 @@ int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
mm->tid = mp->tid; mm->tid = mp->tid;
mm->cpu = mp->cpu.cpu; mm->cpu = mp->cpu.cpu;
if (!mp->len) { if (!mp->len || !mp->mmap_needed) {
mm->base = NULL; mm->base = NULL;
return 0; return 0;
} }
...@@ -168,9 +168,15 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp, ...@@ -168,9 +168,15 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
} }
void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
struct evlist *evlist, int idx, struct evlist *evlist,
struct evsel *evsel, int idx,
bool per_cpu) bool per_cpu)
{ {
mp->mmap_needed = evsel->needs_auxtrace_mmap;
if (!mp->mmap_needed)
return;
mp->idx = idx; mp->idx = idx;
if (per_cpu) { if (per_cpu) {
......
...@@ -344,6 +344,10 @@ struct auxtrace_mmap { ...@@ -344,6 +344,10 @@ struct auxtrace_mmap {
* @idx: index of this mmap * @idx: index of this mmap
* @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu * @tid: tid for a per-thread mmap (also set if there is only 1 tid on a per-cpu
* mmap) otherwise %0 * mmap) otherwise %0
* @mmap_needed: set to %false for non-auxtrace events. This is needed because
* auxtrace mmapping is done in the same code path as non-auxtrace
* mmapping but not every evsel that needs non-auxtrace mmapping
* also needs auxtrace mmapping.
* @cpu: cpu number for a per-cpu mmap otherwise %-1 * @cpu: cpu number for a per-cpu mmap otherwise %-1
*/ */
struct auxtrace_mmap_params { struct auxtrace_mmap_params {
...@@ -353,6 +357,7 @@ struct auxtrace_mmap_params { ...@@ -353,6 +357,7 @@ struct auxtrace_mmap_params {
int prot; int prot;
int idx; int idx;
pid_t tid; pid_t tid;
bool mmap_needed;
struct perf_cpu cpu; struct perf_cpu cpu;
}; };
...@@ -490,7 +495,8 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp, ...@@ -490,7 +495,8 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
unsigned int auxtrace_pages, unsigned int auxtrace_pages,
bool auxtrace_overwrite); bool auxtrace_overwrite);
void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
struct evlist *evlist, int idx, struct evlist *evlist,
struct evsel *evsel, int idx,
bool per_cpu); bool per_cpu);
typedef int (*process_auxtrace_t)(struct perf_tool *tool, typedef int (*process_auxtrace_t)(struct perf_tool *tool,
...@@ -863,7 +869,8 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp, ...@@ -863,7 +869,8 @@ void auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp,
unsigned int auxtrace_pages, unsigned int auxtrace_pages,
bool auxtrace_overwrite); bool auxtrace_overwrite);
void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
struct evlist *evlist, int idx, struct evlist *evlist,
struct evsel *evsel, int idx,
bool per_cpu); bool per_cpu);
#define ITRACE_HELP "" #define ITRACE_HELP ""
......
...@@ -747,15 +747,16 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist, ...@@ -747,15 +747,16 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist,
static void static void
perf_evlist__mmap_cb_idx(struct perf_evlist *_evlist, perf_evlist__mmap_cb_idx(struct perf_evlist *_evlist,
struct perf_evsel *_evsel __maybe_unused, struct perf_evsel *_evsel,
struct perf_mmap_param *_mp, struct perf_mmap_param *_mp,
int idx) int idx)
{ {
struct evlist *evlist = container_of(_evlist, struct evlist, core); struct evlist *evlist = container_of(_evlist, struct evlist, core);
struct mmap_params *mp = container_of(_mp, struct mmap_params, core); struct mmap_params *mp = container_of(_mp, struct mmap_params, core);
bool per_cpu = !perf_cpu_map__empty(_evlist->user_requested_cpus); bool per_cpu = !perf_cpu_map__empty(_evlist->user_requested_cpus);
struct evsel *evsel = container_of(_evsel, struct evsel, core);
auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, idx, per_cpu); auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, evsel, idx, per_cpu);
} }
static struct perf_mmap* static struct perf_mmap*
......
...@@ -62,6 +62,7 @@ void __weak auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp __maybe_u ...@@ -62,6 +62,7 @@ void __weak auxtrace_mmap_params__init(struct auxtrace_mmap_params *mp __maybe_u
void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __maybe_unused, void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __maybe_unused,
struct evlist *evlist __maybe_unused, struct evlist *evlist __maybe_unused,
struct evsel *evsel __maybe_unused,
int idx __maybe_unused, int idx __maybe_unused,
bool per_cpu __maybe_unused) bool per_cpu __maybe_unused)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment