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

perf powerpc: Add basic CONFIG_AUXTRACE support for VPA pmu on powerpc

The powerpc PMU collecting Dispatch Trace Log (DTL) entries makes use of
AUX support in perf infrastructure.

The PMU driver has the functionality to collect trace entries in the aux
buffer.

On the tools side, this data is made available as PERF_RECORD_AUXTRACE
records.

This record is generated by "perf record" command.

To enable the creation of PERF_RECORD_AUXTRACE, add functions to
initialize auxtrace records ie "auxtrace_record__init()".

Fill in fields for other callbacks like info_priv_size, info_fill, free,
recording options etc.

Define auxtrace_type as PERF_AUXTRACE_VPA_DTL. Add header file to
define vpa dtl pmu specific details.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Tejas Manhas <tejas05@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Cc: Aboorva Devarajan <aboorvad@linux.ibm.com>
Cc: Aditya Bodkhe <Aditya.Bodkhe1@ibm.com>
Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Athira Rajeev and committed by
Arnaldo Carvalho de Melo
1dbfaf94 58a60614

+122
+1
tools/perf/arch/powerpc/util/Build
··· 10 10 11 11 perf-util-$(CONFIG_LIBUNWIND) += unwind-libunwind.o 12 12 perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 13 + perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
+103
tools/perf/arch/powerpc/util/auxtrace.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * VPA support 4 + */ 5 + 6 + #include <linux/kernel.h> 7 + #include <linux/types.h> 8 + #include <linux/string.h> 9 + 10 + #include "../../util/evlist.h" 11 + #include "../../util/debug.h" 12 + #include "../../util/auxtrace.h" 13 + #include "../../util/powerpc-vpadtl.h" 14 + #include "../../util/record.h" 15 + #include <internal/lib.h> // page_size 16 + 17 + #define KiB(x) ((x) * 1024) 18 + 19 + static int 20 + powerpc_vpadtl_recording_options(struct auxtrace_record *ar __maybe_unused, 21 + struct evlist *evlist __maybe_unused, 22 + struct record_opts *opts) 23 + { 24 + opts->full_auxtrace = true; 25 + 26 + /* 27 + * Set auxtrace_mmap_pages to minimum 28 + * two pages 29 + */ 30 + if (!opts->auxtrace_mmap_pages) { 31 + opts->auxtrace_mmap_pages = KiB(128) / page_size; 32 + if (opts->mmap_pages == UINT_MAX) 33 + opts->mmap_pages = KiB(256) / page_size; 34 + } 35 + 36 + return 0; 37 + } 38 + 39 + static size_t powerpc_vpadtl_info_priv_size(struct auxtrace_record *itr __maybe_unused, 40 + struct evlist *evlist __maybe_unused) 41 + { 42 + return VPADTL_AUXTRACE_PRIV_SIZE; 43 + } 44 + 45 + static int 46 + powerpc_vpadtl_info_fill(struct auxtrace_record *itr __maybe_unused, 47 + struct perf_session *session __maybe_unused, 48 + struct perf_record_auxtrace_info *auxtrace_info, 49 + size_t priv_size __maybe_unused) 50 + { 51 + auxtrace_info->type = PERF_AUXTRACE_VPA_DTL; 52 + 53 + return 0; 54 + } 55 + 56 + static void powerpc_vpadtl_free(struct auxtrace_record *itr) 57 + { 58 + free(itr); 59 + } 60 + 61 + static u64 powerpc_vpadtl_reference(struct auxtrace_record *itr __maybe_unused) 62 + { 63 + return 0; 64 + } 65 + 66 + struct auxtrace_record *auxtrace_record__init(struct evlist *evlist, 67 + int *err) 68 + { 69 + struct auxtrace_record *aux; 70 + struct evsel *pos; 71 + int found = 0; 72 + 73 + evlist__for_each_entry(evlist, pos) { 74 + if (strstarts(pos->name, "vpa_dtl")) { 75 + found = 1; 76 + pos->needs_auxtrace_mmap = true; 77 + break; 78 + } 79 + } 80 + 81 + if (!found) 82 + return NULL; 83 + 84 + /* 85 + * To obtain the auxtrace buffer file descriptor, the auxtrace event 86 + * must come first. 87 + */ 88 + evlist__to_front(pos->evlist, pos); 89 + 90 + aux = zalloc(sizeof(*aux)); 91 + if (aux == NULL) { 92 + pr_debug("aux record is NULL\n"); 93 + *err = -ENOMEM; 94 + return NULL; 95 + } 96 + 97 + aux->recording_options = powerpc_vpadtl_recording_options; 98 + aux->info_priv_size = powerpc_vpadtl_info_priv_size; 99 + aux->info_fill = powerpc_vpadtl_info_fill; 100 + aux->free = powerpc_vpadtl_free; 101 + aux->reference = powerpc_vpadtl_reference; 102 + return aux; 103 + }
+1
tools/perf/util/auxtrace.c
··· 1390 1390 case PERF_AUXTRACE_HISI_PTT: 1391 1391 err = hisi_ptt_process_auxtrace_info(event, session); 1392 1392 break; 1393 + case PERF_AUXTRACE_VPA_DTL: 1393 1394 case PERF_AUXTRACE_UNKNOWN: 1394 1395 default: 1395 1396 return -EINVAL;
+1
tools/perf/util/auxtrace.h
··· 50 50 PERF_AUXTRACE_ARM_SPE, 51 51 PERF_AUXTRACE_S390_CPUMSF, 52 52 PERF_AUXTRACE_HISI_PTT, 53 + PERF_AUXTRACE_VPA_DTL, 53 54 }; 54 55 55 56 enum itrace_period_type {
+16
tools/perf/util/powerpc-vpadtl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * VPA DTL PMU Support 4 + */ 5 + 6 + #ifndef INCLUDE__PERF_POWERPC_VPADTL_H__ 7 + #define INCLUDE__PERF_POWERPC_VPADTL_H__ 8 + 9 + enum { 10 + POWERPC_VPADTL_TYPE, 11 + VPADTL_AUXTRACE_PRIV_MAX, 12 + }; 13 + 14 + #define VPADTL_AUXTRACE_PRIV_SIZE (VPADTL_AUXTRACE_PRIV_MAX * sizeof(u64)) 15 + 16 + #endif