Skip to content

Commit f72f901

Browse files
olsajiriacmel
authored andcommitted
libperf: Add cpus to struct perf_evlist
Move cpus from tools/perf's evlist to libperf's perf_evlist struct. Committer notes: Fixed up this one: tools/perf/arch/arm/util/cs-etm.c Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20190721112506.12306-55-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ec903f2 commit f72f901

15 files changed

Lines changed: 53 additions & 51 deletions

File tree

‎tools/perf/arch/arm/util/cs-etm.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr,
155155
struct evsel *evsel, u32 option)
156156
{
157157
int i, err = -EINVAL;
158-
struct perf_cpu_map *event_cpus = evsel->evlist->cpus;
158+
struct perf_cpu_map *event_cpus = evsel->evlist->core.cpus;
159159
struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL);
160160

161161
/* Set option of each CPU we have */
@@ -253,7 +253,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
253253
container_of(itr, struct cs_etm_recording, itr);
254254
struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
255255
struct evsel *evsel, *cs_etm_evsel = NULL;
256-
struct perf_cpu_map *cpus = evlist->cpus;
256+
struct perf_cpu_map *cpus = evlist->core.cpus;
257257
bool privileged = (geteuid() == 0 || perf_event_paranoid() < 0);
258258
int err = 0;
259259

@@ -489,7 +489,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused,
489489
{
490490
int i;
491491
int etmv3 = 0, etmv4 = 0;
492-
struct perf_cpu_map *event_cpus = evlist->cpus;
492+
struct perf_cpu_map *event_cpus = evlist->core.cpus;
493493
struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL);
494494

495495
/* cpu map is not empty, we have specific CPUs to work with */
@@ -636,7 +636,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
636636
u32 offset;
637637
u64 nr_cpu, type;
638638
struct perf_cpu_map *cpu_map;
639-
struct perf_cpu_map *event_cpus = session->evlist->cpus;
639+
struct perf_cpu_map *event_cpus = session->evlist->core.cpus;
640640
struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL);
641641
struct cs_etm_recording *ptr =
642642
container_of(itr, struct cs_etm_recording, itr);

‎tools/perf/arch/x86/util/intel-bts.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
106106
container_of(itr, struct intel_bts_recording, itr);
107107
struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu;
108108
struct evsel *evsel, *intel_bts_evsel = NULL;
109-
const struct perf_cpu_map *cpus = evlist->cpus;
109+
const struct perf_cpu_map *cpus = evlist->core.cpus;
110110
bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
111111

112112
btsr->evlist = evlist;

‎tools/perf/arch/x86/util/intel-pt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
365365
ui__warning("Intel Processor Trace: TSC not available\n");
366366
}
367367

368-
per_cpu_mmaps = !cpu_map__empty(session->evlist->cpus);
368+
per_cpu_mmaps = !cpu_map__empty(session->evlist->core.cpus);
369369

370370
auxtrace_info->type = PERF_AUXTRACE_INTEL_PT;
371371
auxtrace_info->priv[INTEL_PT_PMU_TYPE] = intel_pt_pmu->type;
@@ -557,7 +557,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
557557
struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
558558
bool have_timing_info, need_immediate = false;
559559
struct evsel *evsel, *intel_pt_evsel = NULL;
560-
const struct perf_cpu_map *cpus = evlist->cpus;
560+
const struct perf_cpu_map *cpus = evlist->core.cpus;
561561
bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
562562
u64 tsc_bit;
563563
int err;

‎tools/perf/builtin-ftrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static int set_tracing_cpumask(struct perf_cpu_map *cpumap)
192192

193193
static int set_tracing_cpu(struct perf_ftrace *ftrace)
194194
{
195-
struct perf_cpu_map *cpumap = ftrace->evlist->cpus;
195+
struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus;
196196

197197
if (!target__has_cpu(&ftrace->target))
198198
return 0;

‎tools/perf/builtin-record.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static int record__synthesize(struct record *rec, bool tail)
12831283
return err;
12841284
}
12851285

