Skip to content

Commit 49d58f0

Browse files
kliang2acmel
authored andcommitted
perf script: Support physical address
Display the physical address at the tail if it is available. Signed-off-by: Kan Liang <[email protected]> Tested-by: Jiri Olsa <[email protected]> Acked-by: Stephane Eranian <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c35aeb9 commit 49d58f0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tools/perf/Documentation/perf-script.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ OPTIONS
117117
Comma separated list of fields to print. Options are:
118118
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
119119
srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn, brstackoff,
120-
callindent, insn, insnlen, synth.
120+
callindent, insn, insnlen, synth, phys_addr.
121121
Field list can be prepended with the type, trace, sw or hw,
122122
to indicate to which event type the field list applies.
123123
e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace

tools/perf/builtin-script.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum perf_output_field {
8787
PERF_OUTPUT_BRSTACKINSN = 1U << 23,
8888
PERF_OUTPUT_BRSTACKOFF = 1U << 24,
8989
PERF_OUTPUT_SYNTH = 1U << 25,
90+
PERF_OUTPUT_PHYS_ADDR = 1U << 26,
9091
};
9192

9293
struct output_option {
@@ -119,6 +120,7 @@ struct output_option {
119120
{.str = "brstackinsn", .field = PERF_OUTPUT_BRSTACKINSN},
120121
{.str = "brstackoff", .field = PERF_OUTPUT_BRSTACKOFF},
121122
{.str = "synth", .field = PERF_OUTPUT_SYNTH},
123+
{.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR},
122124
};
123125

124126
enum {
@@ -175,7 +177,8 @@ static struct {
175177
PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
176178
PERF_OUTPUT_SYM | PERF_OUTPUT_DSO |
177179
PERF_OUTPUT_PERIOD | PERF_OUTPUT_ADDR |
178-
PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT,
180+
PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT |
181+
PERF_OUTPUT_PHYS_ADDR,
179182

180183
.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
181184
},
@@ -382,6 +385,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
382385
PERF_OUTPUT_IREGS))
383386
return -EINVAL;
384387

388+
if (PRINT_FIELD(PHYS_ADDR) &&
389+
perf_evsel__check_stype(evsel, PERF_SAMPLE_PHYS_ADDR, "PHYS_ADDR",
390+
PERF_OUTPUT_PHYS_ADDR))
391+
return -EINVAL;
392+
385393
return 0;
386394
}
387395

@@ -1446,6 +1454,9 @@ static void process_event(struct perf_script *script,
14461454
if (perf_evsel__is_bpf_output(evsel) && PRINT_FIELD(BPF_OUTPUT))
14471455
print_sample_bpf_output(sample);
14481456
print_insn(sample, attr, thread, machine);
1457+
1458+
if (PRINT_FIELD(PHYS_ADDR))
1459+
printf("%16" PRIx64, sample->phys_addr);
14491460
printf("\n");
14501461
}
14511462

@@ -2729,7 +2740,7 @@ int cmd_script(int argc, const char **argv)
27292740
"Valid types: hw,sw,trace,raw,synth. "
27302741
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
27312742
"addr,symoff,period,iregs,brstack,brstacksym,flags,"
2732-
"bpf-output,callindent,insn,insnlen,brstackinsn,synth",
2743+
"bpf-output,callindent,insn,insnlen,brstackinsn,synth,phys_addr",
27332744
parse_output_fields),
27342745
OPT_BOOLEAN('a', "all-cpus", &system_wide,
27352746
"system-wide collection from all CPUs"),

0 commit comments

Comments
 (0)