Skip to content

Commit cfb104c

Browse files
committed
Merge tag 'perf-core-for-mingo-5.4-20190816' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo: report/script/trace/top: Arnaldo Carvalho de Melo: - Allow specifying marker events demarcating when to consider the other events, i.e. one now can state something like: # perf probe kernel_function # perf record -e cycles,probe:kernel_function And then, in 'perf script' or 'perf report' say: # perf report --switch-on=probe:kernel_function And then the cycles event samples will be considered only after we find the first probe:kernel_function event. There is also --switch-off=event, to make it stop considering events out of some window, say to avoid some winding down of a workload. The same can be done with the "live mode" tools: 'perf top' and 'perf trace'. There are examples in the cset comments showing how to use it with SDT events in things like 'systemtap', that have those tracepoint-like events for the start/end of passes, etc. Another example involves selecting scheduler events + entry/exit of a syscall, using the syscalls tracepoints, one can then see the scheduler events that take place while that syscall is being processed. In the future this should be possible in record/top/trace via eBPF where the perf tools would hook into the marker events and enable events put in place but not enabled when the on/off conditions are the desired ones, reducing the amount of events sampled, but this userspace only solution should be good enough for many scenarios. perf vendor events intel: Haiyan Song: - Add Tremontx event file v1.02. unwind: John Keeping: - Fix callchain unwinding when tid != pid, that was working only for the thread group leader. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQR2GiIUctdOfX2qHhGyPKLppCJ+JwUCXVcMPgAKCRCyPKLppCJ+ J6ipAP9F5+TitM1zln/wUUP7/Ug4ZPDsdvA+Ggc8x0Ns7URJQwD/RHk43MgDC1fG VXbpQ7byj339Wo7SpjadzLl9xPlh/Qw= =IaYE -----END PGP SIGNATURE----- commit e273621 Author: John Keeping <john@metanate.com> Date: Thu Aug 15 11:01:46 2019 +0100 perf unwind: Remove unnecessary test If dwarf_callchain_users is false, then unwind__prepare_access() will not set unwind_libunwind_ops so the remaining test here is sufficient. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: john keeping <john@metanate.com> Link: http://lkml.kernel.org/r/20190815100146.28842-3-john@metanate.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index b843f9d..6499b22 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c @@ -69,18 +69,12 @@ int unwind__prepare_access(struct map_groups *mg, struct map *map, void unwind__flush_access(struct map_groups *mg) { - if (!dwarf_callchain_users) - return; - if (mg->unwind_libunwind_ops) mg->unwind_libunwind_ops->flush_access(mg); } void unwind__finish_access(struct map_groups *mg) { - if (!dwarf_callchain_users) - return; - if (mg->unwind_libunwind_ops) mg->unwind_libunwind_ops->finish_access(mg); }
2 parents 4511708 + e273621 commit cfb104c

29 files changed

Lines changed: 1158 additions & 55 deletions

‎tools/perf/Documentation/perf-report.txt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,23 @@ OPTIONS
438438

439439
perf report --time 0%-10%,30%-40%
440440

441+
--switch-on EVENT_NAME::
442+
Only consider events after this event is found.
443+
444+
This may be interesting to measure a workload only after some initialization
445+
phase is over, i.e. insert a perf probe at that point and then using this
446+
option with that probe.
447+
448+
--switch-off EVENT_NAME::
449+
Stop considering events after this event is found.
450+
451+
--show-on-off-events::
452+
Show the --switch-on/off events too. This has no effect in 'perf report' now
453+
but probably we'll make the default not to show the switch-on/off events
454+
on the --group mode and if there is only one event besides the off/on ones,
455+
go straight to the histogram browser, just like 'perf report' with no events
456+
explicitely specified does.
457+
441458
--itrace::
442459
Options for decoding instruction tracing data. The options are:
443460

‎tools/perf/Documentation/perf-script.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@ include::itrace.txt[]
417417
For itrace only show specified functions and their callees for
418418
itrace. Multiple functions can be separated by comma.
419419

