Skip to content

Commit f913f3a

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-4.11-20170111' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: New features: - Add more triggers to switch the output file (perf.data.TIMESTAMP). Now, in addition to switching to a different output file when receiving a SIGUSR2, one can also specify file size and time based triggers: perf record -a --switch-output=signal is equivalent to what we had before: perf record -a --switch-output While we can also ask for the file to be "sliced" by size, taking into account that that will happen only when we get woken up by the kernel, i.e. one has to take into account the --mmap-pages (the size of the perf mmap ring buffer): perf record -a --switch-output=2G will break the perf.data output into multiple files limited to 2GB of samples, right when generating the output. For time based samples, alert() will be used, so to have 1 minute limited perf.data output files: perf record -a --switch-output=1m (Jiri Olsa) - Remove the need to use -e only for syscalls and --event only for tracepoints/HW/SW/etc events, i.e. now one can use: perf trace -e nanosleep,futex,sched:sched_switch ./workload or: perf trace --event nanosleep,futex,sched:sched_switch ./workload And have it tracing raw_syscalls:sys_{enter,exit} for the nanosleep and futex syscalls, formatting those as strace does while also tracing sched:sched_switch, ordering it all into one strace like output. Using '!' as the first character in the -e/--event argument remains a way to negate the list of syscalls, i.e. all syscalls except for the ones specified, doesn't affect the other kinds of events. E.g: [root@jouet ~] # perf trace -e sched:sched_switch,nanosleep usleep 1 0.000 ( 0.028 ms): usleep/28150 nanosleep(rqtp: 0x7ffe4201b9f0) ... 0.028 ( ): sched:sched_switch:usleep:28150 [120] S ==> swapper/0:0 [120]) 0.000 ( 0.065 ms): usleep/28150 ... [continued]: nanosleep()) = 0 [root@jouet ~]# (Arnaldo Carvalho de Melo) - 'perf kallsyms' toy tool to look for extended symbol information on the running kernel and demonstrate the machine/thread/symbol APIs for use in other tools, such as 'perf probe' (Arnaldo Carvalho de Melo) Infrastructure improvements: - Add missing linux/kernel.h include to subcmd.h (Arnaldo Carvalho de Melo) tools: Sync x86's vmx.h with the kernel - Create libdir directory before installing libperf-jvmti.so (Laura Abbott) - Fix typo in perf_evlist__start_workload() (Soramichi Akiyama) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents ad5013d + 675f52b commit f913f3a

24 files changed

+439
-52
lines changed

