Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-20161114' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

 - Allow querying and setting .perfconfig variables (Taeung Song)

 - Show branch information in callchains (predicted, TSX aborts, loop
   iteractions, etc) (Jin Yao)

Infrastructure changes:

 - Support kbuild's CFLAGS_REMOVE_ in tools/build (Jiri Olsa)

 - Plug building jvmti to the main perf Makefile (Jiri Olsa)

Documentation changes:

 - Update Intel PT documentation about context switch events (Arnaldo Carvalho de Melo)

 - Fix 'perf record --call-graph dwarf' help/config in builds not linking
   with a unwind library, mentioning that is a possible record option (Rabin Vincent)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Nov 15, 2016
2 parents 91a79e5 + fef51ec commit 6a6b12e
Show file tree
Hide file tree
Showing 21 changed files with 634 additions and 131 deletions.
4 changes: 3 additions & 1 deletion tools/build/Build.include
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
# - per target C flags
# - per object C flags
# - BUILD_STR macro to allow '-D"$(variable)"' constructs
c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
c_flags = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))

###
Expand Down
6 changes: 4 additions & 2 deletions tools/build/Documentation/Build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ CFLAGS

It's possible to alter the standard object C flags in the following way:

CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
CFLAGS_gtk += '...' - alters CFLAGS for gtk build object
CFLAGS_perf.o += '...' - adds CFLAGS for perf.o object
CFLAGS_gtk += '...' - adds CFLAGS for gtk build object
CFLAGS_REMOVE_perf.o += '...' - removes CFLAGS for perf.o object
CFLAGS_REMOVE_gtk += '...' - removes CFLAGS for gtk build object

This C flags changes has the scope of the Build makefile they are defined in.

Expand Down
6 changes: 5 additions & 1 deletion tools/build/feature/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ FILES= \
test-bpf.bin \
test-get_cpuid.bin \
test-sdt.bin \
test-cxx.bin
test-cxx.bin \
test-jvmti.bin

FILES := $(addprefix $(OUTPUT),$(FILES))

Expand Down Expand Up @@ -225,6 +226,9 @@ $(OUTPUT)test-sdt.bin:
$(OUTPUT)test-cxx.bin:
$(BUILDXX) -std=gnu++11

$(OUTPUT)test-jvmti.bin:
$(BUILD)

-include $(OUTPUT)*.d

###############################
Expand Down
13 changes: 13 additions & 0 deletions tools/build/feature/test-jvmti.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <jvmti.h>
#include <jvmticmlr.h>

int main(void)
{
JavaVM jvm __attribute__((unused));
jvmtiEventCallbacks cb __attribute__((unused));
jvmtiCapabilities caps __attribute__((unused));
jvmtiJlocationFormat format __attribute__((unused));
jvmtiEnv jvmti __attribute__((unused));

return 0;
}
19 changes: 17 additions & 2 deletions tools/perf/Documentation/intel-pt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,18 @@ Unless /proc/sys/kernel/perf_event_paranoid is set to -1, unprivileged users
have memory limits imposed upon them. That affects what buffer sizes they can
have as outlined above.

The v4.2 kernel introduced support for a context switch metadata event,
PERF_RECORD_SWITCH, which allows unprivileged users to see when their processes
are scheduled out and in, just not by whom, which is left for the
PERF_RECORD_SWITCH_CPU_WIDE, that is only accessible in system wide context,
which in turn requires CAP_SYS_ADMIN.