420+
--switch-on EVENT_NAME::
421+
Only consider events after this event is found.
422+
423+
--switch-off EVENT_NAME::
424+
Stop considering events after this event is found.
425+
426+
--show-on-off-events::
427+
Show the --switch-on/off events too.
428+
420429
SEE ALSO
421430
--------
422431
linkperf:perf-record[1], linkperf:perf-script-perl[1],

‎tools/perf/Documentation/perf-top.txt‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,44 @@ Default is to monitor all CPUS.
266266
Record events of type PERF_RECORD_NAMESPACES and display it with the
267267
'cgroup_id' sort key.
268268

269+
--switch-on EVENT_NAME::
270+
Only consider events after this event is found.
271+
272+
E.g.:
273+
274+
Find out where broadcast packets are handled
275+
276+
perf probe -L icmp_rcv
277+
278+
Insert a probe there:
279+
280+
perf probe icmp_rcv:59
281+
282+
Start perf top and ask it to only consider the cycles events when a
283+
broadcast packet arrives This will show a menu with two entries and
284+
will start counting when a broadcast packet arrives:
285+
286+
perf top -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
287+
288+
Alternatively one can ask for --group and then two overhead columns
289+
will appear, the first for cycles and the second for the switch-on event.
290+
291+
perf top --group -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
292+
293+
This may be interesting to measure a workload only after some initialization
294+
phase is over, i.e. insert a perf probe at that point and use the above
295+
examples replacing probe:icmp_rcv with the just-after-init probe.
296+
297+
--switch-off EVENT_NAME::
298+
Stop considering events after this event is found.
299+
300+
--show-on-off-events::
301+
Show the --switch-on/off events too. This has no effect in 'perf top' now
302+
but probably we'll make the default not to show the switch-on/off events
303+
on the --group mode and if there is only one event besides the off/on ones,
304+
go straight to the histogram browser, just like 'perf top' with no events
305+
explicitely specified does.
306+
269307

270308
INTERACTIVE PROMPTING KEYS
271309
--------------------------

‎tools/perf/Documentation/perf-trace.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
176176
only at exit time or when a syscall is interrupted, i.e. in those cases this
177177
option is equivalent to the number of lines printed.
178178

179+
--switch-on EVENT_NAME::
180+
Only consider events after this event is found.
181+
182+
--switch-off EVENT_NAME::
183+
Stop considering events after this event is found.
184+
185+
--show-on-off-events::
186+
Show the --switch-on/off events too.
187+
179188
--max-stack::
180189
Set the stack depth limit when parsing the callchain, anything
181190
beyond the specified depth will be ignored. Note that at this point

