[1/5] perf evlist: Export perf_evlist__propagate_maps()
Commit Message
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@huawei.com>
---
tools/lib/perf/evlist.c | 23 +++++++++--------------
tools/lib/perf/include/perf/evlist.h | 2 ++
2 files changed, 11 insertions(+), 14 deletions(-)
Comments
On 4/07/23 10:42, Yang Jihong wrote:
> 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.
__perf_evlist__propagate_maps() is quite low-level so it would be better
to avoid exporting it.
Hello,
On 2023/7/11 21:12, Adrian Hunter wrote:
> On 4/07/23 10:42, Yang Jihong wrote:
>> 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.
>
> __perf_evlist__propagate_maps() is quite low-level so it would be better
> to avoid exporting it.
>
>
Or can we export it via internal/evlist.h?
Because as mentioned in patch 2:
void perf_evsel__go_system_wide(struct perf_evlist *evlist, struct
perf_evsel *evsel)
{
if (!evsel->system_wide) {
evsel->system_wide = true;
if (evlist->needs_map_propagation)
__perf_evlist__propagate_maps(evlist, evsel);
}
}
This interface needs to invoke __perf_evlist__propagate_maps.
Thanks,
Yang
On 12/07/23 17:30, Yang Jihong wrote:
> Hello,
>
> On 2023/7/11 21:12, Adrian Hunter wrote:
>> On 4/07/23 10:42, Yang Jihong wrote:
>>> 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.
>>
>> __perf_evlist__propagate_maps() is quite low-level so it would be better
>> to avoid exporting it.
>>
>>
> Or can we export it via internal/evlist.h?
> Because as mentioned in patch 2:
>
> void perf_evsel__go_system_wide(struct perf_evlist *evlist, struct perf_evsel *evsel)
> {
> if (!evsel->system_wide) {
> evsel->system_wide = true;
> if (evlist->needs_map_propagation)
> __perf_evlist__propagate_maps(evlist, evsel);
> }
> }
> This interface needs to invoke __perf_evlist__propagate_maps.
Yes - put it with __perf_evlist__propagate_maps() and export it instead
>
> Thanks,
> Yang
@@ -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)
@@ -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 */