Please see the 45ac1403f564 ("perf: Add PERF_RECORD_SWITCH to indicate context
switches") commit, that introduces these metadata events for further info.

When working with kernels < v4.2, the following considerations must be taken,
as the sched:sched_switch tracepoints will be used to receive such information:

Unless /proc/sys/kernel/perf_event_paranoid is set to -1, unprivileged users are
not permitted to use tracepoints which means there is insufficient side-band
information to decode Intel PT in per-cpu mode, and potentially workload-only
Expand All @@ -564,8 +576,11 @@ sched_switch tracepoint
-----------------------

The sched_switch tracepoint is used to provide side-band data for Intel PT
decoding. sched_switch events are automatically added. e.g. the second event
shown below
decoding in kernels where the PERF_RECORD_SWITCH metadata event isn't
available.

The sched_switch events are automatically added. e.g. the second event shown
below:

$ perf record -vv -e intel_pt//u uname
------------------------------------------------------------
Expand Down
35 changes: 35 additions & 0 deletions tools/perf/Documentation/perf-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ perf-config - Get and set variables in a configuration file.
SYNOPSIS
--------
[verse]
'perf config' [<file-option>] [section.name[=value] ...]
or
'perf config' [<file-option>] -l | --list

DESCRIPTION
Expand Down Expand Up @@ -118,6 +120,39 @@ Given a $HOME/.perfconfig like this:
children = true
group = true

You can hide source code of annotate feature setting the config to false with

% perf config annotate.hide_src_code=true

If you want to add or modify several config items, you can do like

% perf config ui.show-headers=false kmem.default=slab

To modify the sort order of report functionality in user config file(i.e. `~/.perfconfig`), do

% perf config --user report sort-order=srcline

To change colors of selected line to other foreground and background colors
in system config file (i.e. `$(sysconf)/perfconfig`), do

% perf config --system colors.selected=yellow,green

To query the record mode of call graph, do

% perf config call-graph.record-mode

If you want to know multiple config key/value pairs, you can do like

% perf config report.queue-size call-graph.order report.children

To query the config value of sort order of call graph in user config file (i.e. `~/.perfconfig`), do

% perf config --user call-graph.sort-order

To query the config value of buildid directory in system config file (i.e. `$(sysconf)/perfconfig`), do

% perf config --system buildid.dir

Variables
~~~~~~~~~

Expand Down
26 changes: 26 additions & 0 deletions tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,31 @@ ifndef NO_AUXTRACE
endif
endif

ifndef NO_JVMTI
ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
else
ifneq (,$(wildcard /usr/sbin/alternatives))
JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
endif
endif
ifndef JDIR
$(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
NO_JVMTI := 1
endif
endif

ifndef NO_JVMTI
FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
$(call feature_check,jvmti)
ifeq ($(feature-jvmti), 1)
$(call detected_var,JDIR)
else
$(warning No openjdk development package found, please install JDK package)
NO_JVMTI := 1
endif
endif

# Among the variables below, these:
# perfexecdir
# template_dir
Expand Down Expand Up @@ -850,6 +875,7 @@ ifeq ($(VF),1)
$(call print_var,sysconfdir)
$(call print_var,LIBUNWIND_DIR)
$(call print_var,LIBDW_DIR)
$(call print_var,JDIR)

ifeq ($(dwarf-post-unwind),1)
$(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
Expand Down
24 changes: 23 additions & 1 deletion tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ include ../scripts/utilities.mak
#
# Define FEATURES_DUMP to provide features detection dump file
# and bypass the feature detection
#
# Define NO_JVMTI if you do not want jvmti agent built

# As per kernel Makefile, avoid funny character set dependencies
unexport LC_ALL
Expand Down Expand Up @@ -283,6 +285,12 @@ ifndef NO_PERF_READ_VDSOX32
PROGRAMS += $(OUTPUT)perf-read-vdsox32
endif

LIBJVMTI = libperf-jvmti.so

ifndef NO_JVMTI
PROGRAMS += $(OUTPUT)$(LIBJVMTI)
endif

# what 'all' will build and 'install' will install, in perfexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)

Expand Down Expand Up @@ -551,6 +559,16 @@ $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c
$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
endif

ifndef NO_JVMTI
LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o

$(LIBJVMTI_IN): FORCE
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti

$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
endif

$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)

LIBPERF_IN := $(OUTPUT)libperf-in.o
Expand Down Expand Up @@ -687,6 +705,10 @@ endif
ifndef NO_PERF_READ_VDSOX32
$(call QUIET_INSTALL, perf-read-vdsox32) \
$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
endif
ifndef NO_JVMTI
$(call QUIET_INSTALL, $(LIBJVMTI)) \
$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
endif
$(call QUIET_INSTALL, libexec) \
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
Expand Down Expand Up @@ -754,7 +776,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detected
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
$(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
Expand Down
Loading

0 comments on commit 6a6b12e

Please sign in to comment.