Skip to content

Commit e6328a7

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf tooling updates from Ingo Molnar: "Perf tooling updates and fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf annotate browser: Help for cycling thru hottest instructions with TAB/shift+TAB perf stat: Only auto-merge events that are PMU aliases perf test: Add test case for PERF_SAMPLE_PHYS_ADDR perf script: Support physical address perf mem: Support physical address perf sort: Add sort option for physical address perf tools: Support new sample type for physical address perf vendor events powerpc: Remove duplicate events perf intel-pt: Fix syntax in documentation of config option perf test powerpc: Fix 'Object code reading' test perf trace: Support syscall name globbing perf syscalltbl: Support glob matching on syscall names perf report: Calculate the average cycles of iterations
2 parents 33f82bd + 770e961 commit e6328a7

37 files changed

+368
-268
lines changed

tools/include/uapi/linux/perf_event.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ enum perf_event_sample_format {
139139
PERF_SAMPLE_IDENTIFIER = 1U << 16,
140140
PERF_SAMPLE_TRANSACTION = 1U << 17,
141141
PERF_SAMPLE_REGS_INTR = 1U << 18,
142+
PERF_SAMPLE_PHYS_ADDR = 1U << 19,
142143

143-
PERF_SAMPLE_MAX = 1U << 19, /* non-ABI */
144+
PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
144145
};
145146

146147
/*
@@ -814,6 +815,7 @@ enum perf_event_type {
814815
* { u64 transaction; } && PERF_SAMPLE_TRANSACTION
815816
* { u64 abi; # enum perf_sample_regs_abi
816817
* u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR
818+
* { u64 phys_addr;} && PERF_SAMPLE_PHYS_ADDR
817819
* };
818820
*/
819821
PERF_RECORD_SAMPLE = 9,

tools/perf/Documentation/intel-pt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ amended to take the number of elements as a parameter.
873873

874874
$ cat ~/.perfconfig
875875
[intel-pt]
876-
mispred-all
876+
mispred-all = on
877877

878878
$ perf record -e intel_pt//u ./sort 3000
879879
Bubble sorting array of 3000 elements

tools/perf/Documentation/perf-mem.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ OPTIONS
5959
--ldload::
6060
Specify desired latency for loads event.
6161

62+
-p::
63+
--phys-data::
64+
Record/Report sample physical addresses
65+
6266
SEE ALSO
6367
--------
6468
linkperf:perf-record[1], linkperf:perf-report[1]

tools/perf/Documentation/perf-record.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ OPTIONS
249249

250250
-d::
251251
--data::
252-
Record the sample addresses.
252+
Record the sample virtual addresses.
253+
254+
--phys-data::
255+
Record the sample physical addresses.
253256

254257
-T::
255258
--timestamp::

tools/perf/Documentation/perf-report.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ OPTIONS
137137
- mem: type of memory access for the data at the time of the sample
138138
- snoop: type of snoop (if any) for the data at the time of the sample
139139
- dcacheline: the cacheline the data address is on at the time of the sample
140+
- phys_daddr: physical address of data being executed on at the time of sample
140141

141142
And the default sort keys are changed to local_weight, mem, sym, dso,
142143
symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.

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/Documentation/perf-trace.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ OPTIONS
3737
--expr::
3838
--event::
3939
List of syscalls and other perf events (tracepoints, HW cache events,
40-
etc) to show.
40+
etc) to show. Globbing is supported, e.g.: "epoll_*", "*msg*", etc.
4141
See 'perf list' for a complete list of events.
4242
Prefixing with ! shows all syscalls but the ones specified. You may
4343
need to escape it.

