| .. | .. |
|---|
| 8 | 8 | #include <linux/types.h> |
|---|
| 9 | 9 | #include <linux/bitops.h> |
|---|
| 10 | 10 | #include <linux/log2.h> |
|---|
| 11 | +#include <linux/zalloc.h> |
|---|
| 11 | 12 | #include <time.h> |
|---|
| 12 | 13 | |
|---|
| 13 | | -#include "../../util/cpumap.h" |
|---|
| 14 | | -#include "../../util/evsel.h" |
|---|
| 15 | | -#include "../../util/evlist.h" |
|---|
| 16 | | -#include "../../util/session.h" |
|---|
| 17 | | -#include "../../util/util.h" |
|---|
| 18 | | -#include "../../util/pmu.h" |
|---|
| 19 | | -#include "../../util/debug.h" |
|---|
| 20 | | -#include "../../util/auxtrace.h" |
|---|
| 21 | | -#include "../../util/arm-spe.h" |
|---|
| 14 | +#include "../../../util/cpumap.h" |
|---|
| 15 | +#include "../../../util/event.h" |
|---|
| 16 | +#include "../../../util/evsel.h" |
|---|
| 17 | +#include "../../../util/evlist.h" |
|---|
| 18 | +#include "../../../util/session.h" |
|---|
| 19 | +#include <internal/lib.h> // page_size |
|---|
| 20 | +#include "../../../util/pmu.h" |
|---|
| 21 | +#include "../../../util/debug.h" |
|---|
| 22 | +#include "../../../util/auxtrace.h" |
|---|
| 23 | +#include "../../../util/record.h" |
|---|
| 24 | +#include "../../../util/arm-spe.h" |
|---|
| 22 | 25 | |
|---|
| 23 | 26 | #define KiB(x) ((x) * 1024) |
|---|
| 24 | 27 | #define MiB(x) ((x) * 1024 * 1024) |
|---|
| .. | .. |
|---|
| 26 | 29 | struct arm_spe_recording { |
|---|
| 27 | 30 | struct auxtrace_record itr; |
|---|
| 28 | 31 | struct perf_pmu *arm_spe_pmu; |
|---|
| 29 | | - struct perf_evlist *evlist; |
|---|
| 32 | + struct evlist *evlist; |
|---|
| 30 | 33 | }; |
|---|
| 31 | 34 | |
|---|
| 32 | 35 | static size_t |
|---|
| 33 | 36 | arm_spe_info_priv_size(struct auxtrace_record *itr __maybe_unused, |
|---|
| 34 | | - struct perf_evlist *evlist __maybe_unused) |
|---|
| 37 | + struct evlist *evlist __maybe_unused) |
|---|
| 35 | 38 | { |
|---|
| 36 | 39 | return ARM_SPE_AUXTRACE_PRIV_SIZE; |
|---|
| 37 | 40 | } |
|---|
| 38 | 41 | |
|---|
| 39 | 42 | static int arm_spe_info_fill(struct auxtrace_record *itr, |
|---|
| 40 | 43 | struct perf_session *session, |
|---|
| 41 | | - struct auxtrace_info_event *auxtrace_info, |
|---|
| 44 | + struct perf_record_auxtrace_info *auxtrace_info, |
|---|
| 42 | 45 | size_t priv_size) |
|---|
| 43 | 46 | { |
|---|
| 44 | 47 | struct arm_spe_recording *sper = |
|---|
| .. | .. |
|---|
| 48 | 51 | if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE) |
|---|
| 49 | 52 | return -EINVAL; |
|---|
| 50 | 53 | |
|---|
| 51 | | - if (!session->evlist->nr_mmaps) |
|---|
| 54 | + if (!session->evlist->core.nr_mmaps) |
|---|
| 52 | 55 | return -EINVAL; |
|---|
| 53 | 56 | |
|---|
| 54 | 57 | auxtrace_info->type = PERF_AUXTRACE_ARM_SPE; |
|---|
| .. | .. |
|---|
| 58 | 61 | } |
|---|
| 59 | 62 | |
|---|
| 60 | 63 | static int arm_spe_recording_options(struct auxtrace_record *itr, |
|---|
| 61 | | - struct perf_evlist *evlist, |
|---|
| 64 | + struct evlist *evlist, |
|---|
| 62 | 65 | struct record_opts *opts) |
|---|
| 63 | 66 | { |
|---|
| 64 | 67 | struct arm_spe_recording *sper = |
|---|
| 65 | 68 | container_of(itr, struct arm_spe_recording, itr); |
|---|
| 66 | 69 | struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; |
|---|
| 67 | | - struct perf_evsel *evsel, *arm_spe_evsel = NULL; |
|---|
| 68 | | - bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; |
|---|
| 69 | | - struct perf_evsel *tracking_evsel; |
|---|
| 70 | + struct evsel *evsel, *arm_spe_evsel = NULL; |
|---|
| 71 | + bool privileged = perf_event_paranoid_check(-1); |
|---|
| 72 | + struct evsel *tracking_evsel; |
|---|
| 70 | 73 | int err; |
|---|
| 71 | 74 | |
|---|
| 72 | 75 | sper->evlist = evlist; |
|---|
| 73 | 76 | |
|---|
| 74 | 77 | evlist__for_each_entry(evlist, evsel) { |
|---|
| 75 | | - if (evsel->attr.type == arm_spe_pmu->type) { |
|---|
| 78 | + if (evsel->core.attr.type == arm_spe_pmu->type) { |
|---|
| 76 | 79 | if (arm_spe_evsel) { |
|---|
| 77 | 80 | pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n"); |
|---|
| 78 | 81 | return -EINVAL; |
|---|
| 79 | 82 | } |
|---|
| 80 | | - evsel->attr.freq = 0; |
|---|
| 81 | | - evsel->attr.sample_period = 1; |
|---|
| 83 | + evsel->core.attr.freq = 0; |
|---|
| 84 | + evsel->core.attr.sample_period = 1; |
|---|
| 82 | 85 | arm_spe_evsel = evsel; |
|---|
| 83 | 86 | opts->full_auxtrace = true; |
|---|
| 84 | 87 | } |
|---|
| .. | .. |
|---|
| 117 | 120 | */ |
|---|
| 118 | 121 | perf_evlist__to_front(evlist, arm_spe_evsel); |
|---|
| 119 | 122 | |
|---|
| 120 | | - perf_evsel__set_sample_bit(arm_spe_evsel, CPU); |
|---|
| 121 | | - perf_evsel__set_sample_bit(arm_spe_evsel, TIME); |
|---|
| 122 | | - perf_evsel__set_sample_bit(arm_spe_evsel, TID); |
|---|
| 123 | + evsel__set_sample_bit(arm_spe_evsel, CPU); |
|---|
| 124 | + evsel__set_sample_bit(arm_spe_evsel, TIME); |
|---|
| 125 | + evsel__set_sample_bit(arm_spe_evsel, TID); |
|---|
| 126 | + |
|---|
| 127 | + /* |
|---|
| 128 | + * Set this only so that perf report knows that SPE generates memory info. It has no effect |
|---|
| 129 | + * on the opening of the event or the SPE data produced. |
|---|
| 130 | + */ |
|---|
| 131 | + evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); |
|---|
| 123 | 132 | |
|---|
| 124 | 133 | /* Add dummy event to keep tracking */ |
|---|
| 125 | 134 | err = parse_events(evlist, "dummy:u", NULL); |
|---|
| 126 | 135 | if (err) |
|---|
| 127 | 136 | return err; |
|---|
| 128 | 137 | |
|---|
| 129 | | - tracking_evsel = perf_evlist__last(evlist); |
|---|
| 138 | + tracking_evsel = evlist__last(evlist); |
|---|
| 130 | 139 | perf_evlist__set_tracking_event(evlist, tracking_evsel); |
|---|
| 131 | 140 | |
|---|
| 132 | | - tracking_evsel->attr.freq = 0; |
|---|
| 133 | | - tracking_evsel->attr.sample_period = 1; |
|---|
| 134 | | - perf_evsel__set_sample_bit(tracking_evsel, TIME); |
|---|
| 135 | | - perf_evsel__set_sample_bit(tracking_evsel, CPU); |
|---|
| 136 | | - perf_evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK); |
|---|
| 141 | + tracking_evsel->core.attr.freq = 0; |
|---|
| 142 | + tracking_evsel->core.attr.sample_period = 1; |
|---|
| 143 | + evsel__set_sample_bit(tracking_evsel, TIME); |
|---|
| 144 | + evsel__set_sample_bit(tracking_evsel, CPU); |
|---|
| 145 | + evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK); |
|---|
| 137 | 146 | |
|---|
| 138 | 147 | return 0; |
|---|
| 139 | 148 | } |
|---|
| .. | .. |
|---|
| 155 | 164 | free(sper); |
|---|
| 156 | 165 | } |
|---|
| 157 | 166 | |
|---|
| 158 | | -static int arm_spe_read_finish(struct auxtrace_record *itr, int idx) |
|---|
| 159 | | -{ |
|---|
| 160 | | - struct arm_spe_recording *sper = |
|---|
| 161 | | - container_of(itr, struct arm_spe_recording, itr); |
|---|
| 162 | | - struct perf_evsel *evsel; |
|---|
| 163 | | - |
|---|
| 164 | | - evlist__for_each_entry(sper->evlist, evsel) { |
|---|
| 165 | | - if (evsel->attr.type == sper->arm_spe_pmu->type) |
|---|
| 166 | | - return perf_evlist__enable_event_idx(sper->evlist, |
|---|
| 167 | | - evsel, idx); |
|---|
| 168 | | - } |
|---|
| 169 | | - return -EINVAL; |
|---|
| 170 | | -} |
|---|
| 171 | | - |
|---|
| 172 | 167 | struct auxtrace_record *arm_spe_recording_init(int *err, |
|---|
| 173 | 168 | struct perf_pmu *arm_spe_pmu) |
|---|
| 174 | 169 | { |
|---|
| .. | .. |
|---|
| 186 | 181 | } |
|---|
| 187 | 182 | |
|---|
| 188 | 183 | sper->arm_spe_pmu = arm_spe_pmu; |
|---|
| 184 | + sper->itr.pmu = arm_spe_pmu; |
|---|
| 189 | 185 | sper->itr.recording_options = arm_spe_recording_options; |
|---|
| 190 | 186 | sper->itr.info_priv_size = arm_spe_info_priv_size; |
|---|
| 191 | 187 | sper->itr.info_fill = arm_spe_info_fill; |
|---|
| 192 | 188 | sper->itr.free = arm_spe_recording_free; |
|---|
| 193 | 189 | sper->itr.reference = arm_spe_reference; |
|---|
| 194 | | - sper->itr.read_finish = arm_spe_read_finish; |
|---|
| 190 | + sper->itr.read_finish = auxtrace_record__read_finish; |
|---|
| 195 | 191 | sper->itr.alignment = 0; |
|---|
| 196 | 192 | |
|---|
| 197 | 193 | *err = 0; |
|---|