‎tools/perf/builtin-report.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "util/debug.h"
2626
#include "util/evlist.h"
2727
#include "util/evsel.h"
28+
#include "util/evswitch.h"
2829
#include "util/header.h"
2930
#include "util/session.h"
3031
#include "util/tool.h"
@@ -60,6 +61,7 @@
6061
struct report {
6162
struct perf_tool tool;
6263
struct perf_session *session;
64+
struct evswitch evswitch;
6365
bool use_tui, use_gtk, use_stdio;
6466
bool show_full_info;
6567
bool show_threads;
@@ -243,6 +245,9 @@ static int process_sample_event(struct perf_tool *tool,
243245
return 0;
244246
}
245247

248+
if (evswitch__discard(&rep->evswitch, evsel))
249+
return 0;
250+
246251
if (machine__resolve(machine, &al, sample) < 0) {
247252
pr_debug("problem processing %d event, skipping it.\n",
248253
event->header.type);
@@ -1189,6 +1194,7 @@ int cmd_report(int argc, const char **argv)
11891194
OPT_CALLBACK(0, "time-quantum", &symbol_conf.time_quantum, "time (ms|us|ns|s)",
11901195
"Set time quantum for time sort key (default 100ms)",
11911196
parse_time_quantum),
1197+
OPTS_EVSWITCH(&report.evswitch),
11921198
OPT_END()
11931199
};
11941200
struct perf_data data = {
@@ -1257,6 +1263,10 @@ int cmd_report(int argc, const char **argv)
12571263
if (session == NULL)
12581264
return -1;
12591265

1266+
ret = evswitch__init(&report.evswitch, session->evlist, stderr);
1267+
if (ret)
1268+
return ret;
1269+
12601270
if (zstd_init(&(session->zstd_data), 0) < 0)
12611271
pr_warning("Decompression initialization failed. Reported data may be incomplete.\n");
12621272

‎tools/perf/builtin-script.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "util/trace-event.h"
1717
#include "util/evlist.h"
1818
#include "util/evsel.h"
19+
#include "util/evswitch.h"
1920
#include "util/sort.h"
2021
#include "util/data.h"
2122
#include "util/auxtrace.h"
@@ -1628,6 +1629,7 @@ struct perf_script {
16281629
bool show_bpf_events;
16291630
bool allocated;
16301631
bool per_event_dump;
1632+
struct evswitch evswitch;
16311633
struct perf_cpu_map *cpus;
16321634
struct perf_thread_map *threads;
16331635
int name_width;
@@ -1805,6 +1807,9 @@ static void process_event(struct perf_script *script,
18051807
if (!show_event(sample, evsel, thread, al))
18061808
return;
18071809

1810+
if (evswitch__discard(&script->evswitch, evsel))
1811+
return;
1812+
18081813
++es->samples;
18091814

18101815
perf_sample__fprintf_start(sample, thread, evsel,
@@ -3538,6 +3543,7 @@ int cmd_script(int argc, const char **argv)
35383543
"file", "file saving guest os /proc/kallsyms"),
35393544
OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules,
35403545
"file", "file saving guest os /proc/modules"),
3546+
OPTS_EVSWITCH(&script.evswitch),
35413547
OPT_END()
35423548
};
35433549
const char * const script_subcommands[] = { "record", "report", NULL };
@@ -3862,6 +3868,10 @@ int cmd_script(int argc, const char **argv)
38623868
script.range_num);
38633869
}
38643870

3871+
err = evswitch__init(&script.evswitch, session->evlist, stderr);
3872+
if (err)
3873+
goto out_delete;
3874+
38653875
err = __cmd_script(&script);
38663876

38673877
flush_scripting();

‎tools/perf/builtin-top.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,11 @@ static int deliver_event(struct ordered_events *qe,
11481148
evsel = perf_evlist__id2evsel(session->evlist, sample.id);
11491149
assert(evsel != NULL);
11501150

1151-
if (event->header.type == PERF_RECORD_SAMPLE)
1151+
if (event->header.type == PERF_RECORD_SAMPLE) {
1152+
if (evswitch__discard(&top->evswitch, evsel))
1153+
return 0;
11521154
++top->samples;
1155+
}
11531156

11541157
switch (sample.cpumode) {
11551158
case PERF_RECORD_MISC_USER:
@@ -1534,6 +1537,7 @@ int cmd_top(int argc, const char **argv)
15341537
"number of thread to run event synthesize"),
15351538
OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces,
15361539
"Record namespaces events"),
1540+
OPTS_EVSWITCH(&top.evswitch),
15371541
OPT_END()
15381542
};
15391543
struct evlist *sb_evlist = NULL;
@@ -1567,6 +1571,10 @@ int cmd_top(int argc, const char **argv)
15671571
goto out_delete_evlist;
15681572
}
15691573