1286-
err = perf_event__synthesize_cpu_map(&rec->tool, rec->evlist->cpus,
1286+
err = perf_event__synthesize_cpu_map(&rec->tool, rec->evlist->core.cpus,
12871287
process_synthesized_event, NULL);
12881288
if (err < 0) {
12891289
pr_err("Couldn't synthesize cpu map.\n");

‎tools/perf/builtin-stat.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -884,29 +884,29 @@ static int perf_stat_init_aggr_mode(void)
884884

885885
switch (stat_config.aggr_mode) {
886886
case AGGR_SOCKET:
887-
if (cpu_map__build_socket_map(evsel_list->cpus, &stat_config.aggr_map)) {
887+
if (cpu_map__build_socket_map(evsel_list->core.cpus, &stat_config.aggr_map)) {
888888
perror("cannot build socket map");
889889
return -1;
890890
}
891891
stat_config.aggr_get_id = perf_stat__get_socket_cached;
892892
break;
893893
case AGGR_DIE:
894-
if (cpu_map__build_die_map(evsel_list->cpus, &stat_config.aggr_map)) {
894+
if (cpu_map__build_die_map(evsel_list->core.cpus, &stat_config.aggr_map)) {
895895
perror("cannot build die map");
896896
return -1;
897897
}
898898
stat_config.aggr_get_id = perf_stat__get_die_cached;
899899
break;
900900
case AGGR_CORE:
901-
if (cpu_map__build_core_map(evsel_list->cpus, &stat_config.aggr_map)) {
901+
if (cpu_map__build_core_map(evsel_list->core.cpus, &stat_config.aggr_map)) {
902902
perror("cannot build core map");
903903
return -1;
904904
}
905905
stat_config.aggr_get_id = perf_stat__get_core_cached;
906906
break;
907907
case AGGR_NONE:
908908
if (term_percore_set()) {
909-
if (cpu_map__build_core_map(evsel_list->cpus,
909+
if (cpu_map__build_core_map(evsel_list->core.cpus,
910910
&stat_config.aggr_map)) {
911911
perror("cannot build core map");
912912
return -1;
@@ -926,7 +926,7 @@ static int perf_stat_init_aggr_mode(void)
926926
* taking the highest cpu number to be the size of
927927
* the aggregation translate cpumap.
928928
*/
929-
nr = cpu_map__get_max(evsel_list->cpus);
929+
nr = cpu_map__get_max(evsel_list->core.cpus);
930930
stat_config.cpus_aggr_map = cpu_map__empty_new(nr + 1);
931931
return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
932932
}
@@ -1057,21 +1057,21 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)
10571057

10581058
switch (stat_config.aggr_mode) {
10591059
case AGGR_SOCKET:
1060-
if (perf_env__build_socket_map(env, evsel_list->cpus, &stat_config.aggr_map)) {
1060+
if (perf_env__build_socket_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) {
10611061
perror("cannot build socket map");
10621062
return -1;
10631063
}
10641064
stat_config.aggr_get_id = perf_stat__get_socket_file;
10651065
break;
10661066
case AGGR_DIE:
1067-
if (perf_env__build_die_map(env, evsel_list->cpus, &stat_config.aggr_map)) {
1067+
if (perf_env__build_die_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) {
10681068
perror("cannot build die map");
10691069
return -1;
10701070
}
10711071
stat_config.aggr_get_id = perf_stat__get_die_file;
10721072
break;
10731073
case AGGR_CORE:
1074-
if (perf_env__build_core_map(env, evsel_list->cpus, &stat_config.aggr_map)) {
1074+
if (perf_env__build_core_map(env, evsel_list->core.cpus, &stat_config.aggr_map)) {
10751075
perror("cannot build core map");
10761076
return -1;
10771077
}

‎tools/perf/builtin-top.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ static int perf_top__start_counters(struct perf_top *top)
989989

990990
evlist__for_each_entry(evlist, counter) {
991991
try_again:
992-
if (evsel__open(counter, top->evlist->cpus,
992+
if (evsel__open(counter, top->evlist->core.cpus,
993993
top->evlist->threads) < 0) {
994994

995995
/*

‎tools/perf/lib/include/internal/evlist.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
#ifndef __LIBPERF_INTERNAL_EVLIST_H
33
#define __LIBPERF_INTERNAL_EVLIST_H
44

5+
struct perf_cpu_map;
6+
57
struct perf_evlist {
6-
struct list_head entries;
7-
int nr_entries;
8-
bool has_user_cpus;
8+
struct list_head entries;
9+
int nr_entries;
10+
bool has_user_cpus;
11+
struct perf_cpu_map *cpus;
912
};
1013

1114
#endif /* __LIBPERF_INTERNAL_EVLIST_H */

‎tools/perf/util/auxtrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
130130
mp->idx = idx;
131131

132132
if (per_cpu) {
133-
mp->cpu = evlist->cpus->map[idx];
133+
mp->cpu = evlist->core.cpus->map[idx];
134134
if (evlist->threads)
135135
mp->tid = thread_map__pid(evlist->threads, 0);
136136
else

‎tools/perf/util/evlist.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ void evlist__delete(struct evlist *evlist)
143143

144144
perf_evlist__munmap(evlist);
145145
evlist__close(evlist);
146-
perf_cpu_map__put(evlist->cpus);
146+
perf_cpu_map__put(evlist->core.cpus);
147147
perf_thread_map__put(evlist->threads);
148-
evlist->cpus = NULL;
148+
evlist->core.cpus = NULL;
149149
evlist->threads = NULL;
150150
perf_evlist__purge(evlist);
151151
perf_evlist__exit(evlist);
@@ -161,7 +161,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
161161
*/
162162
if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {
163163
perf_cpu_map__put(evsel->core.cpus);
164-
evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
164+
evsel->core.cpus = perf_cpu_map__get(evlist->core.cpus);
165165
} else if (evsel->core.cpus != evsel->core.own_cpus) {
166166
perf_cpu_map__put(evsel->core.cpus);
167167
evsel->core.cpus = perf_cpu_map__get(evsel->core.own_cpus);
@@ -398,7 +398,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
398398
int thread)
399399
{
400400
int cpu;
401-
int nr_cpus = cpu_map__nr(evlist->cpus);
401+
int nr_cpus = cpu_map__nr(evlist->core.cpus);
402402

403403
if (!evsel->fd)
404404
return -EINVAL;
@@ -414,7 +414,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
414414
int perf_evlist__enable_event_idx(struct evlist *evlist,
415415
struct evsel *evsel, int idx)
416416
{
417-
bool per_cpu_mmaps = !cpu_map__empty(evlist->cpus);
417+
bool per_cpu_mmaps = !cpu_map__empty(evlist->core.cpus);
418418

419419
if (per_cpu_mmaps)
420420
return perf_evlist__enable_event_cpu(evlist, evsel, idx);
@@ -424,7 +424,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,
424424

425425
int perf_evlist__alloc_pollfd(struct evlist *evlist)
426426
{
427-
int nr_cpus = cpu_map__nr(evlist->cpus);
427+
int nr_cpus = cpu_map__nr(evlist->core.cpus);
428428
int nr_threads = thread_map__nr(evlist->threads);
429429
int nfds = 0;
430430
struct evsel *evsel;
@@ -552,8 +552,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist,
552552
{
553553
struct perf_sample_id *sid = SID(evsel, cpu, thread);
554554
sid->idx = idx;
555-
if (evlist->cpus && cpu >= 0)
556-
sid->cpu = evlist->cpus->map[cpu];
555+
if (evlist->core.cpus && cpu >= 0)
556+
sid->cpu = evlist->core.cpus->map[cpu];
557557
else
558558
sid->cpu = -1;
559559
if (!evsel->system_wide && evlist->threads && thread >= 0)
@@ -720,8 +720,8 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,
720720
int i;
721721
struct perf_mmap *map;
722722

723-
evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
724-
if (cpu_map__empty(evlist->cpus))
723+
evlist->nr_mmaps = cpu_map__nr(evlist->core.cpus);
724+
if (cpu_map__empty(evlist->core.cpus))
725725
evlist->nr_mmaps = thread_map__nr(evlist->threads);
726726
map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
727727
if (!map)
@@ -759,7 +759,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,
759759
{
760760
struct evsel *evsel;
761761
int revent;
762-
int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx);
762+
int evlist_cpu = cpu_map__cpu(evlist->core.cpus, cpu_idx);
763763

764764
evlist__for_each_entry(evlist, evsel) {
765765
struct perf_mmap *maps = evlist->mmap;
@@ -835,7 +835,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist,
835835
struct mmap_params *mp)
836836
{
837837
int cpu, thread;
838-
int nr_cpus = cpu_map__nr(evlist->cpus);
838+
int nr_cpus = cpu_map__nr(evlist->core.cpus);
839839
int nr_threads = thread_map__nr(evlist->threads);
840840

841841
pr_debug2("perf event ring buffer mmapped per cpu\n");
@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
10141014
int comp_level)
10151015
{
10161016
struct evsel *evsel;
1017-
const struct perf_cpu_map *cpus = evlist->cpus;
1017+
const struct perf_cpu_map *cpus = evlist->core.cpus;
10181018
const struct perf_thread_map *threads = evlist->threads;
10191019
/*
10201020
* Delay setting mp.prot: set it before calling perf_mmap__mmap.
@@ -1116,9 +1116,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus,
11161116
* original reference count of 1. If that is not the case it is up to
11171117
* the caller to increase the reference count.
11181118
*/
1119-
if (cpus != evlist->cpus) {
1120-
perf_cpu_map__put(evlist->cpus);
1121-
evlist->cpus = perf_cpu_map__get(cpus);
1119+
if (cpus != evlist->core.cpus) {
1120+
perf_cpu_map__put(evlist->core.cpus);
1121+
evlist->core.cpus = perf_cpu_map__get(cpus);
11221122
}
11231123

11241124
if (threads != evlist->threads) {
@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)
13981398
* Default: one fd per CPU, all threads, aka systemwide
13991399
* as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL
14001400
*/
1401-
if (evlist->threads == NULL && evlist->cpus == NULL) {
1401+
if (evlist->threads == NULL && evlist->core.cpus == NULL) {
14021402
err = perf_evlist__create_syswide_maps(evlist);
14031403
if (err < 0)
14041404
goto out_err;
@@ -1920,7 +1920,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist,
19201920
goto out_delete_evlist;
19211921

19221922
evlist__for_each_entry(evlist, counter) {
1923-
if (evsel__open(counter, evlist->cpus,
1923+
if (evsel__open(counter, evlist->core.cpus,
19241924
evlist->threads) < 0)
19251925
goto out_delete_evlist;
19261926
}

0 commit comments

Comments
 (0)