Skip to content

Commit 7bfc154

Browse files
James-A-Clarkacmel
authored andcommitted
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: James 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.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 35c51f8 commit 7bfc154

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
324324
perf_can_record_switch_events())
325325
opts->record_switch_events = true;
326326

327-
cs_etm_evsel->core.attr.freq = 0;
328-
cs_etm_evsel->core.attr.sample_period = 1;
329327
cs_etm_evsel->needs_auxtrace_mmap = true;
330328
opts->full_auxtrace = true;
331329

@@ -430,10 +428,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
430428
* when a context switch happened.
431429
*/
432430
if (!perf_cpu_map__empty(cpus)) {
433-
cs_etm_evsel->core.attr.config |=
434-
perf_pmu__format_bits(&cs_etm_pmu->format, "timestamp");
435-
cs_etm_evsel->core.attr.config |=
436-
perf_pmu__format_bits(&cs_etm_pmu->format, "contextid");
431+
evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel,
432+
"timestamp", 1);
433+
evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel,
434+
"contextid", 1);
437435
}
438436

439437
/* Add dummy event to keep tracking */
@@ -914,3 +912,22 @@ struct auxtrace_record *cs_etm_record_init(int *err)
914912
out:
915913
return NULL;
916914
}
915+
916+
/*
917+
* Set a default config to enable the user changed config tracking mechanism
918+
* (CFG_CHG and evsel__set_config_if_unset()). If no default is set then user
919+
* changes aren't tracked.
920+
*/
921+
struct perf_event_attr *
922+
cs_etm_get_default_config(struct perf_pmu *pmu __maybe_unused)
923+
{
924+
struct perf_event_attr *attr;
925+
926+
attr = zalloc(sizeof(struct perf_event_attr));
927+
if (!attr)
928+
return NULL;
929+
930+
attr->sample_period = 1;
931+
932+
return attr;
933+
}

tools/perf/arch/arm/util/pmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "arm-spe.h"
1313
#include "hisi-ptt.h"
1414
#include "../../../util/pmu.h"
15+
#include "../cs-etm.h"
1516

1617
struct perf_event_attr
1718
*perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
@@ -20,6 +21,7 @@ struct perf_event_attr
2021
if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) {
2122
/* add ETM default config here */
2223
pmu->selectable = true;
24+
return cs_etm_get_default_config(pmu);
2325
#if defined(__aarch64__)
2426
} else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) {
2527
return arm_spe_pmu_default_config(pmu);

tools/perf/util/cs-etm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/bits.h>
1313

1414
struct perf_session;
15+
struct perf_pmu;
1516

1617
/*
1718
* Versioning header in case things need to change in the future. That way
@@ -228,6 +229,7 @@ struct cs_etm_packet_queue {
228229

229230
int cs_etm__process_auxtrace_info(union perf_event *event,
230231
struct perf_session *session);
232+
struct perf_event_attr *cs_etm_get_default_config(struct perf_pmu *pmu);
231233

232234
#ifdef HAVE_CSTRACE_SUPPORT
233235
int cs_etm__get_cpu(u8 trace_chan_id, int *cpu);

0 commit comments

Comments
 (0)