Skip to content

Commit 17f248a

Browse files
Kan Liangacmel
authored andcommitted
perf script: Support Retire Latency
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 <[email protected]> Signed-off-by: Kan Liang <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d7d213e commit 17f248a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/perf/builtin-script.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ enum perf_output_field {
132132
PERF_OUTPUT_MACHINE_PID = 1ULL << 37,
133133
PERF_OUTPUT_VCPU = 1ULL << 38,
134134
PERF_OUTPUT_CGROUP = 1ULL << 39,
135+
PERF_OUTPUT_RETIRE_LAT = 1ULL << 40,
135136
};
136137

137138
struct perf_script {
@@ -203,6 +204,7 @@ struct output_option {
203204
{.str = "machine_pid", .field = PERF_OUTPUT_MACHINE_PID},
204205
{.str = "vcpu", .field = PERF_OUTPUT_VCPU},
205206
{.str = "cgroup", .field = PERF_OUTPUT_CGROUP},
207+
{.str = "retire_lat", .field = PERF_OUTPUT_RETIRE_LAT},
206208
};
207209

208210
enum {
@@ -278,7 +280,7 @@ static struct {
278280
PERF_OUTPUT_ADDR | PERF_OUTPUT_DATA_SRC |
279281
PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR |
280282
PERF_OUTPUT_DATA_PAGE_SIZE | PERF_OUTPUT_CODE_PAGE_SIZE |
281-
PERF_OUTPUT_INS_LAT,
283+
PERF_OUTPUT_INS_LAT | PERF_OUTPUT_RETIRE_LAT,
282284

283285
.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
284286
},
@@ -551,6 +553,10 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session)
551553
return -EINVAL;
552554
}
553555

556+
if (PRINT_FIELD(RETIRE_LAT) &&
557+
evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_RETIRE_LAT))
558+
return -EINVAL;
559+
554560
return 0;
555561
}
556562

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

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

@@ -3877,7 +3886,7 @@ int cmd_script(int argc, const char **argv)
38773886
"brstacksym,flags,data_src,weight,bpf-output,brstackinsn,"
38783887
"brstackinsnlen,brstackoff,callindent,insn,insnlen,synth,"
38793888
"phys_addr,metric,misc,srccode,ipc,tod,data_page_size,"
3880-
"code_page_size,ins_lat,machine_pid,vcpu,cgroup",
3889+
"code_page_size,ins_lat,machine_pid,vcpu,cgroup,retire_lat",
38813890
parse_output_fields),
38823891
OPT_BOOLEAN('a', "all-cpus", &system_wide,
38833892
"system-wide collection from all CPUs"),

0 commit comments

Comments
 (0)