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

perf script: Enable to present DTL entries

The process_event() function in "builtin-script.c" invokes
perf_sample__fprintf_synth() for displaying PERF_TYPE_SYNTH
type events.

if (attr->type == PERF_TYPE_SYNTH && PRINT_FIELD(SYNTH))
perf_sample__fprintf_synth(sample, evsel, fp);

perf_sample__fprintf_synth() process the sample depending on the value
in evsel->core.attr.config. Introduce perf_sample__fprintf_synth_vpadtl()
and invoke this for PERF_SYNTH_POWERPC_VPA_DTL

Sample output:

./perf record -a -e sched:*,vpa_dtl/dtl_all/ -c 1000000000 sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.300 MB perf.data ]

./perf script
perf 13322 [002] 233.835807: sched:sched_switch: perf:13322 [120] R ==> migration/2:27 [0]
migration/2 27 [002] 233.835811: sched:sched_migrate_task: comm=perf pid=13322 prio=120 orig_cpu=2 dest_cpu=3
migration/2 27 [002] 233.835818: sched:sched_stat_runtime: comm=migration/2 pid=27 runtime=9214 [ns]
migration/2 27 [002] 233.835819: sched:sched_switch: migration/2:27 [0] S ==> swapper/2:0 [120]
swapper 0 [002] 233.835822: vpa-dtl: timebase: 338954486062657 dispatch_reason:decrementer_interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:435, ready_to_enqueue_time:0, waiting_to_ready_time:34775058, processor_id: 202 c0000000000f8094 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])
swapper 0 [001] 233.835886: vpa-dtl: timebase: 338954486095398 dispatch_reason:priv_doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:542, ready_to_enqueue_time:0, waiting_to_ready_time:1245360, processor_id: 201 c0000000000f8094 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])

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
a0dfb18f 8644834a

+33
+30
tools/perf/builtin-script.c
··· 43 43 #include <linux/stringify.h> 44 44 #include <linux/time64.h> 45 45 #include <linux/zalloc.h> 46 + #include <linux/unaligned.h> 46 47 #include <sys/utsname.h> 47 48 #include "asm/bug.h" 48 49 #include "util/mem-events.h" ··· 2004 2003 return len + perf_sample__fprintf_pt_spacing(len, fp); 2005 2004 } 2006 2005 2006 + #ifdef HAVE_AUXTRACE_SUPPORT 2007 + static int perf_sample__fprintf_synth_vpadtl(struct perf_sample *data, FILE *fp) 2008 + { 2009 + struct powerpc_vpadtl_entry *dtl = (struct powerpc_vpadtl_entry *)data->raw_data; 2010 + int len; 2011 + 2012 + len = fprintf(fp, "timebase: %" PRIu64 " dispatch_reason:%s, preempt_reason:%s,\n" 2013 + "enqueue_to_dispatch_time:%d, ready_to_enqueue_time:%d," 2014 + "waiting_to_ready_time:%d, processor_id: %d", 2015 + get_unaligned_be64(&dtl->timebase), 2016 + dispatch_reasons[dtl->dispatch_reason], 2017 + preempt_reasons[dtl->preempt_reason], 2018 + be32_to_cpu(dtl->enqueue_to_dispatch_time), 2019 + be32_to_cpu(dtl->ready_to_enqueue_time), 2020 + be32_to_cpu(dtl->waiting_to_ready_time), 2021 + be16_to_cpu(dtl->processor_id)); 2022 + 2023 + return len; 2024 + } 2025 + #else 2026 + static int perf_sample__fprintf_synth_vpadtl(struct perf_sample *data __maybe_unused, 2027 + FILE *fp __maybe_unused) 2028 + { 2029 + return 0; 2030 + } 2031 + #endif 2032 + 2007 2033 static int perf_sample__fprintf_synth(struct perf_sample *sample, 2008 2034 struct evsel *evsel, FILE *fp) 2009 2035 { ··· 2053 2025 return perf_sample__fprintf_synth_evt(sample, fp); 2054 2026 case PERF_SYNTH_INTEL_IFLAG_CHG: 2055 2027 return perf_sample__fprintf_synth_iflag_chg(sample, fp); 2028 + case PERF_SYNTH_POWERPC_VPA_DTL: 2029 + return perf_sample__fprintf_synth_vpadtl(sample, fp); 2056 2030 default: 2057 2031 break; 2058 2032 }
+3
tools/perf/util/event.h
··· 271 271 u64 srr1; 272 272 }; 273 273 274 + extern const char *dispatch_reasons[11]; 275 + extern const char *preempt_reasons[10]; 276 + 274 277 static inline void *perf_synth__raw_data(void *p) 275 278 { 276 279 return p + 4;