Commit 38fe0e01 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

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



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

Committer notes:

Fixup evsel->idx usage in tools/perf/util/bpf_counter_cgroup.c, that
appeared in my tree in my local tree.

Also fixed up these:

$ find tools/perf/ -name "*.[ch]" | xargs grep 'evsel->idx'
tools/perf/ui/gtk/annotate.c:                      evsel->idx + i);
tools/perf/ui/gtk/annotate.c:                   evsel->idx);
$

That running 'make -C tools/perf build-test' caught.

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-3-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3d970601
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
void perf_evlist__add(struct perf_evlist *evlist,
		      struct perf_evsel *evsel)
{
	evsel->idx = evlist->nr_entries;
	list_add_tail(&evsel->node, &evlist->entries);
	evlist->nr_entries += 1;
	__perf_evlist__propagate_maps(evlist, evsel);
+4 −2
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@
#include <sys/ioctl.h>
#include <sys/mman.h>

void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr)
void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
		      int idx)
{
	INIT_LIST_HEAD(&evsel->node);
	evsel->attr = *attr;
	evsel->idx  = idx;
}

struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
@@ -29,7 +31,7 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
	struct perf_evsel *evsel = zalloc(sizeof(*evsel));

	if (evsel != NULL)
		perf_evsel__init(evsel, attr);
		perf_evsel__init(evsel, attr, 0);

	return evsel;
}
+3 −1
Original line number Diff line number Diff line
@@ -49,9 +49,11 @@ struct perf_evsel {
	/* parse modifier helper */
	int			 nr_members;
	bool			 system_wide;
	int			 idx;
};

void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr);
void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
		      int idx);
int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
void perf_evsel__close_fd(struct perf_evsel *evsel);
void perf_evsel__free_fd(struct perf_evsel *evsel);
+2 −2
Original line number Diff line number Diff line
@@ -322,7 +322,7 @@ static int iostat_event_group(struct evlist *evl,
	}

	evlist__for_each_entry(evl, evsel) {
		evsel->priv = list->rps[evsel->idx / metrics_count];
		evsel->priv = list->rps[evsel->core.idx / metrics_count];
	}
	list->nr_entries = 0;
err:
@@ -428,7 +428,7 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel,
{
	double iostat_value = 0;
	u64 prev_count_val = 0;
	const char *iostat_metric = iostat_metric_by_idx(evsel->idx);
	const char *iostat_metric = iostat_metric_by_idx(evsel->core.idx);
	u8 die = ((struct iio_root_port *)evsel->priv)->die;
	struct perf_counts_values *count = perf_counts(evsel->counts, die, 0);

+2 −2
Original line number Diff line number Diff line
@@ -1031,12 +1031,12 @@ static int process_base_stream(struct data__file *data_base,
			continue;

		es_base = evsel_streams__entry(data_base->evlist_streams,
					       evsel_base->idx);
					       evsel_base->core.idx);
		if (!es_base)
			return -1;

		es_pair = evsel_streams__entry(data_pair->evlist_streams,
					       evsel_pair->idx);
					       evsel_pair->core.idx);
		if (!es_pair)
			return -1;

Loading