Commit 7bfc1544 authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo

perf cs-etm: Allow user to override timestamp and contextid settings

Timestamps and context tracking are automatically enabled in per-core
mode and it's impossible to override this. Use the new utility function
to set them conditionally.
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Denis Nikitin <denik@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yang Shi <shy828301@gmail.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230424134748.228137-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 35c51f83
...@@ -324,8 +324,6 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, ...@@ -324,8 +324,6 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
perf_can_record_switch_events()) perf_can_record_switch_events())
opts->record_switch_events = true; opts->record_switch_events = true;
cs_etm_evsel->core.attr.freq = 0;
cs_etm_evsel->core.attr.sample_period = 1;
cs_etm_evsel->needs_auxtrace_mmap = true; cs_etm_evsel->needs_auxtrace_mmap = true;
opts->full_auxtrace = true; opts->full_auxtrace = true;
...@@ -430,10 +428,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, ...@@ -430,10 +428,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
* when a context switch happened. * when a context switch happened.
*/ */
if (!perf_cpu_map__empty(cpus)) { if (!perf_cpu_map__empty(cpus)) {
cs_etm_evsel->core.attr.config |= evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel,
perf_pmu__format_bits(&cs_etm_pmu->format, "timestamp"); "timestamp", 1);
cs_etm_evsel->core.attr.config |= evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel,
perf_pmu__format_bits(&cs_etm_pmu->format, "contextid"); "contextid", 1);
} }
/* Add dummy event to keep tracking */ /* Add dummy event to keep tracking */
...@@ -914,3 +912,22 @@ struct auxtrace_record *cs_etm_record_init(int *err) ...@@ -914,3 +912,22 @@ struct auxtrace_record *cs_etm_record_init(int *err)
out: out:
return NULL; return NULL;
} }
/*
* Set a default config to enable the user changed config tracking mechanism
* (CFG_CHG and evsel__set_config_if_unset()). If no default is set then user
* changes aren't tracked.
*/
struct perf_event_attr *
cs_etm_get_default_config(struct perf_pmu *pmu __maybe_unused)
{
struct perf_event_attr *attr;
attr = zalloc(sizeof(struct perf_event_attr));
if (!attr)
return NULL;
attr->sample_period = 1;
return attr;
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "arm-spe.h" #include "arm-spe.h"
#include "hisi-ptt.h" #include "hisi-ptt.h"
#include "../../../util/pmu.h" #include "../../../util/pmu.h"
#include "../cs-etm.h"
struct perf_event_attr struct perf_event_attr
*perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
...@@ -20,6 +21,7 @@ struct perf_event_attr ...@@ -20,6 +21,7 @@ struct perf_event_attr
if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) {
/* add ETM default config here */ /* add ETM default config here */
pmu->selectable = true; pmu->selectable = true;
return cs_etm_get_default_config(pmu);
#if defined(__aarch64__) #if defined(__aarch64__)
} else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) { } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) {
return arm_spe_pmu_default_config(pmu); return arm_spe_pmu_default_config(pmu);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/bits.h> #include <linux/bits.h>
struct perf_session; struct perf_session;
struct perf_pmu;
/* /*
* Versioning header in case things need to change in the future. That way * Versioning header in case things need to change in the future. That way
...@@ -228,6 +229,7 @@ struct cs_etm_packet_queue { ...@@ -228,6 +229,7 @@ struct cs_etm_packet_queue {
int cs_etm__process_auxtrace_info(union perf_event *event, int cs_etm__process_auxtrace_info(union perf_event *event,
struct perf_session *session); struct perf_session *session);
struct perf_event_attr *cs_etm_get_default_config(struct perf_pmu *pmu);
#ifdef HAVE_CSTRACE_SUPPORT #ifdef HAVE_CSTRACE_SUPPORT
int cs_etm__get_cpu(u8 trace_chan_id, int *cpu); int cs_etm__get_cpu(u8 trace_chan_id, int *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