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

libperf: Move 'nr_mmaps' from 'struct evlist' to 'struct perf_evlist'

Moving 'nr_mmaps' from 'struct evlist' to 'struct perf_evlist', it will
be used in following patches.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lore.kernel.org/lkml/20190913132355.21634-21-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 648b5af3
...@@ -648,7 +648,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, ...@@ -648,7 +648,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
if (priv_size != cs_etm_info_priv_size(itr, session->evlist)) if (priv_size != cs_etm_info_priv_size(itr, session->evlist))
return -EINVAL; return -EINVAL;
if (!session->evlist->nr_mmaps) if (!session->evlist->core.nr_mmaps)
return -EINVAL; return -EINVAL;
/* If the cpu_map is empty all online CPUs are involved */ /* If the cpu_map is empty all online CPUs are involved */
......
...@@ -51,7 +51,7 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, ...@@ -51,7 +51,7 @@ static int arm_spe_info_fill(struct auxtrace_record *itr,
if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE) if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE)
return -EINVAL; return -EINVAL;
if (!session->evlist->nr_mmaps) if (!session->evlist->core.nr_mmaps)
return -EINVAL; return -EINVAL;
auxtrace_info->type = PERF_AUXTRACE_ARM_SPE; auxtrace_info->type = PERF_AUXTRACE_ARM_SPE;
......
...@@ -115,7 +115,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe ...@@ -115,7 +115,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
evlist__disable(evlist); evlist__disable(evlist);
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
md = &evlist->mmap[i]; md = &evlist->mmap[i];
if (perf_mmap__read_init(md) < 0) if (perf_mmap__read_init(md) < 0)
continue; continue;
......
...@@ -75,7 +75,7 @@ static int intel_bts_info_fill(struct auxtrace_record *itr, ...@@ -75,7 +75,7 @@ static int intel_bts_info_fill(struct auxtrace_record *itr,
if (priv_size != INTEL_BTS_AUXTRACE_PRIV_SIZE) if (priv_size != INTEL_BTS_AUXTRACE_PRIV_SIZE)
return -EINVAL; return -EINVAL;
if (!session->evlist->nr_mmaps) if (!session->evlist->core.nr_mmaps)
return -EINVAL; return -EINVAL;
pc = session->evlist->mmap[0].core.base; pc = session->evlist->mmap[0].core.base;
......
...@@ -352,7 +352,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr, ...@@ -352,7 +352,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
filter = intel_pt_find_filter(session->evlist, ptr->intel_pt_pmu); filter = intel_pt_find_filter(session->evlist, ptr->intel_pt_pmu);
filter_str_len = filter ? strlen(filter) : 0; filter_str_len = filter ? strlen(filter) : 0;
if (!session->evlist->nr_mmaps) if (!session->evlist->core.nr_mmaps)
return -EINVAL; return -EINVAL;
pc = session->evlist->mmap[0].core.base; pc = session->evlist->mmap[0].core.base;
......
...@@ -802,7 +802,7 @@ static int perf_kvm__mmap_read(struct perf_kvm_stat *kvm) ...@@ -802,7 +802,7 @@ static int perf_kvm__mmap_read(struct perf_kvm_stat *kvm)
s64 n, ntotal = 0; s64 n, ntotal = 0;
u64 flush_time = ULLONG_MAX, mmap_time; u64 flush_time = ULLONG_MAX, mmap_time;
for (i = 0; i < kvm->evlist->nr_mmaps; i++) { for (i = 0; i < kvm->evlist->core.nr_mmaps; i++) {
n = perf_kvm__mmap_read_idx(kvm, i, &mmap_time); n = perf_kvm__mmap_read_idx(kvm, i, &mmap_time);
if (n < 0) if (n < 0)
return -1; return -1;
......
...@@ -357,7 +357,7 @@ static void record__aio_mmap_read_sync(struct record *rec) ...@@ -357,7 +357,7 @@ static void record__aio_mmap_read_sync(struct record *rec)
if (!record__aio_enabled(rec)) if (!record__aio_enabled(rec))
return; return;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
struct mmap *map = &maps[i]; struct mmap *map = &maps[i];
if (map->core.base) if (map->core.base)
...@@ -603,7 +603,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec) ...@@ -603,7 +603,7 @@ static int record__auxtrace_read_snapshot_all(struct record *rec)
int i; int i;
int rc = 0; int rc = 0;
for (i = 0; i < rec->evlist->nr_mmaps; i++) { for (i = 0; i < rec->evlist->core.nr_mmaps; i++) {
struct mmap *map = &rec->evlist->mmap[i]; struct mmap *map = &rec->evlist->mmap[i];
if (!map->auxtrace_mmap.base) if (!map->auxtrace_mmap.base)
...@@ -966,7 +966,7 @@ static int record__mmap_read_evlist(struct record *rec, struct evlist *evlist, ...@@ -966,7 +966,7 @@ static int record__mmap_read_evlist(struct record *rec, struct evlist *evlist,
if (record__aio_enabled(rec)) if (record__aio_enabled(rec))
off = record__aio_get_pos(trace_fd); off = record__aio_get_pos(trace_fd);
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
u64 flush = 0; u64 flush = 0;
struct mmap *map = &maps[i]; struct mmap *map = &maps[i];
......
...@@ -904,7 +904,7 @@ static void perf_top__mmap_read(struct perf_top *top) ...@@ -904,7 +904,7 @@ static void perf_top__mmap_read(struct perf_top *top)
if (overwrite) if (overwrite)
perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_DATA_PENDING); perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_DATA_PENDING);
for (i = 0; i < top->evlist->nr_mmaps; i++) for (i = 0; i < top->evlist->core.nr_mmaps; i++)
perf_top__mmap_read_idx(top, i); perf_top__mmap_read_idx(top, i);
if (overwrite) { if (overwrite) {
......
...@@ -3443,7 +3443,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -3443,7 +3443,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
again: again:
before = trace->nr_events; before = trace->nr_events;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
union perf_event *event; union perf_event *event;
struct mmap *md; struct mmap *md;
......
...@@ -13,6 +13,7 @@ struct perf_evlist { ...@@ -13,6 +13,7 @@ struct perf_evlist {
bool has_user_cpus; bool has_user_cpus;
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
struct perf_thread_map *threads; struct perf_thread_map *threads;
int nr_mmaps;
}; };
/** /**
......
...@@ -33,7 +33,7 @@ static int count_samples(struct evlist *evlist, int *sample_count, ...@@ -33,7 +33,7 @@ static int count_samples(struct evlist *evlist, int *sample_count,
{ {
int i; int i;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
struct mmap *map = &evlist->overwrite_mmap[i]; struct mmap *map = &evlist->overwrite_mmap[i];
union perf_event *event; union perf_event *event;
......
...@@ -179,7 +179,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void), ...@@ -179,7 +179,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
(*func)(); (*func)();
evlist__disable(evlist); evlist__disable(evlist);
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
union perf_event *event; union perf_event *event;
struct mmap *md; struct mmap *md;
......
...@@ -423,7 +423,7 @@ static int process_events(struct machine *machine, struct evlist *evlist, ...@@ -423,7 +423,7 @@ static int process_events(struct machine *machine, struct evlist *evlist,
struct mmap *md; struct mmap *md;
int i, ret; int i, ret;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
md = &evlist->mmap[i]; md = &evlist->mmap[i];
if (perf_mmap__read_init(md) < 0) if (perf_mmap__read_init(md) < 0)
continue; continue;
......
...@@ -36,7 +36,7 @@ static int find_comm(struct evlist *evlist, const char *comm) ...@@ -36,7 +36,7 @@ static int find_comm(struct evlist *evlist, const char *comm)
int i, found; int i, found;
found = 0; found = 0;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
md = &evlist->mmap[i]; md = &evlist->mmap[i];
if (perf_mmap__read_init(md) < 0) if (perf_mmap__read_init(md) < 0)
continue; continue;
......
...@@ -87,7 +87,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest ...@@ -87,7 +87,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
while (1) { while (1) {
int before = nr_events; int before = nr_events;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
union perf_event *event; union perf_event *event;
struct mmap *md; struct mmap *md;
......
...@@ -165,7 +165,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus ...@@ -165,7 +165,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
while (1) { while (1) {
int before = total_events; int before = total_events;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
union perf_event *event; union perf_event *event;
struct mmap *md; struct mmap *md;
......
...@@ -267,7 +267,7 @@ static int process_events(struct evlist *evlist, ...@@ -267,7 +267,7 @@ static int process_events(struct evlist *evlist,
struct mmap *md; struct mmap *md;
int i, ret; int i, ret;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
md = &evlist->mmap[i]; md = &evlist->mmap[i];
if (perf_mmap__read_init(md) < 0) if (perf_mmap__read_init(md) < 0)
continue; continue;
......
...@@ -651,7 +651,7 @@ static int perf_evlist__set_paused(struct evlist *evlist, bool value) ...@@ -651,7 +651,7 @@ static int perf_evlist__set_paused(struct evlist *evlist, bool value)
if (!evlist->overwrite_mmap) if (!evlist->overwrite_mmap)
return 0; return 0;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
int fd = evlist->overwrite_mmap[i].core.fd; int fd = evlist->overwrite_mmap[i].core.fd;
int err; int err;
...@@ -679,11 +679,11 @@ static void evlist__munmap_nofree(struct evlist *evlist) ...@@ -679,11 +679,11 @@ static void evlist__munmap_nofree(struct evlist *evlist)
int i; int i;
if (evlist->mmap) if (evlist->mmap)
for (i = 0; i < evlist->nr_mmaps; i++) for (i = 0; i < evlist->core.nr_mmaps; i++)
perf_mmap__munmap(&evlist->mmap[i]); perf_mmap__munmap(&evlist->mmap[i]);
if (evlist->overwrite_mmap) if (evlist->overwrite_mmap)
for (i = 0; i < evlist->nr_mmaps; i++) for (i = 0; i < evlist->core.nr_mmaps; i++)
perf_mmap__munmap(&evlist->overwrite_mmap[i]); perf_mmap__munmap(&evlist->overwrite_mmap[i]);
} }
...@@ -700,14 +700,14 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist, ...@@ -700,14 +700,14 @@ static struct mmap *evlist__alloc_mmap(struct evlist *evlist,
int i; int i;
struct mmap *map; struct mmap *map;
evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus); evlist->core.nr_mmaps = perf_cpu_map__nr(evlist->core.cpus);
if (perf_cpu_map__empty(evlist->core.cpus)) if (perf_cpu_map__empty(evlist->core.cpus))
evlist->nr_mmaps = perf_thread_map__nr(evlist->core.threads); evlist->core.nr_mmaps = perf_thread_map__nr(evlist->core.threads);
map = zalloc(evlist->nr_mmaps * sizeof(struct mmap)); map = zalloc(evlist->core.nr_mmaps * sizeof(struct mmap));
if (!map) if (!map)
return NULL; return NULL;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
map[i].core.fd = -1; map[i].core.fd = -1;
map[i].core.overwrite = overwrite; map[i].core.overwrite = overwrite;
/* /*
...@@ -1847,7 +1847,7 @@ static void *perf_evlist__poll_thread(void *arg) ...@@ -1847,7 +1847,7 @@ static void *perf_evlist__poll_thread(void *arg)
if (!draining) if (!draining)
perf_evlist__poll(evlist, 1000); perf_evlist__poll(evlist, 1000);
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
struct mmap *map = &evlist->mmap[i]; struct mmap *map = &evlist->mmap[i];
union perf_event *event; union perf_event *event;
......
...@@ -55,7 +55,6 @@ struct evlist { ...@@ -55,7 +55,6 @@ struct evlist {
struct perf_evlist core; struct perf_evlist core;
struct hlist_head heads[PERF_EVLIST__HLIST_SIZE]; struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
int nr_groups; int nr_groups;
int nr_mmaps;
bool enabled; bool enabled;
size_t mmap_len; size_t mmap_len;
int id_pos; int id_pos;
......
...@@ -988,7 +988,7 @@ static struct mmap *get_md(struct evlist *evlist, int cpu) ...@@ -988,7 +988,7 @@ static struct mmap *get_md(struct evlist *evlist, int cpu)
{ {
int i; int i;
for (i = 0; i < evlist->nr_mmaps; i++) { for (i = 0; i < evlist->core.nr_mmaps; i++) {
struct mmap *md = &evlist->mmap[i]; struct mmap *md = &evlist->mmap[i];
if (md->core.cpu == cpu) if (md->core.cpu == cpu)
......
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