[PATCH 1/5] perf evlist: Export perf_evlist__propagate_maps()

From: Yang Jihong
Date: Tue Jul 04 2023 - 03:44:35 EST


For dummy events that keep tracking, we may need to modify its cpu_maps.
For example, change the cpu_maps to track side-band events for all CPUS.
Export perf_evlist__propagate_maps () to support this scenario.

No functional change.

Signed-off-by: Yang Jihong <yangjihong1@xxxxxxxxxx>
---
tools/lib/perf/evlist.c | 23 +++++++++--------------
tools/lib/perf/include/perf/evlist.h | 2 ++
2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index b8b066d0dc5e..a3057b692530 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -33,8 +33,8 @@ void perf_evlist__init(struct perf_evlist *evlist)
perf_evlist__reset_id_hash(evlist);
}

-static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
- struct perf_evsel *evsel)
+void perf_evlist__propagate_maps(struct perf_evlist *evlist,
+ struct perf_evsel *evsel)
{
if (evsel->system_wide) {
/* System wide: set the cpu map of the evsel to all online CPUs. */
@@ -78,16 +78,6 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
evlist->all_cpus = perf_cpu_map__merge(evlist->all_cpus, evsel->cpus);
}

-static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
-{
- struct perf_evsel *evsel;
-
- evlist->needs_map_propagation = true;
-
- perf_evlist__for_each_evsel(evlist, evsel)
- __perf_evlist__propagate_maps(evlist, evsel);
-}
-
void perf_evlist__add(struct perf_evlist *evlist,
struct perf_evsel *evsel)
{
@@ -96,7 +86,7 @@ void perf_evlist__add(struct perf_evlist *evlist,
evlist->nr_entries += 1;

if (evlist->needs_map_propagation)
- __perf_evlist__propagate_maps(evlist, evsel);
+ perf_evlist__propagate_maps(evlist, evsel);
}

void perf_evlist__remove(struct perf_evlist *evlist,
@@ -175,6 +165,8 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,
struct perf_cpu_map *cpus,
struct perf_thread_map *threads)
{
+ struct perf_evsel *evsel;
+
/*
* Allow for the possibility that one or another of the maps isn't being
* changed i.e. don't put it. Note we are assuming the maps that are
@@ -192,7 +184,10 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,
evlist->threads = perf_thread_map__get(threads);
}

- perf_evlist__propagate_maps(evlist);
+ evlist->needs_map_propagation = true;
+
+ perf_evlist__for_each_evsel(evlist, evsel)
+ perf_evlist__propagate_maps(evlist, evsel);
}

int perf_evlist__open(struct perf_evlist *evlist)
diff --git a/tools/lib/perf/include/perf/evlist.h b/tools/lib/perf/include/perf/evlist.h
index e894b770779e..d5a2569b2177 100644
--- a/tools/lib/perf/include/perf/evlist.h
+++ b/tools/lib/perf/include/perf/evlist.h
@@ -48,4 +48,6 @@ LIBPERF_API struct perf_mmap *perf_evlist__next_mmap(struct perf_evlist *evlist,

LIBPERF_API void perf_evlist__set_leader(struct perf_evlist *evlist);
LIBPERF_API int perf_evlist__nr_groups(struct perf_evlist *evlist);
+LIBPERF_API void perf_evlist__propagate_maps(struct perf_evlist *evlist,
+ struct perf_evsel *evsel);
#endif /* __LIBPERF_EVLIST_H */
--
2.30.GIT