1574+
status = evswitch__init(&top.evswitch, top.evlist, stderr);
1575+
if (status)
1576+
goto out_delete_evlist;
1577+
15701578
if (symbol_conf.report_hierarchy) {
15711579
/* disable incompatible options */
15721580
symbol_conf.event_group = false;

‎tools/perf/builtin-trace.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "util/env.h"
2828
#include "util/event.h"
2929
#include "util/evlist.h"
30+
#include "util/evswitch.h"
3031
#include <subcmd/exec-cmd.h>
3132
#include "util/machine.h"
3233
#include "util/map.h"
@@ -106,6 +107,7 @@ struct trace {
106107
unsigned long nr_events;
107108
unsigned long nr_events_printed;
108109
unsigned long max_events;
110+
struct evswitch evswitch;
109111
struct strlist *ev_qualifier;
110112
struct {
111113
size_t nr;
@@ -2680,6 +2682,9 @@ static void trace__handle_event(struct trace *trace, union perf_event *event, st
26802682
return;
26812683
}
26822684

2685+
if (evswitch__discard(&trace->evswitch, evsel))
2686+
return;
2687+
26832688
trace__set_base_time(trace, evsel, sample);
26842689

26852690
if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
@@ -4157,6 +4162,7 @@ int cmd_trace(int argc, const char **argv)
41574162
OPT_UINTEGER('D', "delay", &trace.opts.initial_delay,
41584163
"ms to wait before starting measurement after program "
41594164
"start"),
4165+
OPTS_EVSWITCH(&trace.evswitch),
41604166
OPT_END()
41614167
};
41624168
bool __maybe_unused max_stack_user_set = true;
@@ -4380,6 +4386,10 @@ int cmd_trace(int argc, const char **argv)
43804386
}
43814387
}
43824388

