perf/tools: Add interface to expose vpa dtl
v3 cover perf/tools: Add interface to expose vpa dtl
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
Kernel and tools patches is separated. Kernel patches are posted here :
V2: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
V3: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
Infrastructure used
===================
The VPA DTL PMU counters do not interrupt on overflow or generate any PMI interrupts. Therefore, hrtimer is used to poll the DTL data. The timer interval can be provided by user via sample_period field in nano seconds. vpa dtl pmu has one hrtimer added per vpa-dtl pmu thread. DTL (Dispatch Trace Log) contains information about dispatch/preempt, enqueue time etc. We directly copy the DTL buffer data as part of auxiliary buffer and it will be processed later. This will avoid time taken to create samples in the kernel space. The PMU driver collecting Dispatch Trace Log (DTL) entries makes use of AUX support in perf infrastructure. On the tools side, this data is made available as PERF_RECORD_AUXTRACE records.
To corelate each DTL entry with other events across CPU's, an auxtrace_queue is created for each CPU. Each auxtrace queue has a array/list of auxtrace buffers. All auxtrace queues is maintained in auxtrace heap. The queues are sorted based on timestamp. When the different PERF_RECORD_XX records are processed, compare the timestamp of perf record with timestamp of top element in the auxtrace heap so that DTL events can be co-related with other events Process the auxtrace queue if the timestamp of element from heap is lower than timestamp from entry in perf record. Sometimes it could happen that one buffer is only partially processed. if the timestamp of occurrence of another event is more than currently processed element in the queue, it will move on to next perf record. So keep track of position of buffer to continue processing next time. Update the timestamp of the auxtrace heap with the timestamp of last processed entry from the auxtrace buffer.
This infrastructure ensures dispatch trace log entries can be corelated and presented along with other events like sched.
vpa-dtl PMU example usage
# ls /sys/devices/vpa_dtl/ events format perf_event_mux_interval_ms power subsystem type uevent
To capture the DTL data using perf record:
# ./perf record -a -e sched:*,vpa_dtl/dtl_all/ -c 1000000000 sleep 1
The result can be interpreted using perf report. Snippet of perf report -D:
# ./perf report -D
There are different PERF_RECORD_XX records. In that records corresponding to auxtrace buffers includes:
1. PERF_RECORD_AUX
Conveys that new data is available in AUX area
2. PERF_RECORD_AUXTRACE_INFO
Describes offset and size of auxtrace data in the buffers
3. PERF_RECORD_AUXTRACE
This is the record that defines the auxtrace data which here in case of vpa-dtl pmu is dispatch trace log data.
Snippet from perf report -D showing the PERF_RECORD_AUXTRACE dump
0 0 0x39b10 [0x30]: PERF_RECORD_AUXTRACE size: 0x690 offset: 0 ref: 0 idx: 0 tid: -1 cpu: 0 .
. ... VPA DTL PMU data: size 1680 bytes, entries is 35
. 00000000: boot_tb: 21349649546353231, tb_freq: 512000000 . 00000030: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:7064, ready_to_enqueue_time:187, waiting_to_ready_time:6611773 . 00000060: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:146, ready_to_enqueue_time:0, waiting_to_ready_time:15359437 . 00000090: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:4868, ready_to_enqueue_time:232, waiting_to_ready_time:5100709 . 000000c0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:179, ready_to_enqueue_time:0, waiting_to_ready_time:30714243 . 000000f0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:197, ready_to_enqueue_time:0, waiting_to_ready_time:15350648 . 00000120: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:213, ready_to_enqueue_time:0, waiting_to_ready_time:15353446 . 00000150: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:212, ready_to_enqueue_time:0, waiting_to_ready_time:15355126 . 00000180: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:6368, ready_to_enqueue_time:164, waiting_to_ready_time:5104665
Above is representation of dtl entry of below format:
struct dtl_entry {
u8 dispatch_reason;
u8 preempt_reason;
u16 processor_id;
u32 enqueue_to_dispatch_time;
u32 ready_to_enqueue_time;
u32 waiting_to_ready_time;
u64 timebase;
u64 fault_addr;
u64 srr0;
u64 srr1;};
First two fields represent the dispatch reason and preempt reason. The post procecssing of PERF_RECORD_AUXTRACE records will translate to meaninful data for user to consume.
Visualize the dispatch trace log entries with perf report:
# ./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 report
# Samples: 321 of event 'vpa-dtl'
# Event count (approx.): 321
#
# Children Self Command Shared Object Symbol
# ........ ........ ....... ................. ..............................
#
100.00% 100.00% swapper [kernel.kallsyms] [k] plpar_hcall_norets_notraceVisualize the dispatch trace log entries with perf script:
# ./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])Changelog is added for V3 in each individual patch
Thanks
Athira
Athira Rajeev (6):
tools/perf: Add basic CONFIG_AUXTRACE support for VPA pmu on powerpc tools/perf: process auxtrace events and display in perf report -D tools/perf: Add event name as vpa-dtl of PERF_TYPE_SYNTH type to
present DTL samples
tools/perf: Allocate and setup aux buffer queue to help co-relate with
other events across CPU's
tools/perf: Process the DTL entries in queue and deliver samples tools/perf: Enable perf script to present the DTL entries
tools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/auxtrace.c | 103 ++++ tools/perf/builtin-script.c | 30 + tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/event.h | 20 + tools/perf/util/powerpc-vpadtl.c | 734 ++++++++++++++++++++++++ tools/perf/util/powerpc-vpadtl.h | 23 + 9 files changed, 917 insertions(+) create mode 100644 tools/perf/arch/powerpc/util/auxtrace.c create mode 100644 tools/perf/util/powerpc-vpadtl.c create mode 100644 tools/perf/util/powerpc-vpadtl.h
Signature · 1 line
2.47.1
PATCH v3 1/6 tools/perf: 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.
---
Changelog:
v3:
Addressed review comments from Adrian:
- Remove unused header files from arch/powerpc/util/auxtrace.c
- Use evsel name instead of using new variable
- Remove unused POWERPC_VPADTL_NAME
- Added Tested by from Venkat
v2:
Addressed review comments from Adrian:
- Return VPADTL_AUXTRACE_PRIV_SIZE in powerpc_vpadtl_info_priv_size
- Remove unused powerpc_vpadtl_parse_snapshot_options
- Some of the function parameters had "__maybe_unused", corrected it.
- Used PERF_AUXTRACE_VPA_DTL instead of PERF_AUXTRACE_VPA_PMU
- Moved powerpc_vpadtl_process_auxtrace_info to next patch
tools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/auxtrace.c | 103 ++++++++++++++++++++++++ tools/perf/util/auxtrace.c | 1 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/powerpc-vpadtl.h | 16 ++++ 5 files changed, 122 insertions(+) create mode 100644 tools/perf/arch/powerpc/util/auxtrace.c create mode 100644 tools/perf/util/powerpc-vpadtl.h
tools/perf/arch/powerpc/util/Build +1 -0
@@ -10,3 +10,4 @@ perf-util-$(CONFIG_LIBDW) += skip-callchain-idx.o perf-util-$(CONFIG_LIBUNWIND) += unwind-libunwind.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o +perf-util-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/arch/powerpc/util/auxtrace.c new file +103 -0
103 lines not on this page · raw message
tools/perf/util/auxtrace.c +1 -0
@@ -1393,6 +1393,7 @@ int perf_event__process_auxtrace_info(struct perf_session *session,case PERF_AUXTRACE_HISI_PTT : err =hisi_ptt_process_auxtrace_info (event, session);break ; +case PERF_AUXTRACE_VPA_DTL :case PERF_AUXTRACE_UNKNOWN :default :return -EINVAL ;
tools/perf/util/auxtrace.h +1 -0
@@ -50,6 +50,7 @@ enum auxtrace_type {PERF_AUXTRACE_ARM_SPE ,PERF_AUXTRACE_S390_CPUMSF ,PERF_AUXTRACE_HISI_PTT , + PERF_AUXTRACE_VPA_DTL, }; enum itrace_period_type {
tools/perf/util/powerpc-vpadtl.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* VPA DTL PMU Support +*/ + +#ifndef INCLUDE__PERF_POWERPC_VPADTL_H__ +#define INCLUDE__PERF_POWERPC_VPADTL_H__ + +enum { +POWERPC_VPADTL_TYPE , +VPADTL_AUXTRACE_PRIV_MAX , +}; + +#define VPADTL_AUXTRACE_PRIV_SIZE (VPADTL_AUXTRACE_PRIV_MAX * sizeof(u64)) + +#endif
Signature · 1 line
2.47.1
PATCH v3 2/6 tools/perf: process auxtrace events and display in perf report -D
In reply to Athira RajeevAdd vpa dtl pmu auxtrace process function for "perf report -D". The auxtrace event processing functions are defined in file "util/powerpc-vpadtl.c". Data structures used includes "struct powerpc_vpadtl_queue", "struct powerpc_vpadtl" to store the auxtrace buffers in queue. Different PERF_RECORD_XXX are generated during recording. PERF_RECORD_AUXTRACE_INFO is processed first since it is of type perf_user_event_type and perf session event delivers perf_session__process_user_event() first. Define function powerpc_vpadtl_process_auxtrace_info() to handle the processing of PERF_RECORD_AUXTRACE_INFO records. In this function, initialize the aux buffer queues using auxtrace_queues__init(). Setup the required infrastructure for aux data processing. The data is collected per CPU and auxtrace_queue is created for each CPU.
Define powerpc_vpadtl_process_event() function to process PERF_RECORD_AUXTRACE records. In this, add the event to queue using auxtrace_queues__add_event() and process the buffer in powerpc_vpadtl_dump_event(). The first entry in the buffer with timebase as zero has boot timebase and frequency. Remaining data is of format for "struct powerpc_vpadtl_entry". Define the translation for dispatch_reasons and preempt_reasons, report this when dump trace is invoked via powerpc_vpadtl_dump()
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 report -D
0 0 0x39b10 [0x30]: PERF_RECORD_AUXTRACE size: 0x690 offset: 0 ref: 0 idx: 0 tid: -1 cpu: 0 .
. ... VPA DTL PMU data: size 1680 bytes, entries is 35
. 00000000: boot_tb: 21349649546353231, tb_freq: 512000000 . 00000030: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:7064, ready_to_enqueue_time:187, waiting_to_ready_time:6611773 . 00000060: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:146, ready_to_enqueue_time:0, waiting_to_ready_time:15359437 . 00000090: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:4868, ready_to_enqueue_time:232, waiting_to_ready_time:5100709 . 000000c0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:179, ready_to_enqueue_time:0, waiting_to_ready_time:30714243 . 000000f0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:197, ready_to_enqueue_time:0, waiting_to_ready_time:15350648 . 00000120: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:213, ready_to_enqueue_time:0, waiting_to_ready_time:15353446 . 00000150: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:212, ready_to_enqueue_time:0, waiting_to_ready_time:15355126 . 00000180: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:6368, ready_to_enqueue_time:164, waiting_to_ready_time:5104665
---
Changelog:
v3:
Addressed review comments from Adrian
- Added header files which were missing
- line length change to fit 100 columns
- zfree for auxtrace queue can be used directly without checking if queue exists
- Added Tested by from Venkat
v2:
Addressed review comments from Adrian
- Renamed dtl_entry to powerpc_vpadtl_entry in util/event.h
- Removed unused #includes in powerpc-vpadtl.c
- Added helper session_to_vpa to get "struct powerpc_vpadtl"
- Updated auxtrace_queues__add_event only for piped data
- Used zfree to free "struct powerpc_vpadtl_queue"
tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 3 + tools/perf/util/event.h | 16 ++ tools/perf/util/powerpc-vpadtl.c | 264 +++++++++++++++++++++++++++++++ tools/perf/util/powerpc-vpadtl.h | 7 + 5 files changed, 291 insertions(+) create mode 100644 tools/perf/util/powerpc-vpadtl.c
tools/perf/util/Build +1 -0
@@ -136,6 +136,7 @@ perf-util-$(CONFIG_AUXTRACE) += arm-spe-decoder/ perf-util-$(CONFIG_AUXTRACE) += hisi-ptt.o perf-util-$(CONFIG_AUXTRACE) += hisi-ptt-decoder/ perf-util-$(CONFIG_AUXTRACE) += s390-cpumsf.o +perf-util-$(CONFIG_AUXTRACE) += powerpc-vpadtl.o ifdef CONFIG_LIBOPENCSD perf-util-$(CONFIG_AUXTRACE) += cs-etm.o
tools/perf/util/auxtrace.c +3 -0
@@ -55,6 +55,7 @@#include "hisi-ptt.h" #include "s390-cpumsf.h" #include "util/mmap.h" +#include "powerpc-vpadtl.h" #include <linux/ctype.h> #include "symbol/kallsyms.h"
@@ -1394,6 +1395,8 @@ int perf_event__process_auxtrace_info(struct perf_session *session, err =hisi_ptt_process_auxtrace_info (event, session);break ;case PERF_AUXTRACE_VPA_DTL : + err =powerpc_vpadtl_process_auxtrace_info (event, session); +break ;case PERF_AUXTRACE_UNKNOWN :default :return -EINVAL ;
tools/perf/util/event.h +16 -0
@@ -254,6 +254,22 @@ struct perf_synth_intel_iflag_chg {u64 branch_ip;/* If via_branch */ }; +/* +* The powerpc VPA DTL entries are of below format +*/ +struct powerpc_vpadtl_entry { +u8 dispatch_reason; +u8 preempt_reason; +u16 processor_id; +u32 enqueue_to_dispatch_time; +u32 ready_to_enqueue_time; +u32 waiting_to_ready_time; +u64 timebase; +u64 fault_addr; +u64 srr0; +u64 srr1; +}; +static inline void *perf_synth__raw_data (void *p) {return p +4 ;
tools/perf/util/powerpc-vpadtl.c new file +264 -0
264 lines not on this page · raw message
tools/perf/util/powerpc-vpadtl.h +7 -0
@@ -13,4 +13,11 @@ enum {#define VPADTL_AUXTRACE_PRIV_SIZE (VPADTL_AUXTRACE_PRIV_MAX * sizeof(u64)) +union perf_event ; +struct perf_session ; +struct perf_pmu ; + +int powerpc_vpadtl_process_auxtrace_info (union perf_event *event, +struct perf_session *session); +#endif
Signature · 1 line
2.47.1
PATCH v3 3/6 tools/perf: Add event name as vpa-dtl of PERF_TYPE_SYNTH type to present DTL samples
In reply to Athira RajeevDispatch Trace Log details are captured as-is in PERF_RECORD_AUXTRACE records. To present dtl entries as samples, create an event with name as "vpa-dtl" and type PERF_TYPE_SYNTH. Add perf_synth_id, "PERF_SYNTH_POWERPC_VPA_DTL" as config value for the event. Create a sample id to be a fixed offset from evsel id.
To present the relevant fields from the "struct dtl_entry", prepare the entries as events of type PERF_TYPE_SYNTH. By defining as PERF_TYPE_SYNTH type, samples can be printed as part of perf_sample__fprintf_synth in builtin-script.c
From powerpc_vpadtl_process_auxtrace_info(), invoke auxtrace_queues__process_index() function which will queue the auxtrace buffers by invoke auxtrace_queues__add_event().
---
Changelog
v3:
Added Tested-by from Venkat
tools/perf/util/event.h | 1 + tools/perf/util/powerpc-vpadtl.c | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
tools/perf/util/event.h +1 -0
@@ -117,6 +117,7 @@ enum perf_synth_id {PERF_SYNTH_INTEL_PSB ,PERF_SYNTH_INTEL_EVT ,PERF_SYNTH_INTEL_IFLAG_CHG , + PERF_SYNTH_POWERPC_VPA_DTL, };/*
tools/perf/util/powerpc-vpadtl.c +76 -0
102 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH v3 4/6 tools/perf: Allocate and setup aux buffer queue to help co-relate with other events across CPU's
In reply to Athira RajeevWhen the Dispatch Trace Log data is collected along with other events like sched tracepoint events, it needs to be correlated and present interleaved along with these events. Perf events can be collected parallely across the CPUs. Hence it needs to be ensured events/dtl entries are processed in timestamp order.
An auxtrace_queue is created for each CPU. Data within each queue is in increasing order of timestamp. Each auxtrace queue has a array/list of auxtrace buffers. When processing the auxtrace buffer, the data is mmapp'ed. All auxtrace queues is maintained in auxtrace heap. Each queue has a queue number and a timestamp. The queues are sorted/added to head based on the time stamp. So always the lowest timestamp (entries to be processed first) is on top of the heap.
The auxtrace queue needs to be allocated and heap needs to be populated in the sorted order of timestamp. The queue needs to be filled with data only once via powerpc_vpadtl__update_queues() function. powerpc_vpadtl__setup_queues() iterates through all the entries to allocate and setup the auxtrace queue. To add to auxtrace heap, it is required to fetch the timebase of first entry for each of the queue.
The first entry in the queue for VPA DTL PMU has the boot timebase, frequency details which are needed to get timestamp which is required to correlate with other events. The very next entry is the actual trace data that provides timestamp for occurrence of DTL event. Formula used to get the timestamp from dtl entry is:
((timbase from DTL entry - boot time) / frequency) * 1000000000
powerpc_vpadtl_decode() adds the boot time and frequency as part of powerpc_vpadtl_queue structure so that it can be reused. Each of the dtl_entry is of 48 bytes size. Sometimes it could happen that one buffer is only partially processed (if the timestamp of occurrence of another event is more than currently processed element in queue, it will move on to next event). In order to keep track of position of buffer, additional fields is added to powerpc_vpadtl_queue structure.
---
Changelog:
v3:
Addressed review comments from Adrian
- Declare variables in descending line length
- session parameter is not __maybe_unused in
powerpc_vpadtl_process_event
- Added Tested by from Venkat
v2:
Addressed review comments from Adrian
- Moved time calculation to separate function
tools/perf/util/powerpc-vpadtl.c | 227 ++++++++++++++++++++++++++++++- 1 file changed, 223 insertions(+), 4 deletions(-)
tools/perf/util/powerpc-vpadtl.c +223 -4
@@ -13,6 +13,8 @@#include "machine.h" #include "debug.h" #include "powerpc-vpadtl.h" +#include "sample.h" +#include "tool.h" /* * Structure to save the auxtrace queue
@@ -41,6 +43,14 @@ struct powerpc_vpadtl_queue {struct auxtrace_buffer *buffer;struct thread *thread;bool on_heap; +struct powerpc_vpadtl_entry *dtl; +u64 timestamp; +unsigned long pkt_len; +unsigned long buf_len; +u64 boot_tb; +u64 tb_freq; +unsigned int tb_buffer; +unsigned int size;bool done;pid_t pid;pid_t tid;
@@ -119,6 +129,32 @@ static void powerpc_vpadtl_dump(struct powerpc_vpadtl *vpa __maybe_unused, } } +static unsigned long long powerpc_vpadtl_timestamp (struct powerpc_vpadtl_queue *vpaq) +{ +struct powerpc_vpadtl_entry *record = vpaq->dtl; +unsigned long long timestamp =0 ; +unsigned long long boot_tb; +unsigned long long diff; +double result, div; +double boot_freq; +/* +* Formula used to get timestamp that can be co-related with +* other perf events: +* ((timbase from DTL entry - boot time) / frequency) * 1000000000 +*/ +if (record->timebase) { + boot_tb = vpaq->boot_tb; + boot_freq = vpaq->tb_freq; + diff =be64_to_cpu (record->timebase) - boot_tb; + div = diff / boot_freq; + result = div; + result = result *1000000000 ; + timestamp = result; + } + +return timestamp; +} +static struct powerpc_vpadtl *session_to_vpa (struct perf_session *session) { return container_of(session->auxtrace, struct powerpc_vpadtl, auxtrace);
@@ -131,14 +167,197 @@ static void powerpc_vpadtl_dump_event(struct powerpc_vpadtl *vpa, unsigned charpowerpc_vpadtl_dump (vpa, buf, len); } -static int powerpc_vpadtl_process_event (struct perf_session *session__maybe_unused , -union perf_event *event__maybe_unused , -struct perf_sample *sample__maybe_unused , -const struct perf_tool *tool__maybe_unused ) +static int powerpc_vpadtl_get_buffer (struct powerpc_vpadtl_queue *vpaq) +{ +struct auxtrace_buffer *buffer = vpaq->buffer; +struct auxtrace_queues *queues = &vpaq->vpa->queues; +struct auxtrace_queue *queue; + + queue = &queues->queue_array[vpaq->queue_nr]; + buffer =auxtrace_buffer__next (queue, buffer); + +if (!buffer) +return 0 ; + + vpaq->buffer = buffer; + vpaq->size = buffer->size; + +/* If the aux_buffer doesn't have data associated, try to load it */ +if (!buffer->data) { +/* get the file desc associated with the perf data file */ +int fd =perf_data__fd (vpaq->vpa->session->data); + + buffer->data =auxtrace_buffer__get_data (buffer, fd); +if (!buffer->data) +return -ENOMEM ; + } + + vpaq->buf_len = buffer->size; + +if (buffer->size % dtl_entry_size) + vpaq->buf_len = buffer->size - (buffer->size % dtl_entry_size); + +if (vpaq->tb_buffer != buffer->buffer_nr) { + vpaq->pkt_len =0 ; + vpaq->tb_buffer =0 ; + } + +return 1 ; +} + +/* +* The first entry in the queue for VPA DTL PMU has the boot timebase, +* frequency details which are needed to get timestamp which is required to +* correlate with other events. Save the boot_tb and tb_freq as part of +* powerpc_vpadtl_queue. The very next entry is the actual trace data to +* be returned. +*/ +static int powerpc_vpadtl_decode (struct powerpc_vpadtl_queue *vpaq) +{ +int ret; +char *buf; +struct boottb_freq *boottb; + + ret =powerpc_vpadtl_get_buffer (vpaq); +if (ret <=0 ) +return ret; + + boottb = (struct boottb_freq *)vpaq->buffer->data; +if (boottb->timebase ==0 ) { + vpaq->boot_tb = boottb->boot_tb; + vpaq->tb_freq = boottb->tb_freq; + vpaq->pkt_len += dtl_entry_size; + } + + buf = vpaq->buffer->data; + buf += vpaq->pkt_len; + vpaq->dtl = (struct powerpc_vpadtl_entry *)buf; + + vpaq->tb_buffer = vpaq->buffer->buffer_nr; + vpaq->buffer =NULL ; + vpaq->buf_len =0 ; + +return 1 ; +} + +static struct powerpc_vpadtl_queue *powerpc_vpadtl__alloc_queue (struct powerpc_vpadtl *vpa, +unsigned int queue_nr) +{ +struct powerpc_vpadtl_queue *vpaq; + + vpaq =zalloc (sizeof (*vpaq)); +if (!vpaq) +return NULL ; + + vpaq->vpa = vpa; + vpaq->queue_nr = queue_nr; + +return vpaq; +} + +/* +* When the Dispatch Trace Log data is collected along with other events +* like sched tracepoint events, it needs to be correlated and present +* interleaved along with these events. Perf events can be collected +* parallely across the CPUs. +* +* An auxtrace_queue is created for each CPU. Data within each queue is in +* increasing order of timestamp. Allocate and setup auxtrace queues here. +* All auxtrace queues is maintained in auxtrace heap in the increasing order +* of timestamp. So always the lowest timestamp (entries to be processed first) +* is on top of the heap. +* +* To add to auxtrace heap, fetch the timestamp from first DTL entry +* for each of the queue. +*/ +static int powerpc_vpadtl__setup_queue (struct powerpc_vpadtl *vpa, +struct auxtrace_queue *queue, +unsigned int queue_nr) +{ +struct powerpc_vpadtl_queue *vpaq = queue->priv; + +if (list_empty (&queue->head) || vpaq) +return 0 ; + + vpaq =powerpc_vpadtl__alloc_queue (vpa, queue_nr); +if (!vpaq) +return -ENOMEM ; + + queue->priv = vpaq; + +if (queue->cpu !=-1 ) + vpaq->cpu = queue->cpu; + +if (!vpaq->on_heap) { +int ret; +retry: + ret =powerpc_vpadtl_decode (vpaq); +if (!ret) +return 0 ; + +if (ret <0 ) + goto retry; + + vpaq->timestamp =powerpc_vpadtl_timestamp (vpaq); + + ret =auxtrace_heap__add (&vpa->heap, queue_nr, vpaq->timestamp); +if (ret) +return ret; + vpaq->on_heap = true; + } + +return 0 ; +} + +static int powerpc_vpadtl__setup_queues (struct powerpc_vpadtl *vpa) { +unsigned int i; +int ret; + +for (i =0 ; i < vpa->queues.nr_queues; i++) { + ret =powerpc_vpadtl__setup_queue (vpa, &vpa->queues.queue_array[i], i); +if (ret) +return ret; + } +return 0 ; } +static int powerpc_vpadtl__update_queues (struct powerpc_vpadtl *vpa) +{ +if (vpa->queues.new_data) { + vpa->queues.new_data = false; +return powerpc_vpadtl__setup_queues (vpa); + } + +return 0 ; +} + +static int powerpc_vpadtl_process_event (struct perf_session *session, +union perf_event *event__maybe_unused , +struct perf_sample *sample, +const struct perf_tool *tool) +{ +struct powerpc_vpadtl *vpa =session_to_vpa (session); +int err =0 ; + +if (dump_trace) +return 0 ; + +if (!tool->ordered_events) { +pr_err ("VPA requires ordered events\n" ); +return -EINVAL ; + } + +if (sample->time) { + err =powerpc_vpadtl__update_queues (vpa); +if (err) +return err; + } + +return err; +} +/* * Process PERF_RECORD_AUXTRACE records */
Signature · 1 line
2.47.1
PATCH v3 5/6 tools/perf: Process the DTL entries in queue and deliver samples
In reply to Athira RajeevCreate samples from DTL entries for displaying in perf report and perf script. When the different PERF_RECORD_XX records are processed from perf session, powerpc_vpadtl_process_event() will be invoked. For each of the PERF_RECORD_XX record, compare the timestamp of perf record with timestamp of top element in the auxtrace heap. Process the auxtrace queue if the timestamp of element from heap is lower than timestamp from entry in perf record.
Sometimes it could happen that one buffer is only partially processed. if the timestamp of occurrence of another event is more than currently processed element in the queue, it will move on to next perf record. So keep track of position of buffer to continue processing next time. Update the timestamp of the auxtrace heap with the timestamp of last processed entry from the auxtrace buffer.
Generate perf sample for each entry in the dispatch trace log. Fill in the sample details:
- sample ip is picked from srr0 field of dtl_entry
- sample cpu is picked from processor_id of dtl_entry
- sample id is from sample_id of powerpc_vpadtl
- cpumode is set to PERF_RECORD_MISC_KERNEL
- Additionally save the details in raw_data of sample. This is to print the relevant fields in perf_sample__fprintf_synth() when called from builtin-script
The sample is processed by calling perf_session__deliver_synth_event() so that it gets included in perf report.
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 report
# Samples: 321 of event 'vpa-dtl'
# Event count (approx.): 321
#
# Children Self Command Shared Object Symbol
# ........ ........ ....... ................. ..............................
#
100.00% 100.00% swapper [kernel.kallsyms] [k] plpar_hcall_norets_notrace---
Changelog:
v3:
Addressed review comments from Adrian:
- line lenth to fit 100 columns
- Added braces for else condition
- Added Tested by from Venkat
v2:
Addressed review comments from Adrian:
- Moved time calculation to different function
- Alignment and wording changes
tools/perf/util/powerpc-vpadtl.c | 175 +++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+)
tools/perf/util/powerpc-vpadtl.c +175 -0
@@ -167,6 +167,44 @@ static void powerpc_vpadtl_dump_event(struct powerpc_vpadtl *vpa, unsigned charpowerpc_vpadtl_dump (vpa, buf, len); } +/* +* Generate perf sample for each entry in the dispatch trace log. +* - sample ip is picked from srr0 field of powerpc_vpadtl_entry +* - sample cpu is logical cpu. +* - cpumode is set to PERF_RECORD_MISC_KERNEL +* - Additionally save the details in raw_data of sample. This +* is to print the relevant fields in perf_sample__fprintf_synth() +* when called from builtin-script +*/ +static int powerpc_vpadtl_sample (struct powerpc_vpadtl_entry *record, +struct powerpc_vpadtl *vpa,u64 save,int cpu) +{ +struct perf_sample sample; +union perf_event event; + + sample.ip =be64_to_cpu (record->srr0); + sample.period =1 ; + sample.cpu = cpu; + sample.id = vpa->sample_id; + sample.callchain =NULL ; + sample.branch_stack =NULL ; +memset (&event,0 ,sizeof (event)); + sample.cpumode =PERF_RECORD_MISC_KERNEL ; + sample.time = save; + sample.raw_data = record; + sample.raw_size =sizeof (record); + event.sample.header.type =PERF_RECORD_SAMPLE ; + event.sample.header.misc = sample.cpumode; + event.sample.header.size =sizeof (struct perf_event_header ); + +if (perf_session__deliver_synth_event (vpa->session, &event, &sample)) { +pr_debug ("Failed to create sample for dtl entry\n" ); +return -1 ; + } + +return 0 ; +} +static int powerpc_vpadtl_get_buffer (struct powerpc_vpadtl_queue *vpaq) {struct auxtrace_buffer *buffer = vpaq->buffer;
@@ -240,6 +278,141 @@ static int powerpc_vpadtl_decode(struct powerpc_vpadtl_queue *vpaq)return 1 ; } +static int powerpc_vpadtl_decode_all (struct powerpc_vpadtl_queue *vpaq) +{ +int ret; +unsigned char *buf; + +if (!vpaq->buf_len || vpaq->pkt_len == vpaq->size) { + ret =powerpc_vpadtl_get_buffer (vpaq); +if (ret <=0 ) +return ret; + } + +if (vpaq->buffer) { + buf = vpaq->buffer->data; + buf += vpaq->pkt_len; + vpaq->dtl = (struct powerpc_vpadtl_entry *)buf; +if ((long long )be64_to_cpu (vpaq->dtl->timebase) <=0 ) { +if (vpaq->pkt_len != dtl_entry_size && vpaq->buf_len) { + vpaq->pkt_len += dtl_entry_size; + vpaq->buf_len -= dtl_entry_size; + } +return -1 ; + } + vpaq->pkt_len += dtl_entry_size; + vpaq->buf_len -= dtl_entry_size; + }else { +return 0 ; + } + +return 1 ; +} + +static int powerpc_vpadtl_run_decoder (struct powerpc_vpadtl_queue *vpaq,u64 *timestamp) +{ +struct powerpc_vpadtl *vpa = vpaq->vpa; +struct powerpc_vpadtl_entry *record; +int ret; +unsigned long long vpaq_timestamp; + +while (1 ) { + ret =powerpc_vpadtl_decode_all (vpaq); +if (!ret) { +pr_debug ("All data in the queue has been processed.\n" ); +return 1 ; + } + +/* +* Error is detected when decoding VPA PMU trace. Continue to +* the next trace data and find out more dtl entries. +*/ +if (ret <0 ) +continue ; + + record = vpaq->dtl; + + vpaq_timestamp =powerpc_vpadtl_timestamp (vpaq); + +/* Update timestamp for the last record */ +if (vpaq_timestamp > vpaq->timestamp) + vpaq->timestamp = vpaq_timestamp; + +/* +* If the timestamp of the queue is later than timestamp of the +* coming perf event, bail out so can allow the perf event to +* be processed ahead. +*/ +if (vpaq->timestamp >= *timestamp) { + *timestamp = vpaq->timestamp; + vpaq->pkt_len -= dtl_entry_size; + vpaq->buf_len += dtl_entry_size; +return 0 ; + } + + ret =powerpc_vpadtl_sample (record, vpa, vpaq_timestamp, vpaq->cpu); +if (ret) +continue ; + } +return 0 ; +} + +/* +* For each of the PERF_RECORD_XX record, compare the timestamp +* of perf record with timestamp of top element in the auxtrace heap. +* Process the auxtrace queue if the timestamp of element from heap is +* lower than timestamp from entry in perf record. +* +* Update the timestamp of the auxtrace heap with the timestamp +* of last processed entry from the auxtrace buffer. +*/ +static int powerpc_vpadtl_process_queues (struct powerpc_vpadtl *vpa,u64 timestamp) +{ +unsigned int queue_nr; +u64 ts; +int ret; + +while (1 ) { +struct auxtrace_queue *queue; +struct powerpc_vpadtl_queue *vpaq; + +if (!vpa->heap.heap_cnt) +return 0 ; + +if (vpa->heap.heap_array[0 ].ordinal >= timestamp) +return 0 ; + + queue_nr = vpa->heap.heap_array[0 ].queue_nr; + queue = &vpa->queues.queue_array[queue_nr]; + vpaq = queue->priv; + +auxtrace_heap__pop (&vpa->heap); + +if (vpa->heap.heap_cnt) { + ts = vpa->heap.heap_array[0 ].ordinal +1 ; +if (ts > timestamp) + ts = timestamp; + }else { + ts = timestamp; + } + + ret =powerpc_vpadtl_run_decoder (vpaq, &ts); +if (ret <0 ) { +auxtrace_heap__add (&vpa->heap, queue_nr, ts); +return ret; + } + +if (!ret) { + ret =auxtrace_heap__add (&vpa->heap, queue_nr, ts); +if (ret <0 ) +return ret; + }else { + vpaq->on_heap = false; + } + } +return 0 ; +} +static struct powerpc_vpadtl_queue *powerpc_vpadtl__alloc_queue (struct powerpc_vpadtl *vpa,unsigned int queue_nr) {
@@ -353,6 +526,8 @@ static int powerpc_vpadtl_process_event(struct perf_session *session, err =powerpc_vpadtl__update_queues (vpa);if (err)return err; + + err =powerpc_vpadtl_process_queues (vpa, sample->time); }return err;
Signature · 1 line
2.47.1
PATCH v3 6/6 tools/perf: Enable perf script to present the DTL entries
In reply to Athira RajeevThe 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])---
Changelog:
v3:
Addressed review comments from Adrian
- Remove unnecessary line continuation and line length
- Return number of chars printed for perf_sample__fprintf_synth_vpadtl
- Added Tested by from Venkat
v2:
Addressed review comments from Adrian
- Removed default callback and used perf_sample__fprintf_synth_vpadtl
- fix build failure when using NO_AUXTRACE=1 by
adding code around HAVE_AUXTRACE_SUPPORT
tools/perf/builtin-script.c | 30 ++++++++++++++++++++++++++++++ tools/perf/util/event.h | 3 +++ 2 files changed, 33 insertions(+)
tools/perf/builtin-script.c +30 -0
@@ -43,6 +43,7 @@#include <linux/stringify.h> #include <linux/time64.h> #include <linux/zalloc.h> +#include <linux/unaligned.h> #include <sys/utsname.h> #include "asm/bug.h" #include "util/mem-events.h"
@@ -2003,6 +2004,33 @@ static int perf_sample__fprintf_synth_iflag_chg(struct perf_sample *sample, FILEreturn len +perf_sample__fprintf_pt_spacing (len, fp); } +#ifdef HAVE_AUXTRACE_SUPPORT +static int perf_sample__fprintf_synth_vpadtl (struct perf_sample *data,FILE *fp) +{ +struct powerpc_vpadtl_entry *dtl = (struct powerpc_vpadtl_entry *)data->raw_data; +int len; + + len =fprintf (fp,"timebase: %" PRIu64" dispatch_reason:%s, preempt_reason:%s,\n" +"enqueue_to_dispatch_time:%d, ready_to_enqueue_time:%d," +"waiting_to_ready_time:%d, processor_id: %d" , +get_unaligned_be64 (&dtl->timebase), + dispatch_reasons[dtl->dispatch_reason], + preempt_reasons[dtl->preempt_reason], +be32_to_cpu (dtl->enqueue_to_dispatch_time), +be32_to_cpu (dtl->ready_to_enqueue_time), +be32_to_cpu (dtl->waiting_to_ready_time), +be16_to_cpu (dtl->processor_id)); + +return len; +} +#else +static int perf_sample__fprintf_synth_vpadtl (struct perf_sample *data__maybe_unused , +FILE *fp__maybe_unused ) +{ +return 0 ; +} +#endif +static int perf_sample__fprintf_synth (struct perf_sample *sample,struct evsel *evsel,FILE *fp) {
@@ -2025,6 +2053,8 @@ static int perf_sample__fprintf_synth(struct perf_sample *sample,return perf_sample__fprintf_synth_evt (sample, fp);case PERF_SYNTH_INTEL_IFLAG_CHG :return perf_sample__fprintf_synth_iflag_chg (sample, fp); +case PERF_SYNTH_POWERPC_VPA_DTL : +return perf_sample__fprintf_synth_vpadtl (sample, fp);default :break ; }
tools/perf/util/event.h +3 -0
@@ -271,6 +271,9 @@ struct powerpc_vpadtl_entry {u64 srr1; }; +extern const char *dispatch_reasons[11 ]; +extern const char *preempt_reasons[10 ]; +static inline void *perf_synth__raw_data (void *p) {return p +4 ;
Signature · 1 line
2.47.1
Quoted 9 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
For all patches 1 to 6:
Quoted 155 lines
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
Kernel and tools patches is separated. Kernel patches are posted here :
V2: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
V3: https://lore.kernel.org/linux-perf-users/[email protected]/T/#tInfrastructure used
===================The VPA DTL PMU counters do not interrupt on overflow or generate any PMI interrupts. Therefore, hrtimer is used to poll the DTL data. The timer interval can be provided by user via
sample_periodfield in nano seconds. vpa dtl pmu has one hrtimer added per vpa-dtl pmu thread. DTL (Dispatch Trace Log) contains information about dispatch/preempt, enqueue time etc. We directly copy the DTL buffer data as part of auxiliary buffer and it will be processed later. This will avoid time taken to create samples in the kernel space. The PMU driver collecting Dispatch Trace Log (DTL) entries makes use of AUX support in perf infrastructure. On the tools side, this data is made available asPERF_RECORD_AUXTRACErecords.To corelate each DTL entry with other events across CPU's, an
auxtrace_queueis created for each CPU. Each auxtrace queue has a array/list of auxtrace buffers. All auxtrace queues is maintained in auxtrace heap. The queues are sorted based on timestamp. When the differentPERF_RECORD_XXrecords are processed, compare the timestamp of perf record with timestamp of top element in the auxtrace heap so that DTL events can be co-related with other events Process the auxtrace queue if the timestamp of element from heap is lower than timestamp from entry in perf record. Sometimes it could happen that one buffer is only partially processed. if the timestamp of occurrence of another event is more than currently processed element in the queue, it will move on to next perf record. So keep track of position of buffer to continue processing next time. Update the timestamp of the auxtrace heap with the timestamp of last processed entry from the auxtrace buffer.This infrastructure ensures dispatch trace log entries can be corelated and presented along with other events like sched.
vpa-dtl PMU example usage
# ls /sys/devices/vpa_dtl/ events format perf_event_mux_interval_ms power subsystem type ueventTo capture the DTL data using perf record:
# ./perf record -a -e sched:*,vpa_dtl/dtl_all/ -c 1000000000 sleep 1The result can be interpreted using perf report. Snippet of perf report -D:
# ./perf report -DThere are different
PERF_RECORD_XXrecords. In that records corresponding to auxtrace buffers includes:1.
PERF_RECORD_AUX
Conveys that new data is available in AUX area2.
PERF_RECORD_AUXTRACE_INFO
Describes offset and size of auxtrace data in the buffers3.
PERF_RECORD_AUXTRACE
This is the record that defines the auxtrace data which here in case of vpa-dtl pmu is dispatch trace log data.Snippet from perf report -D showing the
PERF_RECORD_AUXTRACEdump0 0
0x39b10[0x30]:PERF_RECORD_AUXTRACEsize:0x690offset: 0 ref: 0 idx: 0 tid: -1 cpu: 0 .
. ... VPA DTL PMU data: size 1680 bytes, entries is 35. 00000000: boot_tb: 21349649546353231, tb_freq: 512000000 . 00000030: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:7064, ready_to_enqueue_time:187, waiting_to_ready_time:6611773 . 00000060: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:146, ready_to_enqueue_time:0, waiting_to_ready_time:15359437 . 00000090: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:4868, ready_to_enqueue_time:232, waiting_to_ready_time:5100709 . 000000c0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:179, ready_to_enqueue_time:0, waiting_to_ready_time:30714243 . 000000f0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:197, ready_to_enqueue_time:0, waiting_to_ready_time:15350648 . 00000120: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:213, ready_to_enqueue_time:0, waiting_to_ready_time:15353446 . 00000150: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:212, ready_to_enqueue_time:0, waiting_to_ready_time:15355126 . 00000180: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:6368, ready_to_enqueue_time:164, waiting_to_ready_time:5104665Above is representation of dtl entry of below format:
struct dtl_entry { u8 dispatch_reason; u8 preempt_reason; u16 processor_id; u32 enqueue_to_dispatch_time; u32 ready_to_enqueue_time; u32 waiting_to_ready_time; u64 timebase; u64 fault_addr; u64 srr0; u64 srr1;};
First two fields represent the dispatch reason and preempt reason. The post procecssing of
PERF_RECORD_AUXTRACErecords will translate to meaninful data for user to consume.Visualize the dispatch trace log entries with perf report:
# ./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 report # Samples: 321 of event 'vpa-dtl' # Event count (approx.): 321 # # Children Self Command Shared Object Symbol # ........ ........ ....... ................. .............................. # 100.00% 100.00% swapper [kernel.kallsyms] [k] plpar_hcall_norets_notraceVisualize the dispatch trace log entries with perf script:
# ./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])Changelog is added for V3 in each individual patch
Thanks
AthiraAthira Rajeev (6):
tools/perf: Add basicCONFIG_AUXTRACEsupport for VPA pmu on powerpctools/perf: process auxtrace events and display in perf report -Dtools/perf: Add event name as vpa-dtl ofPERF_TYPE_SYNTHtype to
present DTL samples
tools/perf: Allocate and setup aux buffer queue to help co-relate with
other events across CPU's
tools/perf: Process the DTL entries in queue and deliver samplestools/perf: Enable perf script to present the DTL entriestools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/auxtrace.c | 103 ++++ tools/perf/builtin-script.c | 30 + tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/event.h | 20 + tools/perf/util/powerpc-vpadtl.c | 734 ++++++++++++++++++++++++ tools/perf/util/powerpc-vpadtl.h | 23 + 9 files changed, 917 insertions(+)
Quoted 3 lines
create mode 100644
tools/perf/arch/powerpc/util/auxtrace.ccreate mode 100644tools/perf/util/powerpc-vpadtl.ccreate mode 100644tools/perf/util/powerpc-vpadtl.h
Hi Athira,
I have tested the above patchset on the mainline kernel [ 6.17.0-rc2], it is working fine. Please add the tag below, for the entire series.
Thanks & Regards,
Tejas
Quoted 1 line
Quoted 12 lines · Adrian Hunter
Quoted 7 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
Quoted 6 lines
Quoted 2 lines
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
For all patches 1 to 6:
Reviewed-by Adrian Hunter <[email protected]>
Thanks Adrian for sharing Reviewed-by
Athira
Quoted 1 line
Quoted 166 lines · On 17 Sep 2025, at 2:31 PM, tejas05 <[email protected]> wrote:
Quoted 146 lines
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
Kernel and tools patches is separated. Kernel patches are posted here :
V2: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
V3: https://lore.kernel.org/linux-perf-users/[email protected]/T/#tInfrastructure used
===================The VPA DTL PMU counters do not interrupt on overflow or generate any PMI interrupts. Therefore, hrtimer is used to poll the DTL data. The timer interval can be provided by user via
sample_periodfield in nano seconds. vpa dtl pmu has one hrtimer added per vpa-dtl pmu thread. DTL (Dispatch Trace Log) contains information about dispatch/preempt, enqueue time etc. We directly copy the DTL buffer data as part of auxiliary buffer and it will be processed later. This will avoid time taken to create samples in the kernel space. The PMU driver collecting Dispatch Trace Log (DTL) entries makes use of AUX support in perf infrastructure. On the tools side, this data is made available asPERF_RECORD_AUXTRACErecords.To corelate each DTL entry with other events across CPU's, an
auxtrace_queueis created for each CPU. Each auxtrace queue has a array/list of auxtrace buffers. All auxtrace queues is maintained in auxtrace heap. The queues are sorted based on timestamp. When the differentPERF_RECORD_XXrecords are processed, compare the timestamp of perf record with timestamp of top element in the auxtrace heap so that DTL events can be co-related with other events Process the auxtrace queue if the timestamp of element from heap is lower than timestamp from entry in perf record. Sometimes it could happen that one buffer is only partially processed. if the timestamp of occurrence of another event is more than currently processed element in the queue, it will move on to next perf record. So keep track of position of buffer to continue processing next time. Update the timestamp of the auxtrace heap with the timestamp of last processed entry from the auxtrace buffer.This infrastructure ensures dispatch trace log entries can be corelated and presented along with other events like sched.
vpa-dtl PMU example usage
# ls /sys/devices/vpa_dtl/ events format perf_event_mux_interval_ms power subsystem type ueventTo capture the DTL data using perf record:
# ./perf record -a -e sched:*,vpa_dtl/dtl_all/ -c 1000000000 sleep 1The result can be interpreted using perf report. Snippet of perf report -D:
# ./perf report -DThere are different
PERF_RECORD_XXrecords. In that records corresponding to auxtrace buffers includes:1.
PERF_RECORD_AUX
Conveys that new data is available in AUX area2.
PERF_RECORD_AUXTRACE_INFO
Describes offset and size of auxtrace data in the buffers3.
PERF_RECORD_AUXTRACE
This is the record that defines the auxtrace data which here in case of vpa-dtl pmu is dispatch trace log data.Snippet from perf report -D showing the
PERF_RECORD_AUXTRACEdump0 0
0x39b10[0x30]:PERF_RECORD_AUXTRACEsize:0x690offset: 0 ref: 0 idx: 0 tid: -1 cpu: 0 .
. ... VPA DTL PMU data: size 1680 bytes, entries is 35. 00000000: boot_tb: 21349649546353231, tb_freq: 512000000 . 00000030: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:7064, ready_to_enqueue_time:187, waiting_to_ready_time:6611773 . 00000060: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:146, ready_to_enqueue_time:0, waiting_to_ready_time:15359437 . 00000090: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:4868, ready_to_enqueue_time:232, waiting_to_ready_time:5100709 . 000000c0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:179, ready_to_enqueue_time:0, waiting_to_ready_time:30714243 . 000000f0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:197, ready_to_enqueue_time:0, waiting_to_ready_time:15350648 . 00000120: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:213, ready_to_enqueue_time:0, waiting_to_ready_time:15353446 . 00000150: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:212, ready_to_enqueue_time:0, waiting_to_ready_time:15355126 . 00000180: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:6368, ready_to_enqueue_time:164, waiting_to_ready_time:5104665Above is representation of dtl entry of below format:
struct dtl_entry { u8 dispatch_reason; u8 preempt_reason; u16 processor_id; u32 enqueue_to_dispatch_time; u32 ready_to_enqueue_time; u32 waiting_to_ready_time; u64 timebase; u64 fault_addr; u64 srr0; u64 srr1;};
First two fields represent the dispatch reason and preempt reason. The post procecssing of
PERF_RECORD_AUXTRACErecords will translate to meaninful data for user to consume.Visualize the dispatch trace log entries with perf report:
# ./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 report # Samples: 321 of event 'vpa-dtl' # Event count (approx.): 321 # # Children Self Command Shared Object Symbol # ........ ........ ....... ................. .............................. # 100.00% 100.00% swapper [kernel.kallsyms] [k] plpar_hcall_norets_notraceVisualize the dispatch trace log entries with perf script:
# ./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])Changelog is added for V3 in each individual patch
Thanks
AthiraAthira Rajeev (6):
tools/perf: Add basicCONFIG_AUXTRACEsupport for VPA pmu on powerpctools/perf: process auxtrace events and display in perf report -Dtools/perf: Add event name as vpa-dtl ofPERF_TYPE_SYNTHtype to
present DTL samples
tools/perf: Allocate and setup aux buffer queue to help co-relate with
other events across CPU's
tools/perf: Process the DTL entries in queue and deliver samplestools/perf: Enable perf script to present the DTL entriesQuoted 13 lines
tools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/auxtrace.c | 103 ++++ tools/perf/builtin-script.c | 30 + tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/event.h | 20 + tools/perf/util/powerpc-vpadtl.c | 734 ++++++++++++++++++++++++ tools/perf/util/powerpc-vpadtl.h | 23 + 9 files changed, 917 insertions(+) create mode 100644 tools/perf/arch/powerpc/util/auxtrace.c create mode 100644 tools/perf/util/powerpc-vpadtl.c create mode 100644 tools/perf/util/powerpc-vpadtl.hHi Athira,
Quoted 7 lines
I have tested the above patchset on the mainline kernel [ 6.17.0-rc2], it is working fine. Please add the tag below, for the entire series.
Tested-by Tejas Manhas <[email protected]>Thanks & Regards,
Tejas
Thanks Tejas for testing the patch series
Athira
Quoted 12 lines · Adrian Hunter
Quoted 7 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
Quoted 6 lines
Quoted 2 lines
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
For all patches 1 to 6:
Reviewed-by Adrian Hunter <[email protected]>
Hi All,
Looking for further comments if any on this patchset.
The kernel side patches for this feature which was sent as separate series is pulled to powerpc tree by Maddy
If the tools side changes looks good, can we have this merged to perf tools tree ?
Thanks
Athira
Quoted 1 line
Quoted 17 lines · Athira Rajeev
Quoted 17 lines · Adrian Hunter
Quoted 9 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
For all patches 1 to 6:
Quoted 8 lines
Quoted 1 line
Reviewed-by Adrian Hunter <[email protected]>Hi All,
Looking for further comments if any on this patchset.
The kernel side patches for this feature which was sent as separate series is pulled to powerpc tree by MaddyIf the tools side changes looks good, can we have this merged to perf tools tree ?
Sure, I'll look at it soon now that the kernel part is merged.
- Arnaldo
Quoted 6 lines
Thanks
AthiraQuoted 1 line
- Arnaldo
Quoted 31 lines · Arnaldo Carvalho de Melo
Quoted 24 lines · Athira Rajeev
Quoted 12 lines · Adrian Hunter
Quoted 7 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
Quoted 6 lines
Quoted 2 lines
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
For all patches 1 to 6:
Reviewed-by Adrian Hunter <[email protected]>Hi All,
Looking for further comments if any on this patchset.
The kernel side patches for this feature which was sent as separate series is pulled to powerpc tree by Maddy
Quoted 6 lines
Quoted 1 line
If the tools side changes looks good, can we have this merged to perf tools tree ?
Sure, I'll look at it soon now that the kernel part is merged.
- Arnaldo
Sure, thanks Arnaldo
Athira
Quoted 8 lines
Quoted 6 lines
Thanks
AthiraQuoted 1 line
- Arnaldo
Arnaldo Carvalho de Melo
maintainerQuoted 10 lines · Athira Rajeev
Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 4 lines · Athira Rajeev
Looking for further comments if any on this patchset.
The kernel side patches for this feature which was sent as separate series is pulled to powerpc tree by MaddyIf the tools side changes looks good, can we have this merged to perf tools tree ?
Sure, I'll look at it soon now that the kernel part is merged.
Sure, thanks Arnaldo
Applied locally, build testing now.
- Arnaldo
Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · Athira Rajeev
Quoted 6 lines · Arnaldo Carvalho de Melo
Quoted 4 lines · Athira Rajeev
Looking for further comments if any on this patchset.
The kernel side patches for this feature which was sent as separate series is pulled to powerpc tree by MaddyIf the tools side changes looks good, can we have this merged to perf tools tree ?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Sure, I'll look at it soon now that the kernel part is merged.
Sure, thanks Arnaldo
Applied locally, build testing now.
- Arnaldo
Sure, thanks Arnaldo
Athira
Quoted 154 lines · Athira Rajeev
The pseries Shared Processor Logical Partition(SPLPAR) machines can retrieve a log of dispatch and preempt events from the hypervisor using data from Disptach Trace Log(DTL) buffer. With this information, user can retrieve when and why each dispatch & preempt has occurred. The vpa-dtl PMU exposes the Virtual Processor Area(VPA) DTL counters via perf.
- Patch 1 to 6 is perf tools side code changes to enable perf report/script on perf.data file
Kernel and tools patches is separated. Kernel patches are posted here :
V2: https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
V3: https://lore.kernel.org/linux-perf-users/[email protected]/T/#tInfrastructure used
===================The VPA DTL PMU counters do not interrupt on overflow or generate any PMI interrupts. Therefore, hrtimer is used to poll the DTL data. The timer interval can be provided by user via
sample_periodfield in nano seconds. vpa dtl pmu has one hrtimer added per vpa-dtl pmu thread. DTL (Dispatch Trace Log) contains information about dispatch/preempt, enqueue time etc. We directly copy the DTL buffer data as part of auxiliary buffer and it will be processed later. This will avoid time taken to create samples in the kernel space. The PMU driver collecting Dispatch Trace Log (DTL) entries makes use of AUX support in perf infrastructure. On the tools side, this data is made available asPERF_RECORD_AUXTRACErecords.To corelate each DTL entry with other events across CPU's, an
auxtrace_queueis created for each CPU. Each auxtrace queue has a array/list of auxtrace buffers. All auxtrace queues is maintained in auxtrace heap. The queues are sorted based on timestamp. When the differentPERF_RECORD_XXrecords are processed, compare the timestamp of perf record with timestamp of top element in the auxtrace heap so that DTL events can be co-related with other events Process the auxtrace queue if the timestamp of element from heap is lower than timestamp from entry in perf record. Sometimes it could happen that one buffer is only partially processed. if the timestamp of occurrence of another event is more than currently processed element in the queue, it will move on to next perf record. So keep track of position of buffer to continue processing next time. Update the timestamp of the auxtrace heap with the timestamp of last processed entry from the auxtrace buffer.This infrastructure ensures dispatch trace log entries can be corelated and presented along with other events like sched.
vpa-dtl PMU example usage
# ls /sys/devices/vpa_dtl/ events format perf_event_mux_interval_ms power subsystem type ueventTo capture the DTL data using perf record:
# ./perf record -a -e sched:*,vpa_dtl/dtl_all/ -c 1000000000 sleep 1The result can be interpreted using perf report. Snippet of perf report -D:
# ./perf report -DThere are different
PERF_RECORD_XXrecords. In that records corresponding to auxtrace buffers includes:1.
PERF_RECORD_AUX
Conveys that new data is available in AUX area2.
PERF_RECORD_AUXTRACE_INFO
Describes offset and size of auxtrace data in the buffers3.
PERF_RECORD_AUXTRACE
This is the record that defines the auxtrace data which here in case of vpa-dtl pmu is dispatch trace log data.Snippet from perf report -D showing the
PERF_RECORD_AUXTRACEdump0 0
0x39b10[0x30]:PERF_RECORD_AUXTRACEsize: 0x690 offset: 0 ref: 0 idx: 0 tid: -1 cpu: 0
.
. ... VPA DTL PMU data: size 1680 bytes, entries is 35
. 00000000:boot_tb: 21349649546353231,tb_freq: 512000000
. 00000030: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:7064, ready_to_enqueue_time:187, waiting_to_ready_time:6611773 . 00000060: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:146, ready_to_enqueue_time:0, waiting_to_ready_time:15359437 . 00000090: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:4868, ready_to_enqueue_time:232, waiting_to_ready_time:5100709 .000000c0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:179, ready_to_enqueue_time:0, waiting_to_ready_time:30714243 .000000f0: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:197, ready_to_enqueue_time:0, waiting_to_ready_time:15350648 . 00000120: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:213, ready_to_enqueue_time:0, waiting_to_ready_time:15353446 . 00000150: dispatch_reason:priv doorbell, preempt_reason:H_CEDE, enqueue_to_dispatch_time:212, ready_to_enqueue_time:0, waiting_to_ready_time:15355126 . 00000180: dispatch_reason:decrementer interrupt, preempt_reason:H_CEDE, enqueue_to_dispatch_time:6368, ready_to_enqueue_time:164, waiting_to_ready_time:5104665Above is representation of dtl entry of below format:
struct
dtl_entry{
u8dispatch_reason;
u8preempt_reason;
u16processor_id;
u32enqueue_to_dispatch_time;
u32ready_to_enqueue_time;
u32waiting_to_ready_time;
u64 timebase;
u64fault_addr;
u64 srr0;
u64 srr1;
};First two fields represent the dispatch reason and preempt reason. The post procecssing of
PERF_RECORD_AUXTRACErecords will translate to meaninful data for user to consume.Visualize the dispatch trace log entries with perf report:
# ./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 report # Samples: 321 of event 'vpa-dtl' # Event count (approx.): 321 # # Children Self Command Shared Object Symbol # ........ ........ ....... ................. .............................. # 100.00% 100.00% swapper [kernel.kallsyms] [k] plpar_hcall_norets_notraceVisualize the dispatch trace log entries with perf script:
# ./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])Changelog is added for V3 in each individual patch
Thanks
AthiraAthira Rajeev (6):
tools/perf: Add basicCONFIG_AUXTRACEsupport for VPA pmu on powerpctools/perf: process auxtrace events and display in perf report -Dtools/perf: Add event name as vpa-dtl ofPERF_TYPE_SYNTHtype to present DTL samples
tools/perf: Allocate and setup aux buffer queue to help co-relate with other events across CPU's
tools/perf: Process the DTL entries in queue and deliver samplestools/perf: Enable perf script to present the DTL entriestools/perf/arch/powerpc/util/Build | 1 +
tools/perf/arch/powerpc/util/auxtrace.c| 103 ++++ tools/perf/builtin-script.c | 30 + tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/event.h | 20 + tools/perf/util/powerpc-vpadtl.c | 734 ++++++++++++++++++++++++ tools/perf/util/powerpc-vpadtl.h | 23 +
Quoted 4 lines
9 files changed, 917 insertions(+)create mode 100644
tools/perf/arch/powerpc/util/auxtrace.ccreate mode 100644tools/perf/util/powerpc-vpadtl.ccreate mode 100644tools/perf/util/powerpc-vpadtl.h
I tested this on top of commit 0d97f2067c166eb4 (latest upstream master kernel) where the kernel side patches are already merged.
I added custom tracepoints to monitor CEDE hypercall events and also captured DTL CEDE events to check for interleaving when CEDE is triggered at specific intervals.
The events do interleave as expected (on Shared Logical Partition), and basic sanity checks confirm that it’s working as expected.
# ./perf script -i perf.data.cede
swapper 0 [010] 67.270684: power:cpu_idle_cede_enter: cpu_id=10
:32767 32767 [010] 67.270687: vpa-dtl: timebase: 4276378971776601 dispatch_reason:external_interrupt, preempt_reason:H_CEDE,
enqueue_to_dispatch_time:217, ready_to_enqueue_time:0,waiting_to_ready_time:3474, processor_id: 82 c0000000000eae44 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])
swapper 0 [010] 67.270710: power:cpu_idle_cede_enter: cpu_id=10
:32767 32767 [010] 67.270711: vpa-dtl: timebase: 4276378971788639 dispatch_reason:external_interrupt, preempt_reason:H_CEDE,
enqueue_to_dispatch_time:251, ready_to_enqueue_time:0,waiting_to_ready_time:43890, processor_id: 82 c0000000000eae44 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])
swapper 0 [010] 67.270809: power:cpu_idle_cede_enter: cpu_id=10
:32767 32767 [010] 67.270809: vpa-dtl: timebase: 4276378971839227 dispatch_reason:external_interrupt, preempt_reason:H_CEDE,
enqueue_to_dispatch_time:373, ready_to_enqueue_time:0,waiting_to_ready_time:45734, processor_id: 82 c0000000000eae44 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])
swapper 0 [010] 67.271012: power:cpu_idle_cede_enter: cpu_id=10
:32767 32767 [010] 67.271013: vpa-dtl: timebase: 4276378971943394 dispatch_reason:external_interrupt, preempt_reason:H_CEDE,
enqueue_to_dispatch_time:380, ready_to_enqueue_time:0,waiting_to_ready_time:46433, processor_id: 82 c0000000000eae44 plpar_hcall_norets_notrace+0x18 ([kernel.kallsyms])
...So for the entire series:
Thanks,
Aboorva