mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
perf evsel: Add evsel__open_per_cpu_and_thread
Add evsel__open_per_cpu_and_thread that combines the operation of evsel__open_per_cpu and evsel__open_per_thread so that an event without the "any" cpumask can be opened with its cpumask and with threads it specifies. Change the implementation of evsel__open_per_cpu and evsel__open_per_thread to use evsel__open_per_cpu_and_thread to make the implementation of those functions clearer. Reviewed-by: Thomas Falcon <thomas.falcon@intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: James Clark <james.clark@linaro.org> Link: https://lore.kernel.org/r/20250719030517.1990983-12-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
cd63c22168
commit
e9387ba569
|
|
@ -2761,17 +2761,32 @@ void evsel__close(struct evsel *evsel)
|
|||
perf_evsel__free_id(&evsel->core);
|
||||
}
|
||||
|
||||
int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu_map_idx)
|
||||
int evsel__open_per_cpu_and_thread(struct evsel *evsel,
|
||||
struct perf_cpu_map *cpus, int cpu_map_idx,
|
||||
struct perf_thread_map *threads)
|
||||
{
|
||||
if (cpu_map_idx == -1)
|
||||
return evsel__open_cpu(evsel, cpus, NULL, 0, perf_cpu_map__nr(cpus));
|
||||
return evsel__open_cpu(evsel, cpus, threads, 0, perf_cpu_map__nr(cpus));
|
||||
|
||||
return evsel__open_cpu(evsel, cpus, NULL, cpu_map_idx, cpu_map_idx + 1);
|
||||
return evsel__open_cpu(evsel, cpus, threads, cpu_map_idx, cpu_map_idx + 1);
|
||||
}
|
||||
|
||||
int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu_map_idx)
|
||||
{
|
||||
struct perf_thread_map *threads = thread_map__new_by_tid(-1);
|
||||
int ret = evsel__open_per_cpu_and_thread(evsel, cpus, cpu_map_idx, threads);
|
||||
|
||||
perf_thread_map__put(threads);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads)
|
||||
{
|
||||
return evsel__open(evsel, NULL, threads);
|
||||
struct perf_cpu_map *cpus = perf_cpu_map__new_any_cpu();
|
||||
int ret = evsel__open_per_cpu_and_thread(evsel, cpus, -1, threads);
|
||||
|
||||
perf_cpu_map__put(cpus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int perf_evsel__parse_id_sample(const struct evsel *evsel,
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ int evsel__enable(struct evsel *evsel);
|
|||
int evsel__disable(struct evsel *evsel);
|
||||
int evsel__disable_cpu(struct evsel *evsel, int cpu_map_idx);
|
||||
|
||||
int evsel__open_per_cpu_and_thread(struct evsel *evsel,
|
||||
struct perf_cpu_map *cpus, int cpu_map_idx,
|
||||
struct perf_thread_map *threads);
|
||||
int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu_map_idx);
|
||||
int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads);
|
||||
int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user