4389+
err = evswitch__init(&trace.evswitch, trace.evlist, stderr);
4390+
if (err)
4391+
goto out_close;
4392+
43834393
err = target__validate(&trace.opts.target);
43844394
if (err) {
43854395
target__strerror(&trace.opts.target, err, bf, sizeof(bf));

‎tools/perf/pmu-events/arch/x86/mapfile.csv‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ GenuineIntel-6-55-[01234],v1,skylakex,core
3535
GenuineIntel-6-55-[56789ABCDEF],v1,cascadelakex,core
3636
GenuineIntel-6-7D,v1,icelake,core
3737
GenuineIntel-6-7E,v1,icelake,core
38+
GenuineIntel-6-86,v1,tremontx,core
3839
AuthenticAMD-23-[[:xdigit:]]+,v1,amdfam17h,core
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[
2+
{
3+
"CollectPEBSRecord": "2",
4+
"PublicDescription": "Counts cacheable memory requests that miss in the the Last Level Cache. Requests include Demand Loads, Reads for Ownership(RFO), Instruction fetches and L1 HW prefetches. If the platform has an L3 cache, last level cache is the L3, otherwise it is the L2.",
5+
"EventCode": "0x2e",
6+
"Counter": "0,1,2,3",
7+
"UMask": "0x41",
8+
"PEBScounters": "0,1,2,3",
9+
"EventName": "LONGEST_LAT_CACHE.MISS",
10+
"PDIR_COUNTER": "na",
11+
"SampleAfterValue": "200003",
12+
"BriefDescription": "Counts memory requests originating from the core that miss in the last level cache. If the platform has an L3 cache, last level cache is the L3, otherwise it is the L2."
13+
},
14+
{
15+
"CollectPEBSRecord": "2",
16+
"PublicDescription": "Counts cacheable memory requests that access the Last Level Cache. Requests include Demand Loads, Reads for Ownership(RFO), Instruction fetches and L1 HW prefetches. If the platform has an L3 cache, last level cache is the L3, otherwise it is the L2.",
17+
"EventCode": "0x2e",
18+
"Counter": "0,1,2,3",
19+
"UMask": "0x4f",
20+
"PEBScounters": "0,1,2,3",
21+
"EventName": "LONGEST_LAT_CACHE.REFERENCE",
22+
"PDIR_COUNTER": "na",
23+
"SampleAfterValue": "200003",
24+
"BriefDescription": "Counts memory requests originating from the core that reference a cache line in the last level cache. If the platform has an L3 cache, last level cache is the L3, otherwise it is the L2."
25+
},
26+
{
27+
"PEBS": "1",
28+
"CollectPEBSRecord": "2",
29+
"PublicDescription": "Counts the number of load uops retired. This event is Precise Event capable",
30+
"EventCode": "0xd0",
31+
"Counter": "0,1,2,3",
32+
"UMask": "0x81",
33+
"PEBScounters": "0,1,2,3",
34+
"EventName": "MEM_UOPS_RETIRED.ALL_LOADS",
35+
"SampleAfterValue": "200003",
36+
"BriefDescription": "Counts the number of load uops retired.",
37+
"Data_LA": "1"
38+
},
39+
{
40+
"PEBS": "1",
41+
"CollectPEBSRecord": "2",
42+
"PublicDescription": "Counts the number of store uops retired. This event is Precise Event capable",
43+
"EventCode": "0xd0",
44+
"Counter": "0,1,2,3",
45+
"UMask": "0x82",
46+
"PEBScounters": "0,1,2,3",
47+
"EventName": "MEM_UOPS_RETIRED.ALL_STORES",
48+
"SampleAfterValue": "200003",
49+
"BriefDescription": "Counts the number of store uops retired.",
50+
"Data_LA": "1"
51+
},
52+
{
53+
"PEBS": "1",
54+
"CollectPEBSRecord": "2",
55+
"EventCode": "0xd1",
56+
"Counter": "0,1,2,3",
57+
"UMask": "0x1",
58+
"PEBScounters": "0,1,2,3",
59+
"EventName": "MEM_LOAD_UOPS_RETIRED.L1_HIT",
60+
"SampleAfterValue": "200003",
61+
"BriefDescription": "Counts the number of load uops retired that hit the level 1 data cache",
62+
"Data_LA": "1"
63+
},
64+
{
65+
"PEBS": "1",
66+
"CollectPEBSRecord": "2",
67+
"EventCode": "0xd1",
68+
"Counter": "0,1,2,3",
69+
"UMask": "0x2",
70+
"PEBScounters": "0,1,2,3",
71+
"EventName": "MEM_LOAD_UOPS_RETIRED.L2_HIT",
72+
"SampleAfterValue": "200003",
73+
"BriefDescription": "Counts the number of load uops retired that hit in the level 2 cache",
74+
"Data_LA": "1"
75+
},
76+
{
77+
"PEBS": "1",
78+
"CollectPEBSRecord": "2",
79+
"EventCode": "0xd1",
80+
"Counter": "0,1,2,3",
81+
"UMask": "0x4",
82+
"PEBScounters": "0,1,2,3",
83+
"EventName": "MEM_LOAD_UOPS_RETIRED.L3_HIT",
84+
"SampleAfterValue": "200003",
85+
"BriefDescription": "Counts the number of load uops retired that miss in the level 3 cache"
86+
},
87+
{
88+
"PEBS": "1",
89+
"CollectPEBSRecord": "2",
90+
"EventCode": "0xd1",
91+
"Counter": "0,1,2,3",
92+
"UMask": "0x8",
93+
"PEBScounters": "0,1,2,3",
94+
"EventName": "MEM_LOAD_UOPS_RETIRED.L1_MISS",
95+
"SampleAfterValue": "200003",
96+
"BriefDescription": "Counts the number of load uops retired that miss in the level 1 data cache",
97+
"Data_LA": "1"
98+
},
99+
{
100+
"PEBS": "1",
101+
"CollectPEBSRecord": "2",
102+
"EventCode": "0xd1",
103+
"Counter": "0,1,2,3",
104+
"UMask": "0x10",
105+
"PEBScounters": "0,1,2,3",
106+
"EventName": "MEM_LOAD_UOPS_RETIRED.L2_MISS",
107+
"SampleAfterValue": "200003",
108+
"BriefDescription": "Counts the number of load uops retired that miss in the level 2 cache",
109+
"Data_LA": "1"
110+
}
111+
]

0 commit comments

Comments
 (0)