Commit c3537fc2 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

perf evlist: Move perf_evsel__reset_weak_group into evlist

- Move the function from builtin-stat to evlist for reuse
- Rename to evlist to match purpose better
- Pass the evlist as first argument.
- No functional changes
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20181001195927.14211-1-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 79ef68c7
...@@ -383,32 +383,6 @@ static bool perf_evsel__should_store_id(struct perf_evsel *counter) ...@@ -383,32 +383,6 @@ static bool perf_evsel__should_store_id(struct perf_evsel *counter)
return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID; return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID;
} }
static struct perf_evsel *perf_evsel__reset_weak_group(struct perf_evsel *evsel)
{
struct perf_evsel *c2, *leader;
bool is_open = true;
leader = evsel->leader;
pr_debug("Weak group for %s/%d failed\n",
leader->name, leader->nr_members);
/*
* for_each_group_member doesn't work here because it doesn't
* include the first entry.
*/
evlist__for_each_entry(evsel_list, c2) {
if (c2 == evsel)
is_open = false;
if (c2->leader == leader) {
if (is_open)
perf_evsel__close(c2);
c2->leader = c2;
c2->nr_members = 0;
}
}
return leader;
}
static bool is_target_alive(struct target *_target, static bool is_target_alive(struct target *_target,
struct thread_map *threads) struct thread_map *threads)
{ {
...@@ -477,7 +451,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) ...@@ -477,7 +451,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
if ((errno == EINVAL || errno == EBADF) && if ((errno == EINVAL || errno == EBADF) &&
counter->leader != counter && counter->leader != counter &&
counter->weak_group) { counter->weak_group) {
counter = perf_evsel__reset_weak_group(counter); counter = perf_evlist__reset_weak_group(evsel_list, counter);
goto try_again; goto try_again;
} }
......
...@@ -1810,3 +1810,30 @@ void perf_evlist__force_leader(struct perf_evlist *evlist) ...@@ -1810,3 +1810,30 @@ void perf_evlist__force_leader(struct perf_evlist *evlist)
leader->forced_leader = true; leader->forced_leader = true;
} }
} }
struct perf_evsel *perf_evlist__reset_weak_group(struct perf_evlist *evsel_list,
struct perf_evsel *evsel)
{
struct perf_evsel *c2, *leader;
bool is_open = true;
leader = evsel->leader;
pr_debug("Weak group for %s/%d failed\n",
leader->name, leader->nr_members);
/*
* for_each_group_member doesn't work here because it doesn't
* include the first entry.
*/
evlist__for_each_entry(evsel_list, c2) {
if (c2 == evsel)
is_open = false;
if (c2->leader == leader) {
if (is_open)
perf_evsel__close(c2);
c2->leader = c2;
c2->nr_members = 0;
}
}
return leader;
}
...@@ -312,4 +312,7 @@ bool perf_evlist__exclude_kernel(struct perf_evlist *evlist); ...@@ -312,4 +312,7 @@ bool perf_evlist__exclude_kernel(struct perf_evlist *evlist);
void perf_evlist__force_leader(struct perf_evlist *evlist); void perf_evlist__force_leader(struct perf_evlist *evlist);
struct perf_evsel *perf_evlist__reset_weak_group(struct perf_evlist *evlist,
struct perf_evsel *evsel);
#endif /* __PERF_EVLIST_H */ #endif /* __PERF_EVLIST_H */
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