tools/perf/builtin-mem.c

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct perf_mem {
2323
bool hide_unresolved;
2424
bool dump_raw;
2525
bool force;
26+
bool phys_addr;
2627
int operation;
2728
const char *cpu_list;
2829
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -101,6 +102,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
101102

102103
rec_argv[i++] = "-d";
103104

105+
if (mem->phys_addr)
106+
rec_argv[i++] = "--phys-data";
107+
104108
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
105109
if (!perf_mem_events[j].record)
106110
continue;
@@ -161,30 +165,60 @@ dump_raw_samples(struct perf_tool *tool,
161165
if (al.map != NULL)
162166
al.map->dso->hit = 1;
163167

164-
if (symbol_conf.field_sep) {
165-
fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64
166-
"%s0x%"PRIx64"%s%s:%s\n";
168+
if (mem->phys_addr) {
169+
if (symbol_conf.field_sep) {
170+
fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s0x%016"PRIx64
171+
"%s%"PRIu64"%s0x%"PRIx64"%s%s:%s\n";
172+
} else {
173+
fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
174+
"%s0x%016"PRIx64"%s%5"PRIu64"%s0x%06"PRIx64
175+
"%s%s:%s\n";
176+
symbol_conf.field_sep = " ";
177+
}
178+
179+
printf(fmt,
180+
sample->pid,
181+
symbol_conf.field_sep,
182+
sample->tid,
183+
symbol_conf.field_sep,
184+
sample->ip,
185+
symbol_conf.field_sep,
186+
sample->addr,
187+
symbol_conf.field_sep,
188+
sample->phys_addr,
189+
symbol_conf.field_sep,
190+
sample->weight,
191+
symbol_conf.field_sep,
192+
sample->data_src,
193+
symbol_conf.field_sep,
194+
al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
195+
al.sym ? al.sym->name : "???");
167196
} else {
168-
fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
169-
"%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n";
170-
symbol_conf.field_sep = " ";
171-
}
197+
if (symbol_conf.field_sep) {
198+
fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64
199+
"%s0x%"PRIx64"%s%s:%s\n";
200+
} else {
201+
fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
202+
"%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n";
203+
symbol_conf.field_sep = " ";
204+
}
172205

173-
printf(fmt,
174-
sample->pid,
175-
symbol_conf.field_sep,
176-
sample->tid,
177-
symbol_conf.field_sep,
178-
sample->ip,
179-
symbol_conf.field_sep,
180-
sample->addr,
181-
symbol_conf.field_sep,
182-
sample->weight,
183-
symbol_conf.field_sep,
184-
sample->data_src,
185-
symbol_conf.field_sep,
186-
al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
187-
al.sym ? al.sym->name : "???");
206+
printf(fmt,
207+
sample->pid,
208+
symbol_conf.field_sep,
209+
sample->tid,
210+
symbol_conf.field_sep,
211+
sample->ip,
212+
symbol_conf.field_sep,
213+
sample->addr,
214+
symbol_conf.field_sep,
215+
sample->weight,
216+
symbol_conf.field_sep,
217+
sample->data_src,
218+
symbol_conf.field_sep,
219+
al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
220+
al.sym ? al.sym->name : "???");
221+
}
188222
out_put:
189223
addr_location__put(&al);
190224
return 0;
@@ -224,7 +258,10 @@ static int report_raw_events(struct perf_mem *mem)
224258
if (ret < 0)
225259
goto out_delete;
226260

227-
printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
261+
if (mem->phys_addr)
262+
printf("# PID, TID, IP, ADDR, PHYS ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
263+
else
264+
printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
228265

229266
ret = perf_session__process_events(session);
230267

@@ -254,9 +291,16 @@ static int report_events(int argc, const char **argv, struct perf_mem *mem)
254291
* there is no weight (cost) associated with stores, so don't print
255292
* the column
256293
*/
257-
if (!(mem->operation & MEM_OPERATION_LOAD))
258-
rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr,"
259-
"dso_daddr,tlb,locked";
294+
if (!(mem->operation & MEM_OPERATION_LOAD)) {
295+
if (mem->phys_addr)
296+
rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr,"
297+
"dso_daddr,tlb,locked,phys_daddr";
298+
else
299+
rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr,"
300+
"dso_daddr,tlb,locked";
301+
} else if (mem->phys_addr)
302+
rep_argv[i++] = "--sort=local_weight,mem,sym,dso,symbol_daddr,"
303+
"dso_daddr,snoop,tlb,locked,phys_daddr";
260304

261305
for (j = 1; j < argc; j++, i++)
262306
rep_argv[i] = argv[j];
@@ -373,6 +417,7 @@ int cmd_mem(int argc, const char **argv)
373417
"separator for columns, no spaces will be added"
374418
" between columns '.' is reserved."),
375419
OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"),
420+
OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report sample physical addresses"),
376421
OPT_END()
377422
};
378423
const char *const mem_subcommands[] = { "record", "report", NULL };

tools/perf/builtin-record.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,8 @@ static struct option __record_options[] = {
16041604
OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat,
16051605
"per thread counts"),
16061606
OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample addresses"),
1607+
OPT_BOOLEAN(0, "phys-data", &record.opts.sample_phys_addr,
1608+
"Record the sample physical addresses"),
16071609
OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"),
16081610
OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time,
16091611
&record.opts.sample_time_set,

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)