Skip to content

Commit 1fc632c

Browse files
olsajiriacmel
authored andcommitted
libperf: Move perf_event_attr field from perf's evsel to libperf's perf_evsel
Move the perf_event_attr struct fron 'struct evsel' to 'struct perf_evsel'. Committer notes: Fixed up these: tools/perf/arch/arm/util/auxtrace.c tools/perf/arch/arm/util/cs-etm.c tools/perf/arch/arm64/util/arm-spe.c tools/perf/arch/s390/util/auxtrace.c tools/perf/util/cs-etm.c Also cc1: warnings being treated as errors tests/sample-parsing.c: In function 'do_test': tests/sample-parsing.c:162: error: missing initializer tests/sample-parsing.c:162: error: (near initialization for 'evsel.core.cpus') struct evsel evsel = { .needs_swap = false, - .core.attr = { - .sample_type = sample_type, - .read_format = read_format, + .core = { + . attr = { + .sample_type = sample_type, + .read_format = read_format, + }, [perfbuilder@a70e4eeb5549 /]$ gcc --version |& head -1 gcc (GCC) 4.4.7 Also we don't need to include perf_event.h in tools/perf/lib/include/perf/evsel.h, forward declaring 'struct perf_event_attr' is enough. And this even fixes the build in some systems where things are used somewhere down the include path from perf_event.h without defining __always_inline. 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-43-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 6484d2f commit 1fc632c

59 files changed

Lines changed: 864 additions & 857 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tools/perf/arch/arm/util/auxtrace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ struct auxtrace_record
7070

7171
evlist__for_each_entry(evlist, evsel) {
7272
if (cs_etm_pmu &&
73-
evsel->attr.type == cs_etm_pmu->type)
73+
evsel->core.attr.type == cs_etm_pmu->type)
7474
found_etm = true;
7575

7676
if (!nr_spes)
7777
continue;
7878

7979
for (i = 0; i < nr_spes; i++) {
80-
if (evsel->attr.type == arm_spe_pmus[i]->type) {
80+
if (evsel->core.attr.type == arm_spe_pmus[i]->type) {
8181
found_spe = true;
8282
break;
8383
}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr,
9595
}
9696

9797
/* All good, let the kernel know */
98-
evsel->attr.config |= (1 << ETM_OPT_CTXTID);
98+
evsel->core.attr.config |= (1 << ETM_OPT_CTXTID);
9999
err = 0;
100100

101101
out:
@@ -144,7 +144,7 @@ static int cs_etm_set_timestamp(struct auxtrace_record *itr,
144144
}
145145

146146
/* All good, let the kernel know */
147-
evsel->attr.config |= (1 << ETM_OPT_TS);
147+
evsel->core.attr.config |= (1 << ETM_OPT_TS);
148148
err = 0;
149149

150150
out:
@@ -215,7 +215,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
215215
int ret = -EINVAL;
216216
u32 hash;
217217

218-
if (evsel->attr.config2 & GENMASK(31, 0))
218+
if (evsel->core.attr.config2 & GENMASK(31, 0))
219219
return 0;
220220

221221
list_for_each_entry(term, &evsel->config_terms, list) {
@@ -233,7 +233,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
233233
return ret;
234234
}
235235

236-
evsel->attr.config2 |= hash;
236+
evsel->core.attr.config2 |= hash;
237237
return 0;
238238
}
239239

@@ -264,14 +264,14 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
264264
opts->record_switch_events = true;
265265

266266
evlist__for_each_entry(evlist, evsel) {
267-
if (evsel->attr.type == cs_etm_pmu->type) {
267+
if (evsel->core.attr.type == cs_etm_pmu->type) {
268268
if (cs_etm_evsel) {
269269
pr_err("There may be only one %s event\n",
270270
CORESIGHT_ETM_PMU_NAME);
271271
return -EINVAL;
272272
}
273-
evsel->attr.freq = 0;
274-
evsel->attr.sample_period = 1;
273+
evsel->core.attr.freq = 0;
274+
evsel->core.attr.sample_period = 1;
275275
cs_etm_evsel = evsel;
276276
opts->full_auxtrace = true;
277277
}
@@ -416,8 +416,8 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
416416
tracking_evsel = perf_evlist__last(evlist);
417417
perf_evlist__set_tracking_event(evlist, tracking_evsel);
418418

419-
tracking_evsel->attr.freq = 0;
420-
tracking_evsel->attr.sample_period = 1;
419+
tracking_evsel->core.attr.freq = 0;
420+
tracking_evsel->core.attr.sample_period = 1;
421421

422422
/* In per-cpu case, always need the time of mmap events etc */
423423
if (!cpu_map__empty(cpus))
@@ -438,7 +438,7 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr)
438438
struct evsel *evsel;
439439

440440
evlist__for_each_entry(evlist, evsel) {
441-
if (evsel->attr.type == cs_etm_pmu->type) {
441+
if (evsel->core.attr.type == cs_etm_pmu->type) {
442442
/*
443443
* Variable perf_event_attr::config is assigned to
444444
* ETMv3/PTM. The bit fields have been made to match
@@ -447,7 +447,7 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr)
447447
* drivers/hwtracing/coresight/coresight-perf.c for
448448
* details.
449449
*/
450-
config = evsel->attr.config;
450+
config = evsel->core.attr.config;
451451
break;
452452
}
453453
}
@@ -820,7 +820,7 @@ static int cs_etm_snapshot_start(struct auxtrace_record *itr)
820820
struct evsel *evsel;
821821

822822
evlist__for_each_entry(ptr->evlist, evsel) {
823-
if (evsel->attr.type == ptr->cs_etm_pmu->type)
823+
if (evsel->core.attr.type == ptr->cs_etm_pmu->type)
824824
return evsel__disable(evsel);
825825
}
826826
return -EINVAL;
@@ -833,7 +833,7 @@ static int cs_etm_snapshot_finish(struct auxtrace_record *itr)
833833
struct evsel *evsel;
834834

835835
evlist__for_each_entry(ptr->evlist, evsel) {
836-
if (evsel->attr.type == ptr->cs_etm_pmu->type)
836+
if (evsel->core.attr.type == ptr->cs_etm_pmu->type)
837837
return evsel__enable(evsel);
838838
}
839839
return -EINVAL;
@@ -861,7 +861,7 @@ static int cs_etm_read_finish(struct auxtrace_record *itr, int idx)
861861
struct evsel *evsel;
862862

863863
evlist__for_each_entry(ptr->evlist, evsel) {
864-
if (evsel->attr.type == ptr->cs_etm_pmu->type)
864+
if (evsel->core.attr.type == ptr->cs_etm_pmu->type)
865865
return perf_evlist__enable_event_idx(ptr->evlist,
866866
evsel, idx);
867867
}

‎tools/perf/arch/arm64/util/arm-spe.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
7373
sper->evlist = evlist;
7474

7575
evlist__for_each_entry(evlist, evsel) {
76-
if (evsel->attr.type == arm_spe_pmu->type) {
76+
if (evsel->core.attr.type == arm_spe_pmu->type) {
7777
if (arm_spe_evsel) {
7878
pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n");
7979
return -EINVAL;
8080
}
81-
evsel->attr.freq = 0;
82-
evsel->attr.sample_period = 1;
81+
evsel->core.attr.freq = 0;
82+
evsel->core.attr.sample_period = 1;
8383
arm_spe_evsel = evsel;
8484
opts->full_auxtrace = true;
8585
}
@@ -130,8 +130,8 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
130130
tracking_evsel = perf_evlist__last(evlist);
131131
perf_evlist__set_tracking_event(evlist, tracking_evsel);
132132

133-
tracking_evsel->attr.freq = 0;
134-
tracking_evsel->attr.sample_period = 1;
133+
tracking_evsel->core.attr.freq = 0;
134+
tracking_evsel->core.attr.sample_period = 1;
135135
perf_evsel__set_sample_bit(tracking_evsel, TIME);
136136
perf_evsel__set_sample_bit(tracking_evsel, CPU);
137137
perf_evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK);
@@ -163,7 +163,7 @@ static int arm_spe_read_finish(struct auxtrace_record *itr, int idx)
163163
struct evsel *evsel;
164164

165165
evlist__for_each_entry(sper->evlist, evsel) {
166-
if (evsel->attr.type == sper->arm_spe_pmu->type)
166+
if (evsel->core.attr.type == sper->arm_spe_pmu->type)
167167
return perf_evlist__enable_event_idx(sper->evlist,
168168
evsel, idx);
169169
}

‎tools/perf/arch/s390/util/auxtrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
9494
return NULL;
9595

9696
evlist__for_each_entry(evlist, pos) {
97-
if (pos->attr.config == PERF_EVENT_CPUM_SF_DIAG) {
97+
if (pos->core.attr.config == PERF_EVENT_CPUM_SF_DIAG) {
9898
diagnose = 1;
9999
break;
100100
}

‎tools/perf/arch/x86/tests/perf-time-to-tsc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
7979

8080
evsel = perf_evlist__first(evlist);
8181

82-
evsel->attr.comm = 1;
83-
evsel->attr.disabled = 1;
84-
evsel->attr.enable_on_exec = 0;
82+
evsel->core.attr.comm = 1;
83+
evsel->core.attr.disabled = 1;
84+
evsel->core.attr.enable_on_exec = 0;
8585

8686
CHECK__(evlist__open(evlist));
8787

‎tools/perf/arch/x86/util/auxtrace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
2929
intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME);
3030

3131
evlist__for_each_entry(evlist, evsel) {
32-
if (intel_pt_pmu && evsel->attr.type == intel_pt_pmu->type)
32+
if (intel_pt_pmu && evsel->core.attr.type == intel_pt_pmu->type)
3333
found_pt = true;
34-
if (intel_bts_pmu && evsel->attr.type == intel_bts_pmu->type)
34+
if (intel_bts_pmu && evsel->core.attr.type == intel_bts_pmu->type)
3535
found_bts = true;
3636
}
3737

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
113113
btsr->snapshot_mode = opts->auxtrace_snapshot_mode;
114114

115115
evlist__for_each_entry(evlist, evsel) {
116-
if (evsel->attr.type == intel_bts_pmu->type) {
116+
if (evsel->core.attr.type == intel_bts_pmu->type) {
117117
if (intel_bts_evsel) {
118118
pr_err("There may be only one " INTEL_BTS_PMU_NAME " event\n");
119119
return -EINVAL;
120120
}
121-
evsel->attr.freq = 0;
122-
evsel->attr.sample_period = 1;
121+
evsel->core.attr.freq = 0;
122+
evsel->core.attr.sample_period = 1;
123123
intel_bts_evsel = evsel;
124124
opts->full_auxtrace = true;
125125
}
@@ -231,8 +231,8 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
231231

232232
perf_evlist__set_tracking_event(evlist, tracking_evsel);
233233

234-
tracking_evsel->attr.freq = 0;
235-
tracking_evsel->attr.sample_period = 1;
234+
tracking_evsel->core.attr.freq = 0;
235+
tracking_evsel->core.attr.sample_period = 1;
236236
}
237237

238238
return 0;
@@ -316,7 +316,7 @@ static int intel_bts_snapshot_start(struct auxtrace_record *itr)
316316
struct evsel *evsel;
317317

318318
evlist__for_each_entry(btsr->evlist, evsel) {
319-
if (evsel->attr.type == btsr->intel_bts_pmu->type)
319+
if (evsel->core.attr.type == btsr->intel_bts_pmu->type)
320320
return evsel__disable(evsel);
321321
}
322322
return -EINVAL;
@@ -329,7 +329,7 @@ static int intel_bts_snapshot_finish(struct auxtrace_record *itr)
329329
struct evsel *evsel;
330330

331331
evlist__for_each_entry(btsr->evlist, evsel) {
332-
if (evsel->attr.type == btsr->intel_bts_pmu->type)
332+
if (evsel->core.attr.type == btsr->intel_bts_pmu->type)
333333
return evsel__enable(evsel);
334334
}
335335
return -EINVAL;
@@ -411,7 +411,7 @@ static int intel_bts_read_finish(struct auxtrace_record *itr, int idx)
411411
struct evsel *evsel;
412412

413413
evlist__for_each_entry(btsr->evlist, evsel) {
414-
if (evsel->attr.type == btsr->intel_bts_pmu->type)
414+
if (evsel->core.attr.type == btsr->intel_bts_pmu->type)
415415
return perf_evlist__enable_event_idx(btsr->evlist,
416416
evsel, idx);
417417
}

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ static int intel_pt_read_config(struct perf_pmu *intel_pt_pmu, const char *str,
122122
return -EINVAL;
123123

124124
evlist__for_each_entry(evlist, evsel) {
125-
if (evsel->attr.type == intel_pt_pmu->type) {
126-
*res = intel_pt_masked_bits(mask, evsel->attr.config);
125+
if (evsel->core.attr.type == intel_pt_pmu->type) {
126+
*res = intel_pt_masked_bits(mask, evsel->core.attr.config);
127127
return 0;
128128
}
129129
}
@@ -274,7 +274,7 @@ static const char *intel_pt_find_filter(struct evlist *evlist,
274274
struct evsel *evsel;
275275

276276
evlist__for_each_entry(evlist, evsel) {
277-
if (evsel->attr.type == intel_pt_pmu->type)
277+
if (evsel->core.attr.type == intel_pt_pmu->type)
278278
return evsel->filter;
279279
}
280280

@@ -526,26 +526,26 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
526526
* sets pt=0, which avoids senseless kernel errors.
527527
*/
528528
if (perf_pmu__scan_file(intel_pt_pmu, "format/pt", "%c", &c) == 1 &&
529-
!(evsel->attr.config & 1)) {
529+
!(evsel->core.attr.config & 1)) {
530530
pr_warning("pt=0 doesn't make sense, forcing pt=1\n");
531-
evsel->attr.config |= 1;
531+
evsel->core.attr.config |= 1;
532532
}
533533

534534
err = intel_pt_val_config_term(intel_pt_pmu, "caps/cycle_thresholds",
535535
"cyc_thresh", "caps/psb_cyc",
536-
evsel->attr.config);
536+
evsel->core.attr.config);
537537
if (err)
538538
return err;
539539

540540
err = intel_pt_val_config_term(intel_pt_pmu, "caps/mtc_periods",
541541
"mtc_period", "caps/mtc",
542-
evsel->attr.config);
542+
evsel->core.attr.config);
543543
if (err)
544544
return err;
545545

546546
return intel_pt_val_config_term(intel_pt_pmu, "caps/psb_periods",
547547
"psb_period", "caps/psb_cyc",
548-
evsel->attr.config);
548+
evsel->core.attr.config);
549549
}
550550

551551
static int intel_pt_recording_options(struct auxtrace_record *itr,
@@ -566,13 +566,13 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
566566
ptr->snapshot_mode = opts->auxtrace_snapshot_mode;
567567

568568
evlist__for_each_entry(evlist, evsel) {
569-
if (evsel->attr.type == intel_pt_pmu->type) {
569+
if (evsel->core.attr.type == intel_pt_pmu->type) {
570570
if (intel_pt_evsel) {
571571
pr_err("There may be only one " INTEL_PT_PMU_NAME " event\n");
572572
return -EINVAL;
573573
}
574-
evsel->attr.freq = 0;
575-
evsel->attr.sample_period = 1;
574+
evsel->core.attr.freq = 0;
575+
evsel->core.attr.sample_period = 1;
576576
intel_pt_evsel = evsel;
577577
opts->full_auxtrace = true;
578578
}
@@ -670,7 +670,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
670670

671671
intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit);
672672

673-
if (opts->full_auxtrace && (intel_pt_evsel->attr.config & tsc_bit))
673+
if (opts->full_auxtrace && (intel_pt_evsel->core.attr.config & tsc_bit))
674674
have_timing_info = true;
675675
else
676676
have_timing_info = false;
@@ -693,9 +693,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
693693

694694
switch_evsel = perf_evlist__last(evlist);
695695

696-
switch_evsel->attr.freq = 0;
697-
switch_evsel->attr.sample_period = 1;
698-
switch_evsel->attr.context_switch = 1;
696+
switch_evsel->core.attr.freq = 0;
697+
switch_evsel->core.attr.sample_period = 1;
698+
switch_evsel->core.attr.context_switch = 1;
699699

700700
switch_evsel->system_wide = true;
701701
switch_evsel->no_aux_samples = true;
@@ -753,8 +753,8 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
753753

754754
perf_evlist__set_tracking_event(evlist, tracking_evsel);
755755

756-
tracking_evsel->attr.freq = 0;
757-
tracking_evsel->attr.sample_period = 1;
756+
tracking_evsel->core.attr.freq = 0;
757+
tracking_evsel->core.attr.sample_period = 1;
758758

759759
tracking_evsel->no_aux_samples = true;
760760
if (need_immediate)
@@ -787,7 +787,7 @@ static int intel_pt_snapshot_start(struct auxtrace_record *itr)
787787
struct evsel *evsel;
788788

789789
evlist__for_each_entry(ptr->evlist, evsel) {
790-
if (evsel->attr.type == ptr->intel_pt_pmu->type)
790+
if (evsel->core.attr.type == ptr->intel_pt_pmu->type)
791791
return evsel__disable(evsel);
792792
}
793793
return -EINVAL;
@@ -800,7 +800,7 @@ static int intel_pt_snapshot_finish(struct auxtrace_record *itr)
800800
struct evsel *evsel;
801801

802802
evlist__for_each_entry(ptr->evlist, evsel) {
803-
if (evsel->attr.type == ptr->intel_pt_pmu->type)
803+
if (evsel->core.attr.type == ptr->intel_pt_pmu->type)
804804
return evsel__enable(evsel);
805805
}
806806
return -EINVAL;
@@ -1073,7 +1073,7 @@ static int intel_pt_read_finish(struct auxtrace_record *itr, int idx)
10731073
struct evsel *evsel;
10741074

10751075
evlist__for_each_entry(ptr->evlist, evsel) {
1076-
if (evsel->attr.type == ptr->intel_pt_pmu->type)
1076+
if (evsel->core.attr.type == ptr->intel_pt_pmu->type)
10771077
return perf_evlist__enable_event_idx(ptr->evlist, evsel,
10781078
idx);
10791079
}

‎tools/perf/builtin-evlist.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
3636
evlist__for_each_entry(session->evlist, pos) {
3737
perf_evsel__fprintf(pos, details, stdout);
3838

39-
if (pos->attr.type == PERF_TYPE_TRACEPOINT)
39+
if (pos->core.attr.type == PERF_TYPE_TRACEPOINT)
4040
has_tracepoint = true;
4141
}
4242

0 commit comments

Comments
 (0)