mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 13:15:57 +00:00
perf stream: Use evsel rather than evsel->idx
An evsel idx may not be stable due to sorting, evlist removal, etc. Avoid use of the idx where the evsel itself can be used to avoid these problems. Reviewed-by: James Clark <james.clark@linaro.org> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Chen Ni <nichen@iscas.ac.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20241114230713.330701-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
518413d89c
commit
2f0539fa02
@ -1020,12 +1020,12 @@ static int process_base_stream(struct data__file *data_base,
|
||||
continue;
|
||||
|
||||
es_base = evsel_streams__entry(data_base->evlist_streams,
|
||||
evsel_base->core.idx);
|
||||
evsel_base);
|
||||
if (!es_base)
|
||||
return -1;
|
||||
|
||||
es_pair = evsel_streams__entry(data_pair->evlist_streams,
|
||||
evsel_pair->core.idx);
|
||||
evsel_pair);
|
||||
if (!es_pair)
|
||||
return -1;
|
||||
|
||||
|
@ -52,7 +52,6 @@ static struct evlist_streams *evlist_streams__new(int nr_evsel,
|
||||
goto err;
|
||||
|
||||
s->nr_streams_max = nr_streams_max;
|
||||
s->evsel_idx = -1;
|
||||
}
|
||||
|
||||
els->ev_streams = es;
|
||||
@ -139,7 +138,7 @@ static int evlist__init_callchain_streams(struct evlist *evlist,
|
||||
|
||||
hists__output_resort(hists, NULL);
|
||||
init_hot_callchain(hists, &es[i]);
|
||||
es[i].evsel_idx = pos->core.idx;
|
||||
es[i].evsel = pos;
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -166,12 +165,12 @@ struct evlist_streams *evlist__create_streams(struct evlist *evlist,
|
||||
}
|
||||
|
||||
struct evsel_streams *evsel_streams__entry(struct evlist_streams *els,
|
||||
int evsel_idx)
|
||||
const struct evsel *evsel)
|
||||
{
|
||||
struct evsel_streams *es = els->ev_streams;
|
||||
|
||||
for (int i = 0; i < els->nr_evsel; i++) {
|
||||
if (es[i].evsel_idx == evsel_idx)
|
||||
if (es[i].evsel == evsel)
|
||||
return &es[i];
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
#ifndef __PERF_STREAM_H
|
||||
#define __PERF_STREAM_H
|
||||
|
||||
#include "callchain.h"
|
||||
struct callchain_node;
|
||||
struct evlist;
|
||||
struct evsel;
|
||||
|
||||
struct stream {
|
||||
struct callchain_node *cnode;
|
||||
@ -11,9 +13,9 @@ struct stream {
|
||||
|
||||
struct evsel_streams {
|
||||
struct stream *streams;
|
||||
const struct evsel *evsel;
|
||||
int nr_streams_max;
|
||||
int nr_streams;
|
||||
int evsel_idx;
|
||||
u64 streams_hits;
|
||||
};
|
||||
|
||||
@ -22,15 +24,13 @@ struct evlist_streams {
|
||||
int nr_evsel;
|
||||
};
|
||||
|
||||
struct evlist;
|
||||
|
||||
void evlist_streams__delete(struct evlist_streams *els);
|
||||
|
||||
struct evlist_streams *evlist__create_streams(struct evlist *evlist,
|
||||
int nr_streams_max);
|
||||
|
||||
struct evsel_streams *evsel_streams__entry(struct evlist_streams *els,
|
||||
int evsel_idx);
|
||||
const struct evsel *evsel);
|
||||
|
||||
void evsel_streams__match(struct evsel_streams *es_base,
|
||||
struct evsel_streams *es_pair);
|
||||
|
Loading…
x
Reference in New Issue
Block a user