Commit aeaae7d6 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo-20160408' of...

Merge tag 'perf-core-for-mingo-20160408' 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:

User visible changes:

- Beautify more syscall arguments in 'perf trace', using the type column in
  tracepoint /format fields to attach, for instance, a pid_t resolver to the
  thread COMM, also attach a mode_t beautifier in the same fashion
  (Arnaldo Carvalho de Melo)

- Build the syscall table id <-> name resolver using the same .tbl file
  used in the kernel to generate headers, to avoid the delay in getting
  new syscalls supported in the audit-libs external dependency, done so
  far only for x86_64 (Arnaldo Carvalho de Melo)

- Improve the documentation of event specifications (Andi Kleen)

- Process update events in 'perf script', fixing up this use case:

    # perf stat -a -I 1000 -e cycles record | perf script -s script.py

- Shared object symbol adjustment fixes, fixing symbol resolution in
  Android (Wang Nan)

Infrastructure changes:

- Add dedicated unwind addr_space member into thread struct, to allow
  tools to use thread->priv, noticed while working on having callchains
  in 'perf trace' (Jiri Olsa)

Build fixes:

- Fix the build in Ubuntu 12.04 (Arnaldo Carvalho de Melo, Vinson Lee)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 889fac6d 99e87f7b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ endef
FEATURE_TESTS_BASIC :=			\
	backtrace			\
	dwarf				\
	dwarf_getlocations		\
	fortify-source			\
	sync-compare-and-swap		\
	glibc				\
@@ -78,6 +79,7 @@ endif

FEATURE_DISPLAY ?=			\
	dwarf				\
	dwarf_getlocations		\
	glibc				\
	gtk2				\
	libaudit			\
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ FILES= \
	test-backtrace.bin		\
	test-bionic.bin			\
	test-dwarf.bin			\
	test-dwarf_getlocations.bin	\
	test-fortify-source.bin		\
	test-sync-compare-and-swap.bin	\
	test-glibc.bin			\
@@ -82,6 +83,9 @@ endif
$(OUTPUT)test-dwarf.bin:
	$(BUILD) $(DWARFLIBS)

$(OUTPUT)test-dwarf_getlocations.bin:
	$(BUILD) $(DWARFLIBS)

$(OUTPUT)test-libelf-mmap.bin:
	$(BUILD) -lelf

+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@
# include "test-dwarf.c"
#undef main

#define main main_test_dwarf_getlocations
# include "test-dwarf_getlocations.c"
#undef main

#define main main_test_libelf_getphdrnum
# include "test-libelf-getphdrnum.c"
#undef main
@@ -143,6 +147,7 @@ int main(int argc, char *argv[])
	main_test_libelf_mmap();
	main_test_glibc();
	main_test_dwarf();
	main_test_dwarf_getlocations();
	main_test_libelf_getphdrnum();
	main_test_libunwind();
	main_test_libaudit();
+12 −0
Original line number Diff line number Diff line
#include <stdlib.h>
#include <elfutils/libdw.h>

int main(void)
{
	Dwarf_Addr base, start, end;
	Dwarf_Attribute attr;
	Dwarf_Op *op;
        size_t nops;
	ptrdiff_t offset = 0;
        return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
}
+106 −1
Original line number Diff line number Diff line
@@ -93,6 +93,67 @@ raw encoding of 0x1A8 can be used:
You should refer to the processor specific documentation for getting these
details. Some of them are referenced in the SEE ALSO section below.

ARBITRARY PMUS
--------------

perf also supports an extended syntax for specifying raw parameters
to PMUs. Using this typically requires looking up the specific event
in the CPU vendor specific documentation.

The available PMUs and their raw parameters can be listed with

  ls /sys/devices/*/format

For example the raw event "LSD.UOPS" core pmu event above could
be specified as

  perf stat -e cpu/event=0xa8,umask=0x1,name=LSD.UOPS_CYCLES,cmask=1/ ...

PER SOCKET PMUS
---------------

Some PMUs are not associated with a core, but with a whole CPU socket.
Events on these PMUs generally cannot be sampled, but only counted globally
with perf stat -a. They can be bound to one logical CPU, but will measure
all the CPUs in the same socket.

This example measures memory bandwidth every second
on the first memory controller on socket 0 of a Intel Xeon system

  perf stat -C 0 -a uncore_imc_0/cas_count_read/,uncore_imc_0/cas_count_write/ -I 1000 ...

Each memory controller has its own PMU.  Measuring the complete system
bandwidth would require specifying all imc PMUs (see perf list output),
and adding the values together.

This example measures the combined core power every second

  perf stat -I 1000 -e power/energy-cores/  -a

ACCESS RESTRICTIONS
-------------------

For non root users generally only context switched PMU events are available.
This is normally only the events in the cpu PMU, the predefined events
like cycles and instructions and some software events.

Other PMUs and global measurements are normally root only.
Some event qualifiers, such as "any", are also root only.

This can be overriden by setting the kernel.perf_event_paranoid
sysctl to -1, which allows non root to use these events.

For accessing trace point events perf needs to have read access to
/sys/kernel/debug/tracing, even when perf_event_paranoid is in a relaxed
setting.

TRACING
-------

Some PMUs control advanced hardware tracing capabilities, such as Intel PT,
that allows low overhead execution tracing.  These are described in a separate
intel-pt.txt document.

PARAMETERIZED EVENTS
--------------------

@@ -106,6 +167,50 @@ also be supplied. For example:

  perf stat -C 0 -e 'hv_gpci/dtbp_ptitc,phys_processor_idx=0x2/' ...

EVENT GROUPS
------------

Perf supports time based multiplexing of events, when the number of events
active exceeds the number of hardware performance counters. Multiplexing
can cause measurement errors when the workload changes its execution
profile.

When metrics are computed using formulas from event counts, it is useful to
ensure some events are always measured together as a group to minimize multiplexing
errors. Event groups can be specified using { }.

  perf stat -e '{instructions,cycles}' ...

The number of available performance counters depend on the CPU. A group
cannot contain more events than available counters.
For example Intel Core CPUs typically have four generic performance counters
for the core, plus three fixed counters for instructions, cycles and
ref-cycles. Some special events have restrictions on which counter they
can schedule, and may not support multiple instances in a single group.
When too many events are specified in the group none of them will not
be measured.

Globally pinned events can limit the number of counters available for
other groups. On x86 systems, the NMI watchdog pins a counter by default.
The nmi watchdog can be disabled as root with

	echo 0 > /proc/sys/kernel/nmi_watchdog

Events from multiple different PMUs cannot be mixed in a group, with
some exceptions for software events.

LEADER SAMPLING
---------------

perf also supports group leader sampling using the :S specifier.

  perf record -e '{cycles,instructions}:S' ...
  perf report --group

Normally all events in a event group sample, but with :S only
the first event (the leader) samples, and it only reads the values of the
other events in the group.

OPTIONS
-------

@@ -143,5 +248,5 @@ SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-top[1],
linkperf:perf-record[1],
http://www.intel.com/Assets/PDF/manual/253669.pdf[Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 3B: System Programming Guide],
http://www.intel.com/sdm/[Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 3B: System Programming Guide],
http://support.amd.com/us/Processor_TechDocs/24593_APM_v2.pdf[AMD64 Architecture Programmer’s Manual Volume 2: System Programming]
Loading