tools/arch/x86/include/uapi/asm/vmx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#define EXIT_REASON_TPR_BELOW_THRESHOLD 43
6666
#define EXIT_REASON_APIC_ACCESS 44
6767
#define EXIT_REASON_EOI_INDUCED 45
68+
#define EXIT_REASON_GDTR_IDTR 46
69+
#define EXIT_REASON_LDTR_TR 47
6870
#define EXIT_REASON_EPT_VIOLATION 48
6971
#define EXIT_REASON_EPT_MISCONFIG 49
7072
#define EXIT_REASON_INVEPT 50
@@ -113,6 +115,8 @@
113115
{ EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \
114116
{ EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, \
115117
{ EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, \
118+
{ EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, \
119+
{ EXIT_REASON_LDTR_TR, "LDTR_TR" }, \
116120
{ EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, \
117121
{ EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, \
118122
{ EXIT_REASON_INVEPT, "INVEPT" }, \
@@ -129,6 +133,7 @@
129133
{ EXIT_REASON_XRSTORS, "XRSTORS" }
130134

131135
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
136+
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
132137
#define VMX_ABORT_LOAD_HOST_MSR_FAIL 4
133138

134139
#endif /* _UAPIVMX_H */

tools/lib/subcmd/parse-options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef __SUBCMD_PARSE_OPTIONS_H
22
#define __SUBCMD_PARSE_OPTIONS_H
33

4+
#include <linux/kernel.h>
45
#include <stdbool.h>
56
#include <stdint.h>
67

tools/perf/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ perf-y += builtin-help.o
77
perf-y += builtin-sched.o
88
perf-y += builtin-buildid-list.o
99
perf-y += builtin-buildid-cache.o
10+
perf-y += builtin-kallsyms.o
1011
perf-y += builtin-list.o
1112
perf-y += builtin-record.o
1213
perf-y += builtin-report.o
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
perf-kallsyms(1)
2+
==============
3+
4+
NAME
5+
----
6+
perf-kallsyms - Searches running kernel for symbols
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'perf kallsyms <options> symbol_name[,symbol_name...]'
12+
13+
DESCRIPTION
14+
-----------
15+
This command searches the running kernel kallsyms file for the given symbol(s)
16+
and prints information about it, including the DSO, the kallsyms begin/end
17+
addresses and the addresses in the ELF kallsyms symbol table (for symbols in
18+
modules).
19+
20+
OPTIONS
21+
-------
22+
-v::
23+
--verbose=::
24+
Increase verbosity level, showing details about symbol table loading, etc.

tools/perf/Documentation/perf-record.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,19 @@ Configure all used events to run in user space.
421421
--timestamp-filename
422422
Append timestamp to output file name.
423423

424-
--switch-output::
424+
--switch-output[=mode]::
425425
Generate multiple perf.data files, timestamp prefixed, switching to a new one
426-
when receiving a SIGUSR2.
426+
based on 'mode' value:
427+
"signal" - when receiving a SIGUSR2 (default value) or
428+
<size> - when reaching the size threshold, size is expected to
429+
be a number with appended unit character - B/K/M/G
430+
<time> - when reaching the time threshold, size is expected to
431+
be a number with appended unit character - s/m/h/d
432+
433+
Note: the precision of the size threshold hugely depends
434+
on your configuration - the number and size of your ring
435+
buffers (-m). It is generally more precise for higher sizes
436+
(like >5M), for lower values expect different sizes.
427437

428438
A possible use case is to, given an external event, slice the perf.data file
429439
that gets then processed, possibly via a perf script, to decide if that

tools/perf/Documentation/perf-trace.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ OPTIONS
3535

3636
-e::
3737
--expr::
38-
List of syscalls to show, currently only syscall names.
38+
--event::
39+
List of syscalls and other perf events (tracepoints, HW cache events,
40+
etc) to show.
41+
See 'perf list' for a complete list of events.
3942
Prefixing with ! shows all syscalls but the ones specified. You may
4043
need to escape it.
4144

@@ -135,9 +138,6 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
135138
--kernel-syscall-graph::
136139
Show the kernel callchains on the syscall exit path.
137140

138-
--event::
139-
Trace other events, see 'perf list' for a complete list.
140-
141141
--max-stack::
142142
Set the stack depth limit when parsing the callchain, anything
143143
beyond the specified depth will be ignored. Note that at this point

tools/perf/Makefile.perf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ ifndef NO_PERF_READ_VDSOX32
661661
endif
662662
ifndef NO_JVMTI
663663
$(call QUIET_INSTALL, $(LIBJVMTI)) \
664+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
664665
$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
665666
endif
666667
$(call QUIET_INSTALL, libexec) \

tools/perf/builtin-help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
434434
const char * const builtin_help_subcommands[] = {
435435
"buildid-cache", "buildid-list", "diff", "evlist", "help", "list",
436436
"record", "report", "bench", "stat", "timechart", "top", "annotate",
437-
"script", "sched", "kmem", "lock", "kvm", "test", "inject", "mem", "data",
437+
"script", "sched", "kallsyms", "kmem", "lock", "kvm", "test", "inject", "mem", "data",
438438
#ifdef HAVE_LIBELF_SUPPORT
439439
"probe",
440440
#endif

tools/perf/builtin-kallsyms.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* builtin-kallsyms.c
3+
*
4+
* Builtin command: Look for a symbol in the running kernel and its modules
5+
*
6+
* Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]>
7+
*
8+
* Released under the GPL v2. (and only v2, not any later version)
9+
*/
10+
#include "builtin.h"
11+
#include <linux/compiler.h>
12+
#include <subcmd/parse-options.h>
13+
#include "debug.h"
14+
#include "machine.h"
15+
#include "symbol.h"
16+
17+
static int __cmd_kallsyms(int argc, const char **argv)
18+
{
19+
int i;
20+
struct machine *machine = machine__new_kallsyms();
21+
22+
if (machine == NULL) {
23+
pr_err("Couldn't read /proc/kallsyms\n");
24+
return -1;
25+
}
26+
27+
for (i = 0; i < argc; ++i) {
28+
struct map *map;
29+
struct symbol *symbol = machine__find_kernel_function_by_name(machine, argv[i], &map);
30+
31+
if (symbol == NULL) {
32+
printf("%s: not found\n", argv[i]);
33+
continue;
34+
}
35+
36+
printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n",
37+
symbol->name, map->dso->short_name, map->dso->long_name,
38+
map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end),
39+
symbol->start, symbol->end);
40+
}
41+
42+
machine__delete(machine);
43+
return 0;
44+
}
45+
46+
int cmd_kallsyms(int argc, const char **argv, const char *prefix __maybe_unused)
47+
{
48+
const struct option options[] = {
49+
OPT_INCR('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"),
50+
OPT_END()
51+
};
52+
const char * const kallsyms_usage[] = {
53+
"perf kallsyms [<options>] symbol_name",
54+
NULL
55+
};
56+
57+
argc = parse_options(argc, argv, options, kallsyms_usage, 0);
58+
if (argc < 1)
59+
usage_with_options(kallsyms_usage, options);
60+
61+
symbol_conf.sort_by_name = true;
62+
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
63+
if (symbol__init(NULL) < 0)
64+
return -1;
65+
66+
return __cmd_kallsyms(argc, argv);
67+
}

0 commit comments

Comments
 (0)