Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
7bfc1544 35c51f83

+27 -6
+23 -6
tools/perf/arch/arm/util/cs-etm.c
··· 324 324 perf_can_record_switch_events()) 325 325 opts->record_switch_events = true; 326 326 327 - cs_etm_evsel->core.attr.freq = 0; 328 - cs_etm_evsel->core.attr.sample_period = 1; 329 327 cs_etm_evsel->needs_auxtrace_mmap = true; 330 328 opts->full_auxtrace = true; 331 329 ··· 428 430 * when a context switch happened. 429 431 */ 430 432 if (!perf_cpu_map__empty(cpus)) { 431 - cs_etm_evsel->core.attr.config |= 432 - perf_pmu__format_bits(&cs_etm_pmu->format, "timestamp"); 433 - cs_etm_evsel->core.attr.config |= 434 - perf_pmu__format_bits(&cs_etm_pmu->format, "contextid"); 433 + evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel, 434 + "timestamp", 1); 435 + evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel, 436 + "contextid", 1); 435 437 } 436 438 437 439 /* Add dummy event to keep tracking */ ··· 911 913 return &ptr->itr; 912 914 out: 913 915 return NULL; 916 + } 917 + 918 + /* 919 + * Set a default config to enable the user changed config tracking mechanism 920 + * (CFG_CHG and evsel__set_config_if_unset()). If no default is set then user 921 + * changes aren't tracked. 922 + */ 923 + struct perf_event_attr * 924 + cs_etm_get_default_config(struct perf_pmu *pmu __maybe_unused) 925 + { 926 + struct perf_event_attr *attr; 927 + 928 + attr = zalloc(sizeof(struct perf_event_attr)); 929 + if (!attr) 930 + return NULL; 931 + 932 + attr->sample_period = 1; 933 + 934 + return attr; 914 935 }
+2
tools/perf/arch/arm/util/pmu.c
··· 12 12 #include "arm-spe.h" 13 13 #include "hisi-ptt.h" 14 14 #include "../../../util/pmu.h" 15 + #include "../cs-etm.h" 15 16 16 17 struct perf_event_attr 17 18 *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) ··· 21 20 if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { 22 21 /* add ETM default config here */ 23 22 pmu->selectable = true; 23 + return cs_etm_get_default_config(pmu); 24 24 #if defined(__aarch64__) 25 25 } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) { 26 26 return arm_spe_pmu_default_config(pmu);
+2
tools/perf/util/cs-etm.h
··· 12 12 #include <linux/bits.h> 13 13 14 14 struct perf_session; 15 + struct perf_pmu; 15 16 16 17 /* 17 18 * Versioning header in case things need to change in the future. That way ··· 229 228 230 229 int cs_etm__process_auxtrace_info(union perf_event *event, 231 230 struct perf_session *session); 231 + struct perf_event_attr *cs_etm_get_default_config(struct perf_pmu *pmu); 232 232 233 233 #ifdef HAVE_CSTRACE_SUPPORT 234 234 int cs_etm__get_cpu(u8 trace_chan_id, int *cpu);