Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.11-20170111' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/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 <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jan 12, 2017
2 parents ad5013d + 675f52b commit f913f3a
Show file tree
Hide file tree
Showing 24 changed files with 439 additions and 52 deletions.
5 changes: 5 additions & 0 deletions tools/arch/x86/include/uapi/asm/vmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
#define EXIT_REASON_TPR_BELOW_THRESHOLD 43
#define EXIT_REASON_APIC_ACCESS 44
#define EXIT_REASON_EOI_INDUCED 45
#define EXIT_REASON_GDTR_IDTR 46
#define EXIT_REASON_LDTR_TR 47
#define EXIT_REASON_EPT_VIOLATION 48
#define EXIT_REASON_EPT_MISCONFIG 49
#define EXIT_REASON_INVEPT 50
Expand Down Expand Up @@ -113,6 +115,8 @@
{ EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \
{ EXIT_REASON_TPR_BELOW_THRESHOLD, "TPR_BELOW_THRESHOLD" }, \
{ EXIT_REASON_APIC_ACCESS, "APIC_ACCESS" }, \
{ EXIT_REASON_GDTR_IDTR, "GDTR_IDTR" }, \
{ EXIT_REASON_LDTR_TR, "LDTR_TR" }, \
{ EXIT_REASON_EPT_VIOLATION, "EPT_VIOLATION" }, \
{ EXIT_REASON_EPT_MISCONFIG, "EPT_MISCONFIG" }, \
{ EXIT_REASON_INVEPT, "INVEPT" }, \
Expand All @@ -129,6 +133,7 @@
{ EXIT_REASON_XRSTORS, "XRSTORS" }

#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
#define VMX_ABORT_LOAD_HOST_MSR_FAIL 4

#endif /* _UAPIVMX_H */
1 change: 1 addition & 0 deletions tools/lib/subcmd/parse-options.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __SUBCMD_PARSE_OPTIONS_H
#define __SUBCMD_PARSE_OPTIONS_H

#include <linux/kernel.h>
#include <stdbool.h>
#include <stdint.h>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/Build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ perf-y += builtin-help.o
perf-y += builtin-sched.o
perf-y += builtin-buildid-list.o
perf-y += builtin-buildid-cache.o
perf-y += builtin-kallsyms.o
perf-y += builtin-list.o
perf-y += builtin-record.o
perf-y += builtin-report.o
Expand Down
24 changes: 24 additions & 0 deletions tools/perf/Documentation/perf-kallsyms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
perf-kallsyms(1)
==============

NAME
----
perf-kallsyms - Searches running kernel for symbols

SYNOPSIS
--------
[verse]
'perf kallsyms <options> symbol_name[,symbol_name...]'

DESCRIPTION
-----------
This command searches the running kernel kallsyms file for the given symbol(s)
and prints information about it, including the DSO, the kallsyms begin/end
addresses and the addresses in the ELF kallsyms symbol table (for symbols in
modules).

OPTIONS
-------
-v::
--verbose=::
Increase verbosity level, showing details about symbol table loading, etc.
14 changes: 12 additions & 2 deletions tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,19 @@ Configure all used events to run in user space.
--timestamp-filename
Append timestamp to output file name.

--switch-output::
--switch-output[=mode]::
Generate multiple perf.data files, timestamp prefixed, switching to a new one
when receiving a SIGUSR2.
based on 'mode' value:
"signal" - when receiving a SIGUSR2 (default value) or
<size> - when reaching the size threshold, size is expected to
be a number with appended unit character - B/K/M/G
<time> - when reaching the time threshold, size is expected to
be a number with appended unit character - s/m/h/d

Note: the precision of the size threshold hugely depends
on your configuration - the number and size of your ring
buffers (-m). It is generally more precise for higher sizes
(like >5M), for lower values expect different sizes.

A possible use case is to, given an external event, slice the perf.data file
that gets then processed, possibly via a perf script, to decide if that
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/Documentation/perf-trace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ OPTIONS

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

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

--event::
Trace other events, see 'perf list' for a complete list.

--max-stack::
Set the stack depth limit when parsing the callchain, anything
beyond the specified depth will be ignored. Note that at this point
Expand Down
1 change: 1 addition & 0 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ ifndef NO_PERF_READ_VDSOX32
endif
ifndef NO_JVMTI
$(call QUIET_INSTALL, $(LIBJVMTI)) \
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
endif
$(call QUIET_INSTALL, libexec) \
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-help.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
const char * const builtin_help_subcommands[] = {
"buildid-cache", "buildid-list", "diff", "evlist", "help", "list",
"record", "report", "bench", "stat", "timechart", "top", "annotate",
"script", "sched", "kmem", "lock", "kvm", "test", "inject", "mem", "data",
"script", "sched", "kallsyms", "kmem", "lock", "kvm", "test", "inject", "mem", "data",
#ifdef HAVE_LIBELF_SUPPORT
"probe",
#endif
Expand Down
67 changes: 67 additions & 0 deletions tools/perf/builtin-kallsyms.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* builtin-kallsyms.c
*
* Builtin command: Look for a symbol in the running kernel and its modules
*
* Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
*
* Released under the GPL v2. (and only v2, not any later version)
*/
#include "builtin.h"
#include <linux/compiler.h>
#include <subcmd/parse-options.h>
#include "debug.h"
#include "machine.h"
#include "symbol.h"

static int __cmd_kallsyms(int argc, const char **argv)
{
int i;
struct machine *machine = machine__new_kallsyms();

if (machine == NULL) {
pr_err("Couldn't read /proc/kallsyms\n");
return -1;
}

for (i = 0; i < argc; ++i) {
struct map *map;
struct symbol *symbol = machine__find_kernel_function_by_name(machine, argv[i], &map);

if (symbol == NULL) {
printf("%s: not found\n", argv[i]);
continue;
}

printf("%s: %s %s %#" PRIx64 "-%#" PRIx64 " (%#" PRIx64 "-%#" PRIx64")\n",
symbol->name, map->dso->short_name, map->dso->long_name,
map->unmap_ip(map, symbol->start), map->unmap_ip(map, symbol->end),
symbol->start, symbol->end);
}

machine__delete(machine);
return 0;
}

int cmd_kallsyms(int argc, const char **argv, const char *prefix __maybe_unused)
{
const struct option options[] = {
OPT_INCR('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"),
OPT_END()
};
const char * const kallsyms_usage[] = {
"perf kallsyms [<options>] symbol_name",
NULL
};

argc = parse_options(argc, argv, options, kallsyms_usage, 0);
if (argc < 1)
usage_with_options(kallsyms_usage, options);

symbol_conf.sort_by_name = true;
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
if (symbol__init(NULL) < 0)
return -1;

return __cmd_kallsyms(argc, argv);
}
Loading

0 comments on commit f913f3a

Please sign in to comment.