diff options
Diffstat (limited to 'tools/perf/arch/arm/util/cs-etm.c')
-rw-r--r-- | tools/perf/arch/arm/util/cs-etm.c | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 4208974c24f8..c32db09baf0d 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -11,19 +11,22 @@ #include <linux/coresight-pmu.h> #include <linux/kernel.h> #include <linux/log2.h> +#include <linux/string.h> #include <linux/types.h> #include <linux/zalloc.h> #include "cs-etm.h" -#include "../../perf.h" +#include "../../util/debug.h" +#include "../../util/record.h" #include "../../util/auxtrace.h" #include "../../util/cpumap.h" +#include "../../util/event.h" #include "../../util/evlist.h" #include "../../util/evsel.h" #include "../../util/pmu.h" -#include "../../util/thread_map.h" #include "../../util/cs-etm.h" #include "../../util/util.h" +#include "../../util/session.h" #include <errno.h> #include <stdlib.h> @@ -32,7 +35,7 @@ struct cs_etm_recording { struct auxtrace_record itr; struct perf_pmu *cs_etm_pmu; - struct perf_evlist *evlist; + struct evlist *evlist; int wrapped_cnt; bool *wrapped; bool snapshot_mode; @@ -55,7 +58,7 @@ static const char *metadata_etmv4_ro[CS_ETMV4_PRIV_MAX] = { static bool cs_etm_is_etmv4(struct auxtrace_record *itr, int cpu); static int cs_etm_set_context_id(struct auxtrace_record *itr, - struct perf_evsel *evsel, int cpu) + struct evsel *evsel, int cpu) { struct cs_etm_recording *ptr; struct perf_pmu *cs_etm_pmu; @@ -95,7 +98,7 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr, } /* All good, let the kernel know */ - evsel->attr.config |= (1 << ETM_OPT_CTXTID); + evsel->core.attr.config |= (1 << ETM_OPT_CTXTID); err = 0; out: @@ -104,7 +107,7 @@ out: } static int cs_etm_set_timestamp(struct auxtrace_record *itr, - struct perf_evsel *evsel, int cpu) + struct evsel *evsel, int cpu) { struct cs_etm_recording *ptr; struct perf_pmu *cs_etm_pmu; @@ -144,7 +147,7 @@ static int cs_etm_set_timestamp(struct auxtrace_record *itr, } /* All good, let the kernel know */ - evsel->attr.config |= (1 << ETM_OPT_TS); + evsel->core.attr.config |= (1 << ETM_OPT_TS); err = 0; out: @@ -152,11 +155,11 @@ out: } static int cs_etm_set_option(struct auxtrace_record *itr, - struct perf_evsel *evsel, u32 option) + struct evsel *evsel, u32 option) { int i, err = -EINVAL; - struct cpu_map *event_cpus = evsel->evlist->cpus; - struct cpu_map *online_cpus = cpu_map__new(NULL); + struct perf_cpu_map *event_cpus = evsel->evlist->core.cpus; + struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); /* Set option of each CPU we have */ for (i = 0; i < cpu__max_cpu(); i++) { @@ -181,7 +184,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr, err = 0; out: - cpu_map__put(online_cpus); + perf_cpu_map__put(online_cpus); return err; } @@ -208,14 +211,14 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr, } static int cs_etm_set_sink_attr(struct perf_pmu *pmu, - struct perf_evsel *evsel) + struct evsel *evsel) { char msg[BUFSIZ], path[PATH_MAX], *sink; struct perf_evsel_config_term *term; int ret = -EINVAL; u32 hash; - if (evsel->attr.config2 & GENMASK(31, 0)) + if (evsel->core.attr.config2 & GENMASK(31, 0)) return 0; list_for_each_entry(term, &evsel->config_terms, list) { @@ -233,7 +236,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, return ret; } - evsel->attr.config2 |= hash; + evsel->core.attr.config2 |= hash; return 0; } @@ -245,16 +248,16 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu, } static int cs_etm_recording_options(struct auxtrace_record *itr, - struct perf_evlist *evlist, + struct evlist *evlist, struct record_opts *opts) { int ret; struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; - struct perf_evsel *evsel, *cs_etm_evsel = NULL; - struct cpu_map *cpus = evlist->cpus; - bool privileged = (geteuid() == 0 || perf_event_paranoid() < 0); + struct evsel *evsel, *cs_etm_evsel = NULL; + struct perf_cpu_map *cpus = evlist->core.cpus; + bool privileged = perf_event_paranoid_check(-1); int err = 0; ptr->evlist = evlist; @@ -264,14 +267,14 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, opts->record_switch_events = true; evlist__for_each_entry(evlist, evsel) { - if (evsel->attr.type == cs_etm_pmu->type) { + if (evsel->core.attr.type == cs_etm_pmu->type) { if (cs_etm_evsel) { pr_err("There may be only one %s event\n", CORESIGHT_ETM_PMU_NAME); return -EINVAL; } - evsel->attr.freq = 0; - evsel->attr.sample_period = 1; + evsel->core.attr.freq = 0; + evsel->core.attr.sample_period = 1; cs_etm_evsel = evsel; opts->full_auxtrace = true; } @@ -396,7 +399,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, * AUX event. We also need the contextID in order to be notified * when a context switch happened. */ - if (!cpu_map__empty(cpus)) { + if (!perf_cpu_map__empty(cpus)) { perf_evsel__set_sample_bit(cs_etm_evsel, CPU); err = cs_etm_set_option(itr, cs_etm_evsel, @@ -407,7 +410,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, /* Add dummy event to keep tracking */ if (opts->full_auxtrace) { - struct perf_evsel *tracking_evsel; + struct evsel *tracking_evsel; err = parse_events(evlist, "dummy:u", NULL); if (err) @@ -416,11 +419,11 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, tracking_evsel = perf_evlist__last(evlist); perf_evlist__set_tracking_event(evlist, tracking_evsel); - tracking_evsel->attr.freq = 0; - tracking_evsel->attr.sample_period = 1; + tracking_evsel->core.attr.freq = 0; + tracking_evsel->core.attr.sample_period = 1; /* In per-cpu case, always need the time of mmap events etc */ - if (!cpu_map__empty(cpus)) + if (!perf_cpu_map__empty(cpus)) perf_evsel__set_sample_bit(tracking_evsel, TIME); } @@ -434,11 +437,11 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr) struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; - struct perf_evlist *evlist = ptr->evlist; - struct perf_evsel *evsel; + struct evlist *evlist = ptr->evlist; + struct evsel *evsel; evlist__for_each_entry(evlist, evsel) { - if (evsel->attr.type == cs_etm_pmu->type) { + if (evsel->core.attr.type == cs_etm_pmu->type) { /* * Variable perf_event_attr::config is assigned to * ETMv3/PTM. The bit fields have been made to match @@ -447,7 +450,7 @@ static u64 cs_etm_get_config(struct auxtrace_record *itr) * drivers/hwtracing/coresight/coresight-perf.c for * details. */ - config = evsel->attr.config; + config = evsel->core.attr.config; break; } } @@ -485,15 +488,15 @@ static u64 cs_etmv4_get_config(struct auxtrace_record *itr) static size_t cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, - struct perf_evlist *evlist __maybe_unused) + struct evlist *evlist __maybe_unused) { int i; int etmv3 = 0, etmv4 = 0; - struct cpu_map *event_cpus = evlist->cpus; - struct cpu_map *online_cpus = cpu_map__new(NULL); + struct perf_cpu_map *event_cpus = evlist->core.cpus; + struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); /* cpu map is not empty, we have specific CPUs to work with */ - if (!cpu_map__empty(event_cpus)) { + if (!perf_cpu_map__empty(event_cpus)) { for (i = 0; i < cpu__max_cpu(); i++) { if (!cpu_map__has(event_cpus, i) || !cpu_map__has(online_cpus, i)) @@ -517,7 +520,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, } } - cpu_map__put(online_cpus); + perf_cpu_map__put(online_cpus); return (CS_ETM_HEADER_SIZE + (etmv4 * CS_ETMV4_PRIV_SIZE) + @@ -564,7 +567,7 @@ static int cs_etm_get_ro(struct perf_pmu *pmu, int cpu, const char *path) static void cs_etm_get_metadata(int cpu, u32 *offset, struct auxtrace_record *itr, - struct auxtrace_info_event *info) + struct perf_record_auxtrace_info *info) { u32 increment; u64 magic; @@ -629,15 +632,15 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, static int cs_etm_info_fill(struct auxtrace_record *itr, struct perf_session *session, - struct auxtrace_info_event *info, + struct perf_record_auxtrace_info *info, size_t priv_size) { int i; u32 offset; u64 nr_cpu, type; - struct cpu_map *cpu_map; - struct cpu_map *event_cpus = session->evlist->cpus; - struct cpu_map *online_cpus = cpu_map__new(NULL); + struct perf_cpu_map *cpu_map; + struct perf_cpu_map *event_cpus = session->evlist->core.cpus; + struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; @@ -649,11 +652,11 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, return -EINVAL; /* If the cpu_map is empty all online CPUs are involved */ - if (cpu_map__empty(event_cpus)) { + if (perf_cpu_map__empty(event_cpus)) { cpu_map = online_cpus; } else { /* Make sure all specified CPUs are online */ - for (i = 0; i < cpu_map__nr(event_cpus); i++) { + for (i = 0; i < perf_cpu_map__nr(event_cpus); i++) { if (cpu_map__has(event_cpus, i) && !cpu_map__has(online_cpus, i)) return -EINVAL; @@ -662,7 +665,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, cpu_map = event_cpus; } - nr_cpu = cpu_map__nr(cpu_map); + nr_cpu = perf_cpu_map__nr(cpu_map); /* Get PMU type as dynamically assigned by the core */ type = cs_etm_pmu->type; @@ -679,7 +682,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, if (cpu_map__has(cpu_map, i)) cs_etm_get_metadata(i, &offset, itr, info); - cpu_map__put(online_cpus); + perf_cpu_map__put(online_cpus); return 0; } @@ -817,11 +820,11 @@ static int cs_etm_snapshot_start(struct auxtrace_record *itr) { struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); - struct perf_evsel *evsel; + struct evsel *evsel; evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->attr.type == ptr->cs_etm_pmu->type) - return perf_evsel__disable(evsel); + if (evsel->core.attr.type == ptr->cs_etm_pmu->type) + return evsel__disable(evsel); } return -EINVAL; } @@ -830,11 +833,11 @@ static int cs_etm_snapshot_finish(struct auxtrace_record *itr) { struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); - struct perf_evsel *evsel; + struct evsel *evsel; evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->attr.type == ptr->cs_etm_pmu->type) - return perf_evsel__enable(evsel); + if (evsel->core.attr.type == ptr->cs_etm_pmu->type) + return evsel__enable(evsel); } return -EINVAL; } @@ -858,10 +861,10 @@ static int cs_etm_read_finish(struct auxtrace_record *itr, int idx) { struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); - struct perf_evsel *evsel; + struct evsel *evsel; evlist__for_each_entry(ptr->evlist, evsel) { - if (evsel->attr.type == ptr->cs_etm_pmu->type) + if (evsel->core.attr.type == ptr->cs_etm_pmu->type) return perf_evlist__enable_event_idx(ptr->evlist, evsel, idx); } |