lkml.org 
[lkml]   [2022]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 9/9] perf script: Support Retire Latency
Date
From: Kan Liang <kan.liang@linux.intel.com>

The Retire Latency field is added in the var3_w of the
PERF_SAMPLE_WEIGHT_STRUCT. The Retire Latency reports the number of
elapsed core clocks between the retirement of the instruction
indicated by the Instruction Pointer field of the PEBS record and the
retirement of the prior instruction. That's quite useful to display
the information with perf script.

Add a new field retire_lat for the Retire Latency information.

Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
tools/perf/builtin-script.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7ca238277d83..071ffdff1980 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -127,6 +127,7 @@ enum perf_output_field {
PERF_OUTPUT_BRSTACKINSNLEN = 1ULL << 36,
PERF_OUTPUT_MACHINE_PID = 1ULL << 37,
PERF_OUTPUT_VCPU = 1ULL << 38,
+ PERF_OUTPUT_RETIRE_LAT = 1ULL << 39,
};

struct perf_script {
@@ -197,6 +198,7 @@ struct output_option {
{.str = "brstackinsnlen", .field = PERF_OUTPUT_BRSTACKINSNLEN},
{.str = "machine_pid", .field = PERF_OUTPUT_MACHINE_PID},
{.str = "vcpu", .field = PERF_OUTPUT_VCPU},
+ {.str = "retire_lat", .field = PERF_OUTPUT_RETIRE_LAT},
};

enum {
@@ -272,7 +274,7 @@ static struct {
PERF_OUTPUT_ADDR | PERF_OUTPUT_DATA_SRC |
PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR |
PERF_OUTPUT_DATA_PAGE_SIZE | PERF_OUTPUT_CODE_PAGE_SIZE |
- PERF_OUTPUT_INS_LAT,
+ PERF_OUTPUT_INS_LAT | PERF_OUTPUT_RETIRE_LAT,

.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
},
@@ -539,6 +541,10 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_INS_LAT))
return -EINVAL;

+ if (PRINT_FIELD(RETIRE_LAT) &&
+ evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_RETIRE_LAT))
+ return -EINVAL;
+
return 0;
}

@@ -2175,6 +2181,9 @@ static void process_event(struct perf_script *script,
if (PRINT_FIELD(INS_LAT))
fprintf(fp, "%16" PRIu16, sample->ins_lat);

+ if (PRINT_FIELD(RETIRE_LAT))
+ fprintf(fp, "%16" PRIu16, sample->retire_lat);
+
if (PRINT_FIELD(IP)) {
struct callchain_cursor *cursor = NULL;

@@ -3849,7 +3858,7 @@ int cmd_script(int argc, const char **argv)
"brstacksym,flags,data_src,weight,bpf-output,brstackinsn,"
"brstackinsnlen,brstackoff,callindent,insn,insnlen,synth,"
"phys_addr,metric,misc,srccode,ipc,tod,data_page_size,"
- "code_page_size,ins_lat",
+ "code_page_size,ins_lat,retire_lat",
parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
--
2.35.1
\
 
 \ /
  Last update: 2022-12-01 20:58    [W:0.050 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site