提交 2e6263ab 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

libperf: Adopt evlist__set_leader() from tools/perf as perf_evlist__set_leader()

Move the implementation of evlist__set_leader() to a new libperf
perf_evlist__set_leader() function with the same functionality make it a
libperf exported API.
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Requested-by: NShunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210706151704.73662-6-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 3a683120
无相关合并请求
...@@ -642,3 +642,24 @@ perf_evlist__next_mmap(struct perf_evlist *evlist, struct perf_mmap *map, ...@@ -642,3 +642,24 @@ perf_evlist__next_mmap(struct perf_evlist *evlist, struct perf_mmap *map,
return overwrite ? evlist->mmap_ovw_first : evlist->mmap_first; return overwrite ? evlist->mmap_ovw_first : evlist->mmap_first;
} }
void __perf_evlist__set_leader(struct list_head *list)
{
struct perf_evsel *evsel, *leader;
leader = list_entry(list->next, struct perf_evsel, node);
evsel = list_entry(list->prev, struct perf_evsel, node);
leader->nr_members = evsel->idx - leader->idx + 1;
__perf_evlist__for_each_entry(list, evsel)
evsel->leader = leader;
}
void perf_evlist__set_leader(struct perf_evlist *evlist)
{
if (evlist->nr_entries) {
evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0;
__perf_evlist__set_leader(&evlist->entries);
}
}
...@@ -127,4 +127,5 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist, ...@@ -127,4 +127,5 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist,
void perf_evlist__reset_id_hash(struct perf_evlist *evlist); void perf_evlist__reset_id_hash(struct perf_evlist *evlist);
void __perf_evlist__set_leader(struct list_head *list);
#endif /* __LIBPERF_INTERNAL_EVLIST_H */ #endif /* __LIBPERF_INTERNAL_EVLIST_H */
...@@ -46,4 +46,5 @@ LIBPERF_API struct perf_mmap *perf_evlist__next_mmap(struct perf_evlist *evlist, ...@@ -46,4 +46,5 @@ LIBPERF_API struct perf_mmap *perf_evlist__next_mmap(struct perf_evlist *evlist,
(pos) != NULL; \ (pos) != NULL; \
(pos) = perf_evlist__next_mmap((evlist), (pos), overwrite)) (pos) = perf_evlist__next_mmap((evlist), (pos), overwrite))
LIBPERF_API void perf_evlist__set_leader(struct perf_evlist *evlist);
#endif /* __LIBPERF_EVLIST_H */ #endif /* __LIBPERF_EVLIST_H */
...@@ -45,6 +45,7 @@ LIBPERF_0.0.1 { ...@@ -45,6 +45,7 @@ LIBPERF_0.0.1 {
perf_evlist__munmap; perf_evlist__munmap;
perf_evlist__filter_pollfd; perf_evlist__filter_pollfd;
perf_evlist__next_mmap; perf_evlist__next_mmap;
perf_evlist__set_leader;
perf_mmap__consume; perf_mmap__consume;
perf_mmap__read_init; perf_mmap__read_init;
perf_mmap__read_done; perf_mmap__read_done;
......
...@@ -223,26 +223,9 @@ int __evlist__set_tracepoints_handlers(struct evlist *evlist, ...@@ -223,26 +223,9 @@ int __evlist__set_tracepoints_handlers(struct evlist *evlist,
return err; return err;
} }
void __evlist__set_leader(struct list_head *list)
{
struct evsel *evsel, *leader;
leader = list_entry(list->next, struct evsel, core.node);
evsel = list_entry(list->prev, struct evsel, core.node);
leader->core.nr_members = evsel->core.idx - leader->core.idx + 1;
__evlist__for_each_entry(list, evsel) {
evsel->core.leader = &leader->core;
}
}
void evlist__set_leader(struct evlist *evlist) void evlist__set_leader(struct evlist *evlist)
{ {
if (evlist->core.nr_entries) { perf_evlist__set_leader(&evlist->core);
evlist->core.nr_groups = evlist->core.nr_entries > 1 ? 1 : 0;
__evlist__set_leader(&evlist->core.entries);
}
} }
int __evlist__add_default(struct evlist *evlist, bool precise) int __evlist__add_default(struct evlist *evlist, bool precise)
......
...@@ -201,7 +201,6 @@ void evlist__set_selected(struct evlist *evlist, struct evsel *evsel); ...@@ -201,7 +201,6 @@ void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);
int evlist__create_maps(struct evlist *evlist, struct target *target); int evlist__create_maps(struct evlist *evlist, struct target *target);
int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel); int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
void __evlist__set_leader(struct list_head *list);
void evlist__set_leader(struct evlist *evlist); void evlist__set_leader(struct evlist *evlist);
u64 __evlist__combined_sample_type(struct evlist *evlist); u64 __evlist__combined_sample_type(struct evlist *evlist);
......
...@@ -1833,7 +1833,7 @@ void parse_events__set_leader(char *name, struct list_head *list, ...@@ -1833,7 +1833,7 @@ void parse_events__set_leader(char *name, struct list_head *list,
if (parse_events__set_leader_for_uncore_aliase(name, list, parse_state)) if (parse_events__set_leader_for_uncore_aliase(name, list, parse_state))
return; return;
__evlist__set_leader(list); __perf_evlist__set_leader(list);
leader = list_entry(list->next, struct evsel, core.node); leader = list_entry(list->next, struct evsel, core.node);
leader->group_name = name ? strdup(name) : NULL; leader->group_name = name ? strdup(name) : NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部