Commit fba7c866 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

libperf: Move 'leader' from tools/perf to perf_evsel::leader

Move evsel::leader to perf_evsel::leader, so we can move the group
interface to libperf.

Also add several evsel helpers to ease up the transition:

  struct evsel *evsel__leader(struct evsel *evsel);
  - get leader evsel

  bool evsel__has_leader(struct evsel *evsel, struct evsel *leader);
  - true if evsel has leader as leader

  bool evsel__is_leader(struct evsel *evsel);
  - true if evsel is itw own leader

  void evsel__set_leader(struct evsel *evsel, struct evsel *leader);
  - set leader for evsel

Committer notes:

Fix this when building with 'make BUILD_BPF_SKEL=1'

  tools/perf/util/bpf_counter.c

  -       if (evsel->leader->core.nr_members > 1) {
  +       if (evsel->core.leader->nr_members > 1) {
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Requested-by: default avatarShunsuke 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-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 38fe0e01
...@@ -24,6 +24,7 @@ void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, ...@@ -24,6 +24,7 @@ void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
INIT_LIST_HEAD(&evsel->node); INIT_LIST_HEAD(&evsel->node);
evsel->attr = *attr; evsel->attr = *attr;
evsel->idx = idx; evsel->idx = idx;
evsel->leader = evsel;
} }
struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr) struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
......
...@@ -45,6 +45,7 @@ struct perf_evsel { ...@@ -45,6 +45,7 @@ struct perf_evsel {
struct xyarray *sample_id; struct xyarray *sample_id;
u64 *id; u64 *id;
u32 ids; u32 ids;
struct perf_evsel *leader;
/* parse modifier helper */ /* parse modifier helper */
int nr_members; int nr_members;
......
...@@ -926,7 +926,7 @@ static int record__open(struct record *rec) ...@@ -926,7 +926,7 @@ static int record__open(struct record *rec)
goto try_again; goto try_again;
} }
if ((errno == EINVAL || errno == EBADF) && if ((errno == EINVAL || errno == EBADF) &&
pos->leader != pos && pos->core.leader != &pos->core &&
pos->weak_group) { pos->weak_group) {
pos = evlist__reset_weak_group(evlist, pos, true); pos = evlist__reset_weak_group(evlist, pos, true);
goto try_again; goto try_again;
......
...@@ -677,7 +677,7 @@ static int report__collapse_hists(struct report *rep) ...@@ -677,7 +677,7 @@ static int report__collapse_hists(struct report *rep)
/* Non-group events are considered as leader */ /* Non-group events are considered as leader */
if (symbol_conf.event_group && !evsel__is_group_leader(pos)) { if (symbol_conf.event_group && !evsel__is_group_leader(pos)) {
struct hists *leader_hists = evsel__hists(pos->leader); struct hists *leader_hists = evsel__hists(evsel__leader(pos));
hists__match(leader_hists, hists); hists__match(leader_hists, hists);
hists__link(leader_hists, hists); hists__link(leader_hists, hists);
......
...@@ -1899,6 +1899,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, ...@@ -1899,6 +1899,7 @@ static void perf_sample__fprint_metric(struct perf_script *script,
struct perf_sample *sample, struct perf_sample *sample,
FILE *fp) FILE *fp)
{ {
struct evsel *leader = evsel__leader(evsel);
struct perf_stat_output_ctx ctx = { struct perf_stat_output_ctx ctx = {
.print_metric = script_print_metric, .print_metric = script_print_metric,
.new_line = script_new_line, .new_line = script_new_line,
...@@ -1915,7 +1916,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, ...@@ -1915,7 +1916,7 @@ static void perf_sample__fprint_metric(struct perf_script *script,
if (!evsel->stats) if (!evsel->stats)
evlist__alloc_stats(script->session->evlist, false); evlist__alloc_stats(script->session->evlist, false);
if (evsel_script(evsel->leader)->gnum++ == 0) if (evsel_script(leader)->gnum++ == 0)
perf_stat__reset_shadow_stats(); perf_stat__reset_shadow_stats();
val = sample->period * evsel->scale; val = sample->period * evsel->scale;
perf_stat__update_shadow_stats(evsel, perf_stat__update_shadow_stats(evsel,
...@@ -1923,8 +1924,8 @@ static void perf_sample__fprint_metric(struct perf_script *script, ...@@ -1923,8 +1924,8 @@ static void perf_sample__fprint_metric(struct perf_script *script,
sample->cpu, sample->cpu,
&rt_stat); &rt_stat);
evsel_script(evsel)->val = val; evsel_script(evsel)->val = val;
if (evsel_script(evsel->leader)->gnum == evsel->leader->core.nr_members) { if (evsel_script(leader)->gnum == leader->core.nr_members) {
for_each_group_member (ev2, evsel->leader) { for_each_group_member (ev2, leader) {
perf_stat__print_shadow_stats(&stat_config, ev2, perf_stat__print_shadow_stats(&stat_config, ev2,
evsel_script(ev2)->val, evsel_script(ev2)->val,
sample->cpu, sample->cpu,
...@@ -1932,7 +1933,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, ...@@ -1932,7 +1933,7 @@ static void perf_sample__fprint_metric(struct perf_script *script,
NULL, NULL,
&rt_stat); &rt_stat);
} }
evsel_script(evsel->leader)->gnum = 0; evsel_script(leader)->gnum = 0;
} }
} }
......
...@@ -248,7 +248,7 @@ static void evlist__check_cpu_maps(struct evlist *evlist) ...@@ -248,7 +248,7 @@ static void evlist__check_cpu_maps(struct evlist *evlist)
evlist__warn_hybrid_group(evlist); evlist__warn_hybrid_group(evlist);
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
leader = evsel->leader; leader = evsel__leader(evsel);
/* Check that leader matches cpus with each member. */ /* Check that leader matches cpus with each member. */
if (leader == evsel) if (leader == evsel)
...@@ -269,10 +269,10 @@ static void evlist__check_cpu_maps(struct evlist *evlist) ...@@ -269,10 +269,10 @@ static void evlist__check_cpu_maps(struct evlist *evlist)
} }
for_each_group_evsel(pos, leader) { for_each_group_evsel(pos, leader) {
pos->leader = pos; evsel__set_leader(pos, pos);
pos->core.nr_members = 0; pos->core.nr_members = 0;
} }
evsel->leader->core.nr_members = 0; evsel->core.leader->nr_members = 0;
} }
} }
...@@ -745,8 +745,8 @@ static enum counter_recovery stat_handle_error(struct evsel *counter) ...@@ -745,8 +745,8 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)
*/ */
counter->errored = true; counter->errored = true;
if ((counter->leader != counter) || if ((evsel__leader(counter) != counter) ||
!(counter->leader->core.nr_members > 1)) !(counter->core.leader->nr_members > 1))
return COUNTER_SKIP; return COUNTER_SKIP;
} else if (evsel__fallback(counter, errno, msg, sizeof(msg))) { } else if (evsel__fallback(counter, errno, msg, sizeof(msg))) {
if (verbose > 0) if (verbose > 0)
...@@ -839,7 +839,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) ...@@ -839,7 +839,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
* Don't close here because we're in the wrong affinity. * Don't close here because we're in the wrong affinity.
*/ */
if ((errno == EINVAL || errno == EBADF) && if ((errno == EINVAL || errno == EBADF) &&
counter->leader != counter && evsel__leader(counter) != counter &&
counter->weak_group) { counter->weak_group) {
evlist__reset_weak_group(evsel_list, counter, false); evlist__reset_weak_group(evsel_list, counter, false);
assert(counter->reset_group); assert(counter->reset_group);
......
...@@ -301,7 +301,7 @@ static void perf_top__resort_hists(struct perf_top *t) ...@@ -301,7 +301,7 @@ static void perf_top__resort_hists(struct perf_top *t)
/* Non-group events are considered as leader */ /* Non-group events are considered as leader */
if (symbol_conf.event_group && !evsel__is_group_leader(pos)) { if (symbol_conf.event_group && !evsel__is_group_leader(pos)) {
struct hists *leader_hists = evsel__hists(pos->leader); struct hists *leader_hists = evsel__hists(evsel__leader(pos));
hists__match(leader_hists, hists); hists__match(leader_hists, hists);
hists__link(leader_hists, hists); hists__link(leader_hists, hists);
......
This diff is collapsed.
...@@ -73,8 +73,8 @@ static int evlist__regroup(struct evlist *evlist, struct evsel *leader, struct e ...@@ -73,8 +73,8 @@ static int evlist__regroup(struct evlist *evlist, struct evsel *leader, struct e
grp = false; grp = false;
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
if (grp) { if (grp) {
if (!(evsel->leader == leader || if (!(evsel__leader(evsel) == leader ||
(evsel->leader == evsel && (evsel__leader(evsel) == evsel &&
evsel->core.nr_members <= 1))) evsel->core.nr_members <= 1)))
return -EINVAL; return -EINVAL;
} else if (evsel == leader) { } else if (evsel == leader) {
...@@ -87,8 +87,8 @@ static int evlist__regroup(struct evlist *evlist, struct evsel *leader, struct e ...@@ -87,8 +87,8 @@ static int evlist__regroup(struct evlist *evlist, struct evsel *leader, struct e
grp = false; grp = false;
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
if (grp) { if (grp) {
if (evsel->leader != leader) { if (!evsel__has_leader(evsel, leader)) {
evsel->leader = leader; evsel__set_leader(evsel, leader);
if (leader->core.nr_members < 1) if (leader->core.nr_members < 1)
leader->core.nr_members = 1; leader->core.nr_members = 1;
leader->core.nr_members += 1; leader->core.nr_members += 1;
...@@ -1231,11 +1231,11 @@ static void unleader_evsel(struct evlist *evlist, struct evsel *leader) ...@@ -1231,11 +1231,11 @@ static void unleader_evsel(struct evlist *evlist, struct evsel *leader)
/* Find new leader for the group */ /* Find new leader for the group */
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
if (evsel->leader != leader || evsel == leader) if (!evsel__has_leader(evsel, leader) || evsel == leader)
continue; continue;
if (!new_leader) if (!new_leader)
new_leader = evsel; new_leader = evsel;
evsel->leader = new_leader; evsel__set_leader(evsel, new_leader);
} }
/* Update group information */ /* Update group information */
......
...@@ -353,7 +353,7 @@ static int bperf_check_target(struct evsel *evsel, ...@@ -353,7 +353,7 @@ static int bperf_check_target(struct evsel *evsel,
enum bperf_filter_type *filter_type, enum bperf_filter_type *filter_type,
__u32 *filter_entry_cnt) __u32 *filter_entry_cnt)
{ {
if (evsel->leader->core.nr_members > 1) { if (evsel->core.leader->nr_members > 1) {
pr_err("bpf managed perf events do not yet support groups.\n"); pr_err("bpf managed perf events do not yet support groups.\n");
return -1; return -1;
} }
......
...@@ -459,7 +459,7 @@ int evlist__expand_cgroup(struct evlist *evlist, const char *str, ...@@ -459,7 +459,7 @@ int evlist__expand_cgroup(struct evlist *evlist, const char *str,
if (evsel__is_group_leader(pos)) if (evsel__is_group_leader(pos))
leader = evsel; leader = evsel;
evsel->leader = leader; evsel__set_leader(evsel, leader);
evlist__add(tmp_list, evsel); evlist__add(tmp_list, evsel);
} }
......
...@@ -192,7 +192,7 @@ void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list) ...@@ -192,7 +192,7 @@ void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list)
} }
__evlist__for_each_entry_safe(list, temp, evsel) { __evlist__for_each_entry_safe(list, temp, evsel) {
if (evsel->leader == leader) { if (evsel__has_leader(evsel, leader)) {
list_del_init(&evsel->core.node); list_del_init(&evsel->core.node);
evlist__add(evlist, evsel); evlist__add(evlist, evsel);
} }
...@@ -233,7 +233,7 @@ void __evlist__set_leader(struct list_head *list) ...@@ -233,7 +233,7 @@ void __evlist__set_leader(struct list_head *list)
leader->core.nr_members = evsel->core.idx - leader->core.idx + 1; leader->core.nr_members = evsel->core.idx - leader->core.idx + 1;
__evlist__for_each_entry(list, evsel) { __evlist__for_each_entry(list, evsel) {
evsel->leader = leader; evsel->core.leader = &leader->core;
} }
} }
...@@ -1624,7 +1624,7 @@ void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel) ...@@ -1624,7 +1624,7 @@ void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel)
return; return;
evlist__for_each_entry_safe(evlist, n, evsel) { evlist__for_each_entry_safe(evlist, n, evsel) {
if (evsel->leader == move_evsel->leader) if (evsel__leader(evsel) == evsel__leader(move_evsel))
list_move_tail(&evsel->core.node, &move); list_move_tail(&evsel->core.node, &move);
} }
...@@ -1761,7 +1761,8 @@ struct evsel *evlist__reset_weak_group(struct evlist *evsel_list, struct evsel * ...@@ -1761,7 +1761,8 @@ struct evsel *evlist__reset_weak_group(struct evlist *evsel_list, struct evsel *
struct evsel *c2, *leader; struct evsel *c2, *leader;
bool is_open = true; bool is_open = true;
leader = evsel->leader; leader = evsel__leader(evsel);
pr_debug("Weak group for %s/%d failed\n", pr_debug("Weak group for %s/%d failed\n",
leader->name, leader->core.nr_members); leader->name, leader->core.nr_members);
...@@ -1772,10 +1773,10 @@ struct evsel *evlist__reset_weak_group(struct evlist *evsel_list, struct evsel * ...@@ -1772,10 +1773,10 @@ struct evsel *evlist__reset_weak_group(struct evlist *evsel_list, struct evsel *
evlist__for_each_entry(evsel_list, c2) { evlist__for_each_entry(evsel_list, c2) {
if (c2 == evsel) if (c2 == evsel)
is_open = false; is_open = false;
if (c2->leader == leader) { if (evsel__has_leader(c2, leader)) {
if (is_open && close) if (is_open && close)
perf_evsel__close(&c2->core); perf_evsel__close(&c2->core);
c2->leader = c2; evsel__set_leader(c2, c2);
c2->core.nr_members = 0; c2->core.nr_members = 0;
/* /*
* Set this for all former members of the group * Set this for all former members of the group
...@@ -2172,13 +2173,13 @@ void evlist__check_mem_load_aux(struct evlist *evlist) ...@@ -2172,13 +2173,13 @@ void evlist__check_mem_load_aux(struct evlist *evlist)
* any valid memory load information. * any valid memory load information.
*/ */
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
leader = evsel->leader; leader = evsel__leader(evsel);
if (leader == evsel) if (leader == evsel)
continue; continue;
if (leader->name && strstr(leader->name, "mem-loads-aux")) { if (leader->name && strstr(leader->name, "mem-loads-aux")) {
for_each_group_evsel(pos, leader) { for_each_group_evsel(pos, leader) {
pos->leader = pos; evsel__set_leader(pos, pos);
pos->core.nr_members = 0; pos->core.nr_members = 0;
} }
} }
......
...@@ -241,7 +241,6 @@ void evsel__init(struct evsel *evsel, ...@@ -241,7 +241,6 @@ void evsel__init(struct evsel *evsel,
{ {
perf_evsel__init(&evsel->core, attr, idx); perf_evsel__init(&evsel->core, attr, idx);
evsel->tracking = !idx; evsel->tracking = !idx;
evsel->leader = evsel;
evsel->unit = ""; evsel->unit = "";
evsel->scale = 1.0; evsel->scale = 1.0;
evsel->max_events = ULONG_MAX; evsel->max_events = ULONG_MAX;
...@@ -409,7 +408,7 @@ struct evsel *evsel__clone(struct evsel *orig) ...@@ -409,7 +408,7 @@ struct evsel *evsel__clone(struct evsel *orig)
evsel->cgrp = cgroup__get(orig->cgrp); evsel->cgrp = cgroup__get(orig->cgrp);
evsel->tp_format = orig->tp_format; evsel->tp_format = orig->tp_format;
evsel->handler = orig->handler; evsel->handler = orig->handler;
evsel->leader = orig->leader; evsel->core.leader = orig->core.leader;
evsel->max_events = orig->max_events; evsel->max_events = orig->max_events;
evsel->tool_event = orig->tool_event; evsel->tool_event = orig->tool_event;
...@@ -1074,7 +1073,7 @@ void __weak arch_evsel__set_sample_weight(struct evsel *evsel) ...@@ -1074,7 +1073,7 @@ void __weak arch_evsel__set_sample_weight(struct evsel *evsel)
void evsel__config(struct evsel *evsel, struct record_opts *opts, void evsel__config(struct evsel *evsel, struct record_opts *opts,
struct callchain_param *callchain) struct callchain_param *callchain)
{ {
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
struct perf_event_attr *attr = &evsel->core.attr; struct perf_event_attr *attr = &evsel->core.attr;
int track = evsel->tracking; int track = evsel->tracking;
bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread; bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread;
...@@ -1592,7 +1591,7 @@ static int evsel__match_other_cpu(struct evsel *evsel, struct evsel *other, ...@@ -1592,7 +1591,7 @@ static int evsel__match_other_cpu(struct evsel *evsel, struct evsel *other,
static int evsel__hybrid_group_cpu(struct evsel *evsel, int cpu) static int evsel__hybrid_group_cpu(struct evsel *evsel, int cpu)
{ {
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
if ((evsel__is_hybrid(evsel) && !evsel__is_hybrid(leader)) || if ((evsel__is_hybrid(evsel) && !evsel__is_hybrid(leader)) ||
(!evsel__is_hybrid(evsel) && evsel__is_hybrid(leader))) { (!evsel__is_hybrid(evsel) && evsel__is_hybrid(leader))) {
...@@ -1604,7 +1603,7 @@ static int evsel__hybrid_group_cpu(struct evsel *evsel, int cpu) ...@@ -1604,7 +1603,7 @@ static int evsel__hybrid_group_cpu(struct evsel *evsel, int cpu)
static int get_group_fd(struct evsel *evsel, int cpu, int thread) static int get_group_fd(struct evsel *evsel, int cpu, int thread)
{ {
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
int fd; int fd;
if (evsel__is_group_leader(evsel)) if (evsel__is_group_leader(evsel))
...@@ -2850,3 +2849,23 @@ bool evsel__is_hybrid(struct evsel *evsel) ...@@ -2850,3 +2849,23 @@ bool evsel__is_hybrid(struct evsel *evsel)
{ {
return evsel->pmu_name && perf_pmu__is_hybrid(evsel->pmu_name); return evsel->pmu_name && perf_pmu__is_hybrid(evsel->pmu_name);
} }
struct evsel *evsel__leader(struct evsel *evsel)
{
return container_of(evsel->core.leader, struct evsel, core);
}
bool evsel__has_leader(struct evsel *evsel, struct evsel *leader)
{
return evsel->core.leader == &leader->core;
}
bool evsel__is_leader(struct evsel *evsel)
{
return evsel__has_leader(evsel, evsel);
}
void evsel__set_leader(struct evsel *evsel, struct evsel *leader)
{
evsel->core.leader = &leader->core;
}
...@@ -118,7 +118,6 @@ struct evsel { ...@@ -118,7 +118,6 @@ struct evsel {
bool reset_group; bool reset_group;
bool errored; bool errored;
struct hashmap *per_pkg_mask; struct hashmap *per_pkg_mask;
struct evsel *leader;
int err; int err;
int cpu_iter; int cpu_iter;
struct { struct {
...@@ -367,7 +366,7 @@ static inline struct evsel *evsel__prev(struct evsel *evsel) ...@@ -367,7 +366,7 @@ static inline struct evsel *evsel__prev(struct evsel *evsel)
*/ */
static inline bool evsel__is_group_leader(const struct evsel *evsel) static inline bool evsel__is_group_leader(const struct evsel *evsel)
{ {
return evsel->leader == evsel; return evsel->core.leader == &evsel->core;
} }
/** /**
...@@ -405,19 +404,19 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target, ...@@ -405,19 +404,19 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
static inline int evsel__group_idx(struct evsel *evsel) static inline int evsel__group_idx(struct evsel *evsel)
{ {
return evsel->core.idx - evsel->leader->core.idx; return evsel->core.idx - evsel->core.leader->idx;
} }
/* Iterates group WITHOUT the leader. */ /* Iterates group WITHOUT the leader. */
#define for_each_group_member(_evsel, _leader) \ #define for_each_group_member(_evsel, _leader) \
for ((_evsel) = list_entry((_leader)->core.node.next, struct evsel, core.node); \ for ((_evsel) = list_entry((_leader)->core.node.next, struct evsel, core.node); \
(_evsel) && (_evsel)->leader == (_leader); \ (_evsel) && (_evsel)->core.leader == (&_leader->core); \
(_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node)) (_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node))
/* Iterates group WITH the leader. */ /* Iterates group WITH the leader. */
#define for_each_group_evsel(_evsel, _leader) \ #define for_each_group_evsel(_evsel, _leader) \
for ((_evsel) = _leader; \ for ((_evsel) = _leader; \
(_evsel) && (_evsel)->leader == (_leader); \ (_evsel) && (_evsel)->core.leader == (&_leader->core); \
(_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node)) (_evsel) = list_entry((_evsel)->core.node.next, struct evsel, core.node))
static inline bool evsel__has_branch_callstack(const struct evsel *evsel) static inline bool evsel__has_branch_callstack(const struct evsel *evsel)
...@@ -462,4 +461,8 @@ int evsel__store_ids(struct evsel *evsel, struct evlist *evlist); ...@@ -462,4 +461,8 @@ int evsel__store_ids(struct evsel *evsel, struct evlist *evlist);
void evsel__zero_per_pkg(struct evsel *evsel); void evsel__zero_per_pkg(struct evsel *evsel);
bool evsel__is_hybrid(struct evsel *evsel); bool evsel__is_hybrid(struct evsel *evsel);
struct evsel *evsel__leader(struct evsel *evsel);
bool evsel__has_leader(struct evsel *evsel, struct evsel *leader);
bool evsel__is_leader(struct evsel *evsel);
void evsel__set_leader(struct evsel *evsel, struct evsel *leader);
#endif /* __PERF_EVSEL_H */ #endif /* __PERF_EVSEL_H */
...@@ -2740,7 +2740,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) ...@@ -2740,7 +2740,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
i = nr = 0; i = nr = 0;
evlist__for_each_entry(session->evlist, evsel) { evlist__for_each_entry(session->evlist, evsel) {
if (evsel->core.idx == (int) desc[i].leader_idx) { if (evsel->core.idx == (int) desc[i].leader_idx) {
evsel->leader = evsel; evsel__set_leader(evsel, evsel);
/* {anon_group} is a dummy name */ /* {anon_group} is a dummy name */
if (strcmp(desc[i].name, "{anon_group}")) { if (strcmp(desc[i].name, "{anon_group}")) {
evsel->group_name = desc[i].name; evsel->group_name = desc[i].name;
...@@ -2758,7 +2758,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) ...@@ -2758,7 +2758,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
i++; i++;
} else if (nr) { } else if (nr) {
/* This is a group member */ /* This is a group member */
evsel->leader = leader; evsel__set_leader(evsel, leader);
nr--; nr--;
} }
......
...@@ -221,7 +221,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, ...@@ -221,7 +221,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
/* Ignore event if already used and merging is disabled. */ /* Ignore event if already used and merging is disabled. */
if (metric_no_merge && test_bit(ev->core.idx, evlist_used)) if (metric_no_merge && test_bit(ev->core.idx, evlist_used))
continue; continue;
if (!has_constraint && ev->leader != current_leader) { if (!has_constraint && !evsel__has_leader(ev, current_leader)) {
/* /*
* Start of a new group, discard the whole match and * Start of a new group, discard the whole match and
* start again. * start again.
...@@ -229,7 +229,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, ...@@ -229,7 +229,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
matched_events = 0; matched_events = 0;
memset(metric_events, 0, memset(metric_events, 0,
sizeof(struct evsel *) * idnum); sizeof(struct evsel *) * idnum);
current_leader = ev->leader; current_leader = evsel__leader(ev);
} }
/* /*
* Check for duplicate events with the same name. For example, * Check for duplicate events with the same name. For example,
...@@ -287,8 +287,8 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, ...@@ -287,8 +287,8 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
* when then group is left. * when then group is left.
*/ */
if (!has_constraint && if (!has_constraint &&
ev->leader != metric_events[i]->leader && ev->core.leader != metric_events[i]->core.leader &&
evsel_same_pmu_or_none(ev->leader, metric_events[i]->leader)) evsel_same_pmu_or_none(evsel__leader(ev), evsel__leader(metric_events[i])))
break; break;
if (!strcmp(metric_events[i]->name, ev->name)) { if (!strcmp(metric_events[i]->name, ev->name)) {
set_bit(ev->core.idx, evlist_used); set_bit(ev->core.idx, evlist_used);
......
...@@ -1800,7 +1800,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, ...@@ -1800,7 +1800,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
__evlist__for_each_entry(list, evsel) { __evlist__for_each_entry(list, evsel) {
if (i >= nr_pmu) if (i >= nr_pmu)
i = 0; i = 0;
evsel->leader = (struct evsel *) leaders[i++]; evsel__set_leader(evsel, (struct evsel *) leaders[i++]);
} }
/* The number of members and group name are same for each group */ /* The number of members and group name are same for each group */
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
*/ */
static struct evsel *evsel__read_sampler(struct evsel *evsel, struct evlist *evlist) static struct evsel *evsel__read_sampler(struct evsel *evsel, struct evlist *evlist)
{ {
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
if (evsel__is_aux_event(leader) || arch_topdown_sample_read(leader) || if (evsel__is_aux_event(leader) || arch_topdown_sample_read(leader) ||
is_mem_loads_aux_event(leader)) { is_mem_loads_aux_event(leader)) {
evlist__for_each_entry(evlist, evsel) { evlist__for_each_entry(evlist, evsel) {
if (evsel->leader == leader && evsel != evsel->leader) if (evsel__leader(evsel) == leader && evsel != evsel__leader(evsel))
return evsel; return evsel;
} }
} }
...@@ -53,7 +53,7 @@ static u64 evsel__config_term_mask(struct evsel *evsel) ...@@ -53,7 +53,7 @@ static u64 evsel__config_term_mask(struct evsel *evsel)
static void evsel__config_leader_sampling(struct evsel *evsel, struct evlist *evlist) static void evsel__config_leader_sampling(struct evsel *evsel, struct evlist *evlist)
{ {
struct perf_event_attr *attr = &evsel->core.attr; struct perf_event_attr *attr = &evsel->core.attr;
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
struct evsel *read_sampler; struct evsel *read_sampler;
u64 term_types, freq_mask; u64 term_types, freq_mask;
......
...@@ -379,7 +379,7 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list) ...@@ -379,7 +379,7 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list)
evlist__for_each_entry(evsel_list, counter) { evlist__for_each_entry(evsel_list, counter) {
bool invalid = false; bool invalid = false;
leader = counter->leader; leader = evsel__leader(counter);
if (!counter->metric_expr) if (!counter->metric_expr)
continue; continue;
......
...@@ -534,7 +534,7 @@ int create_perf_stat_counter(struct evsel *evsel, ...@@ -534,7 +534,7 @@ int create_perf_stat_counter(struct evsel *evsel,
int cpu) int cpu)
{ {
struct perf_event_attr *attr = &evsel->core.attr; struct perf_event_attr *attr = &evsel->core.attr;
struct evsel *leader = evsel->leader; struct evsel *leader = evsel__leader(evsel);
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
PERF_FORMAT_TOTAL_TIME_RUNNING; PERF_FORMAT_TOTAL_TIME_RUNNING;
......
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