perf/core improvements and fixes
Subsystems (4)
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit f2029b1e47b607619d1dd2cb0bbb77f64ec6b7c2:
perf/x86/intel: Add Kaby Lake support (2017-02-11 21:28:23 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.11-20170213
for you to fetch changes up to a734fb5d60067a73dd7099a58756847c07f9cd68:
samples/bpf: Reset global variables (2017-02-13 17:22:53 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
New feature:
- Introduce the 'delta-abs' 'perf diff' compute method, that orders the histogram entries by the absolute value of the percentage delta for a function in two perf.data files, i.e. the functions that changed the most (increase or decrease in samples) comes first (Namhyung Kim)
User visible:
- Improve message about tweaking the kernel.perf_event_paranoid setting, telling how to make the change permanent by editing /etc/sysctl.conf (Ingo Molnar)
Infrastructure:
- Introduce linux/compiler-gcc.h as a counterpart to the kernel's, initially containing the definition of __fallthrough, more to come (__maybe_unused, etc) (Arnaldo Carvalho de Melo)
- Fixes for problems uncovered by building tools/perf with clang, such as always true tests of arrays against NULL and variables that sometimes were used without being initialized (Arnaldo Carvalho de Melo, Steven Rostedt)
- Before loading a new ELF, clear global variables set by the samples/bpf loader (Mickaël Salaün)
- Ignore already processed ELF sections in the samples/bpf loader (Mickaël Salaün)
- Fix compile error in the scripting code with some perl5 versions (Wang YanQing)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (6):
tools include: Introduce linux/compiler-gcc.h
tools lib traceevent plugin function: Initialize 'index' variable perf evsel: Inform how to make a sysctl setting permanent perf symbols: No need to check if sym->name is NULL
perf tests record: No need to test an array against NULL perf symbols: dso->name is an array, no need to check it against NULL
Mickaël Salaün (3):
samples/bpf: Add missing header samples/bpf: Ignore already processed ELF sections samples/bpf: Reset global variables
Namhyung Kim (4):
perf diff: Add 'delta-abs' compute method perf diff: Add diff.order config option perf diff: Add diff.compute config option perf diff: Change default setting to "delta-abs"
Steven Rostedt (VMware) (1):
tools lib traceevent: Initialize lenght on OLD_RING_BUFFER_TYPE_TIME_STAMP
Wang YanQing (1):
perf scripting perl: Fix compile error with some perl5 versions
samples/bpf/bpf_load.c | 7 ++ samples/bpf/tracex5_kern.c | 1 + tools/include/linux/compiler-gcc.h | 14 ++++ tools/include/linux/compiler.h | 10 +-- tools/lib/traceevent/kbuffer-parse.c | 1 + tools/lib/traceevent/plugin_function.c | 2 +- tools/perf/Documentation/perf-config.txt | 12 ++++ tools/perf/Documentation/perf-diff.txt | 15 ++++- tools/perf/MANIFEST | 1 + tools/perf/builtin-diff.c | 78 ++++++++++++++++++++-- tools/perf/builtin-kmem.c | 4 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/util/evsel.c | 4 +- tools/perf/util/evsel_fprintf.c | 1 - tools/perf/util/machine.c | 2 +- tools/perf/util/map.c | 4 +- tools/perf/util/scripting-engines/Build | 2 +- .../perf/util/scripting-engines/trace-event-perl.c | 4 +- tools/perf/util/symbol_fprintf.c | 2 +- 23 files changed, 145 insertions(+), 29 deletions(-) create mode 100644 tools/include/linux/compiler-gcc.h
Test results:
The first ones are container (docker) based builds of tools/perf with and without libelf support, objtool where it is supported and samples/bpf/, ditto.
Several are cross builds, the ones with -x-ARCH, and the android one, and those may not have all the features built, due to lack of multi-arch devel packages, available and being used so far on just a few, like debian:experimental-x-{arm64,mipsel}.
The 'perf test' one will perform a variety of tests exercising tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands with a variety of command line event specifications to then intercept the sys_perf_event syscall to check that the perf_event_attr fields are set up as expected, among a variety of other unit tests.
Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/ with a variety of feature sets, exercising the build with an incomplete set of features as well as with a complete one. It is planned to have it run on each of the containers mentioned above, using some container orchestration infrastructure. Get in contact if interested in helping having this in place.
# time dm 1 alpine:3.4: Ok 2 android-ndk:r12b-arm: Ok 3 archlinux:latest: Ok 4 centos:5: Ok 5 centos:6: Ok 6 centos:7: Ok 7 debian:7: Ok 8 debian:8: Ok 9 debian:experimental: Ok 10 debian:experimental-x-arm64: Ok 11 debian:experimental-x-mips: Ok 12 debian:experimental-x-mips64: Ok 13 debian:experimental-x-mipsel: Ok 14 fedora:20: Ok 15 fedora:21: Ok 16 fedora:22: Ok 17 fedora:23: Ok 18 fedora:24: Ok 19 fedora:24-x-ARC-uClibc: Ok 20 fedora:25: Ok 21 fedora:rawhide: Ok 22 mageia:5: Ok 23 opensuse:13.2: Ok 24 opensuse:42.1: Ok 25 opensuse:tumbleweed: Ok 26 ubuntu:12.04.5: Ok 27 ubuntu:14.04.4-x-linaro-arm64: Ok 28 ubuntu:15.10: Ok 29 ubuntu:16.04: Ok 30 ubuntu:16.04-x-arm: Ok 31 ubuntu:16.04-x-arm64: Ok 32 ubuntu:16.04-x-powerpc: Ok 33 ubuntu:16.04-x-powerpc64: Ok 34 ubuntu:16.04-x-powerpc64el: Ok 35 ubuntu:16.04-x-s390: Ok 36 ubuntu:16.10: Ok #
# uname -a Linux jouet 4.9.8-201.fc25.x86_64 #1 SMP Tue Feb 7 11:28:07 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux # perf test 1: vmlinux symtab matches kallsyms : Ok 2: Detect openat syscall event : Ok 3: Detect openat syscall event on all cpus : Ok 4: Read samples using the mmap interface : Ok 5: Parse event definition strings : Ok 6: PERF_RECORD_* events & perf_sample fields : Ok 7: Parse perf pmu format : Ok 8: DSO data read : Ok 9: DSO data cache : Ok 10: DSO data reopen : Ok 11: Roundtrip evsel->name : Ok 12: Parse sched tracepoints fields : Ok 13: syscalls:sys_enter_openat event fields : Ok 14: Setup struct perf_event_attr : Ok 15: Match and link multiple hists : Ok 16: 'import perf' in python : Ok 17: Breakpoint overflow signal handler : Ok 18: Breakpoint overflow sampling : Ok 19: Number of exit events of a simple workload : Ok 20: Software clock events period values : Ok 21: Object code reading : Ok 22: Sample parsing : Ok 23: Use a dummy software event to keep tracking: Ok 24: Parse with no sample_id_all bit set : Ok 25: Filter hist entries : Ok 26: Lookup mmap thread : Ok 27: Share thread mg : Ok 28: Sort output of hist entries : Ok 29: Cumulate child hist entries : Ok 30: Track with sched_switch : Ok 31: Filter fds with revents mask in a fdarray : Ok 32: Add fd to a fdarray, making it autogrow : Ok 33: kmod_path__parse : Ok 34: Thread map : Ok 35: LLVM search and compile : 35.1: Basic BPF llvm compile : Ok 35.2: kbuild searching : Ok 35.3: Compile source for BPF prologue generation: Ok 35.4: Compile source for BPF relocation : Ok 36: Session topology : Ok 37: BPF filter : 37.1: Basic BPF filtering : Ok 37.2: BPF pinning : Ok 37.3: BPF prologue generation : Ok 37.4: BPF relocation checker : Ok 38: Synthesize thread map : Ok 39: Remove thread map : Ok 40: Synthesize cpu map : Ok 41: Synthesize stat config : Ok 42: Synthesize stat : Ok 43: Synthesize stat round : Ok 44: Synthesize attr update : Ok 45: Event times : Ok 46: Read backward ring buffer : Ok 47: Print cpu map : Ok 48: Probe SDT events : Ok 49: is_printable_array : Ok 50: Print bitmap : Ok 51: perf hooks : Ok 52: builtin clang support : Skip (not compiled in) 53: unit_number__scnprintf : Ok 54: x86 rdpmc : Ok 55: Convert perf time to TSC : Ok 56: DWARF unwind : Ok 57: x86 instruction decoder - new instructions : Ok 58: Intel cqm nmi context read : Skip #
$ make -C tools/perf build-test
make: Entering directory '/home/acme/git/linux/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_install_O: make install
make_no_libunwind_O: make NO_LIBUNWIND=1
make_no_newt_O: make NO_NEWT=1
make_no_slang_O: make NO_SLANG=1
make_static_O: make LDFLAGS=-static
make_no_backtrace_O: make NO_BACKTRACE=1
make_no_libbionic_O: make NO_LIBBIONIC=1
make_clean_all_O: make clean all
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_no_libnuma_O: make NO_LIBNUMA=1
make_tags_O: make tags
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
make_perf_o_O: make perf.o
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_no_libpython_O: make NO_LIBPYTHON=1
make_no_gtk2_O: make NO_GTK2=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_help_O: make help
make_with_babeltrace_O: make LIBBABELTRACE=1
make_install_prefix_O: make install prefix=/tmp/krava
make_debug_O: make DEBUG=1
make_no_libbpf_O: make NO_LIBBPF=1
make_util_map_o_O: make util/map.o
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_no_libperl_O: make NO_LIBPERL=1
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_doc_O: make doc
make_no_libelf_O: make NO_LIBELF=1
make_no_auxtrace_O: make NO_AUXTRACE=1
make_install_bin_O: make install-bin
make_no_demangle_O: make NO_DEMANGLE=1
make_pure_O: make
OK
make: Leaving directory '/home/acme/git/linux/tools/perf'
$Arnaldo Carvalho de Melo
maintainerPATCH 1/15 tools include: Introduce linux/compiler-gcc.h
From: Arnaldo Carvalho de Melo <[email protected]>
To match the kernel headers structure, setting up things that are specific to gcc or to some specific version of gcc.
It gets included by linux/compiler.h when gcc is the compiler being used.
--- tools/include/linux/compiler-gcc.h | 14 ++++++++++++++ tools/include/linux/compiler.h | 10 +++++----- tools/perf/MANIFEST | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tools/include/linux/compiler-gcc.h
tools/include/linux/compiler-gcc.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _TOOLS_LINUX_COMPILER_H_ +#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead." +#endif + +/* +* Common definitions for all gcc versions go here. +*/ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION >=70000 && !defined(__CHECKER__) +# define __fallthrough __attribute__ ((fallthrough)) +#endif
tools/include/linux/compiler.h +5 -5
@@ -1,6 +1,10 @@#ifndef _TOOLS_LINUX_COMPILER_H_#define _TOOLS_LINUX_COMPILER_H_ +#ifdef __GNUC__ +#include <linux/compiler-gcc.h> +#endif +/* Optimization barrier */ /* The "volatile" is due to gcc bugs */ #define barrier () __asm__ __volatile__("": : :"memory")
@@ -128,11 +132,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s#ifndef __fallthrough -# if defined(__GNUC__) && __GNUC__ >=7 -# define __fallthrough __attribute__ ((fallthrough)) -# else -# define __fallthrough -# endif +# define __fallthrough#endif #endif /* _TOOLS_LINUX_COMPILER_H */
tools/perf/MANIFEST +1 -0
@@ -61,6 +61,7 @@ tools/include/asm-generic/bitops.h tools/include/linux/atomic.h tools/include/linux/bitops.h tools/include/linux/compiler.h +tools/include/linux/compiler-gcc.h tools/include/linux/coresight-pmu.h tools/include/linux/filter.h tools/include/linux/hash.h
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 2/15 perf diff: Add 'delta-abs' compute method
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The 'delta-abs' compute method is same as 'delta' but shows entries with bigger absolute delta first instead of sorting numerically. This is only useful together with -o option.
Below is default output (-c delta):
$ perf diff -o 1 -c delta | grep -v ^# | head
42.22% +4.97% [kernel.kallsyms] [k] cfb_imageblit
0.62% +1.23% [kernel.kallsyms] [k] mutex_lock
+1.15% [kernel.kallsyms] [k] copy_user_generic_string
2.40% +0.95% [kernel.kallsyms] [k] bit_putcs
0.31% +0.79% [kernel.kallsyms] [k] link_path_walk
+0.64% [kernel.kallsyms] [k] kmem_cache_alloc
0.00% +0.57% [kernel.kallsyms] [k] __rcu_read_unlock
+0.45% [kernel.kallsyms] [k] alloc_set_pte
0.16% +0.45% [kernel.kallsyms] [k] menu_select
+0.41% ld-2.24.so [.] do_lookup_xNow with 'delta-abs' it shows entries have bigger delta value either positive or negative.
$ perf diff -o 1 -c delta-abs | grep -v ^# | head
42.22% +4.97% [kernel.kallsyms] [k] cfb_imageblit
12.72% -3.01% [kernel.kallsyms] [k] intel_idle
9.72% -1.31% [unknown] [.] 0x0000000000411343
0.62% +1.23% [kernel.kallsyms] [k] mutex_lock
2.40% +0.95% [kernel.kallsyms] [k] bit_putcs
0.31% +0.79% [kernel.kallsyms] [k] link_path_walk
1.35% -0.71% [kernel.kallsyms] [k] smp_call_function_single
0.00% +0.57% [kernel.kallsyms] [k] __rcu_read_unlock
0.16% +0.45% [kernel.kallsyms] [k] menu_select
0.72% -0.44% [kernel.kallsyms] [k] lookup_fast--- tools/perf/Documentation/perf-diff.txt | 6 ++++- tools/perf/builtin-diff.c | 46 ++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-diff.txt +5 -1
@@ -86,7 +86,7 @@ OPTIONS -c:: --compute:: - Differential computation selection - delta,ratio,wdiff (default is delta). + Differential computation selection - delta,ratio,wdiff,delta-abs (default is delta). See COMPARISON METHODS section for more info. -p::
@@ -181,6 +181,10 @@ with: relative to how entries are filtered. Use --percentage=absolute to prevent such fluctuation. +delta-abs +~~~~~~~~~ +Same as 'delta` method, but sort the result with the absolute values. + ratio ~~~~~ If specified the 'Ratio' column is displayed with value 'r' computed as:
tools/perf/builtin-diff.c +44 -2
135 lines not on this page · raw message
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 3/15 perf diff: Add diff.order config option
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
In many cases, I need to look at differences between two data so I often used the -o option to sort the result base on the difference first. It'd be nice to have a config option to set it by default.
The diff.order config option is to set the default value of -o/--order option.
--- tools/perf/Documentation/perf-config.txt | 7 +++++++ tools/perf/Documentation/perf-diff.txt | 6 +++++- tools/perf/builtin-diff.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-config.txt +7 -0
@@ -498,6 +498,13 @@ record.*:: But if this option is 'no-cache', it will not update the build-id cache. 'skip' skips post-processing and does not update the cache. +diff.*:: + diff.order:: + This option sets the number of columns to sort the result. + The default is 0, which means sorting by baseline. + Setting it to 1 will sort the result by delta (or other + compute method selected). + SEE ALSO -------- linkperf:perf[1]
tools/perf/Documentation/perf-diff.txt +5 -1
@@ -99,7 +99,11 @@ OPTIONS -o:: --order:: - Specify compute sorting column number. + Specify compute sorting column number. 0 means sorting by baseline + overhead (default) and 1 means sorting by computed value of column 1 + (data from the first file other base baseline). Values more than 1 + can be used only if enough data files are provided. + The default value can be set using the diff.order config option. --percentage:: Determine how to display the overhead percentage of filtered entries.
tools/perf/builtin-diff.c +14 -0
@@ -17,6 +17,7 @@#include "util/symbol.h" #include "util/util.h" #include "util/data.h" +#include "util/config.h" #include <stdlib.h> #include <math.h>
@@ -1291,6 +1292,17 @@ static int data_init(int argc, const char **argv)return 0 ; } +static int diff__config (const char *var,const char *value, +void *cb__maybe_unused ) +{ +if (!strcmp (var,"diff.order" )) { + sort_compute =perf_config_int (var, value); +return 0 ; + } + +return 0 ; +} +int cmd_diff (int argc,const char **argv,const char *prefix__maybe_unused ) {int ret =hists__init ();
@@ -1298,6 +1310,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)if (ret <0 )return ret; +perf_config (diff__config,NULL ); + argc =parse_options (argc, argv, options, diff_usage,0 );if (symbol__init (NULL ) <0 )
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 4/15 perf diff: Add diff.compute config option
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The diff.compute config variable is to set the default compute method of perf diff command (-c option). Possible values 'delta' (default), 'delta-abs', 'ratio' and 'wdiff'.
--- tools/perf/Documentation/perf-config.txt | 5 +++++ tools/perf/Documentation/perf-diff.txt | 5 +++-- tools/perf/builtin-diff.c | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-config.txt +5 -0
@@ -505,6 +505,11 @@ diff.*:: Setting it to 1 will sort the result by delta (or other compute method selected). + diff.compute:: + This options sets the method for computing the diff result. + Possible values are 'delta', 'delta-abs', 'ratio' and + 'wdiff'. Default is 'delta'. + SEE ALSO -------- linkperf:perf[1]
tools/perf/Documentation/perf-diff.txt +3 -2
@@ -86,8 +86,9 @@ OPTIONS -c:: --compute:: - Differential computation selection - delta,ratio,wdiff,delta-abs (default is delta). - See COMPARISON METHODS section for more info. + Differential computation selection - delta, ratio, wdiff, delta-abs + (default is delta). Default can be changed using diff.compute + config option. See COMPARISON METHODS section for more info. -p:: --period::
tools/perf/builtin-diff.c +15 -1
@@ -86,7 +86,7 @@ const char *compute_names[COMPUTE_MAX] = { [COMPUTE_WEIGHTED_DIFF] = "wdiff", }; -static int compute; +static int compute =COMPUTE_DELTA ;static int compute_2_hpp[COMPUTE_MAX ] = { [COMPUTE_DELTA ] =PERF_HPP_DIFF__DELTA ,
@@ -1299,6 +1299,20 @@ static int diff__config(const char *var, const char *value, sort_compute =perf_config_int (var, value);return 0 ; } +if (!strcmp (var,"diff.compute" )) { +if (!strcmp (value,"delta" )) { + compute =COMPUTE_DELTA ; + }else if (!strcmp (value,"delta-abs" )) { + compute =COMPUTE_DELTA_ABS ; + }else if (!strcmp (value,"ratio" )) { + compute =COMPUTE_RATIO ; + }else if (!strcmp (value,"wdiff" )) { + compute =COMPUTE_WEIGHTED_DIFF ; + }else { +pr_err ("Invalid compute method: %s\n" , value); +return -1 ; + } + }return 0 ; }
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 5/15 perf diff: Change default setting to "delta-abs"
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The "delta-abs" compute method will show most changed entries on top. So users can easily see how much effect between the data. Note that it also changes the default of -o option to 1 in order to apply the compute method. To see original-style (sorted by baseline) use -o 0 option.
--- tools/perf/Documentation/perf-diff.txt | 4 ++-- tools/perf/builtin-diff.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/Documentation/perf-diff.txt +2 -2
@@ -87,7 +87,7 @@ OPTIONS -c:: --compute:: Differential computation selection - delta, ratio, wdiff, delta-abs - (default is delta). Default can be changed using diff.compute + (default is delta-abs). Default can be changed using diff.compute config option. See COMPARISON METHODS section for more info. -p::
@@ -101,7 +101,7 @@ OPTIONS -o:: --order:: Specify compute sorting column number. 0 means sorting by baseline - overhead (default) and 1 means sorting by computed value of column 1 + overhead and 1 (default) means sorting by computed value of column 1 (data from the first file other base baseline). Values more than 1 can be used only if enough data files are provided. The default value can be set using the diff.order config option.
tools/perf/builtin-diff.c +3 -3
@@ -66,7 +66,7 @@ static bool force;static bool show_period;static bool show_formula;static bool show_baseline_only; -static unsigned int sort_compute; +static unsigned int sort_compute =1 ;static s64 compute_wdiff_w1;static s64 compute_wdiff_w2;
@@ -86,7 +86,7 @@ const char *compute_names[COMPUTE_MAX] = { [COMPUTE_WEIGHTED_DIFF] = "wdiff", }; -static int compute =COMPUTE_DELTA ; +static int compute =COMPUTE_DELTA_ABS ;static int compute_2_hpp[COMPUTE_MAX ] = { [COMPUTE_DELTA ] =PERF_HPP_DIFF__DELTA ,
@@ -810,7 +810,7 @@ static const struct option options[] = {OPT_BOOLEAN ('b' ,"baseline-only" , &show_baseline_only,"Show only items with match in baseline" ),OPT_CALLBACK ('c' ,"compute" , &compute, -"delta,delta-abs,ratio,wdiff:w1,w2 (default delta)" , +"delta,delta-abs,ratio,wdiff:w1,w2 (default delta-abs)" ,"Entries differential computation selection" , setup_compute), OPT_BOOLEAN('p', "period", &show_period,
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 6/15 perf scripting perl: Fix compile error with some perl5 versions
In reply to Arnaldo Carvalho de MeloFrom: Wang YanQing <[email protected]>
Fix below compile error:
CC util/scripting-engines/trace-event-perl.o
In file included from /usr/lib/perl5/5.22.2/i686-linux/CORE/perl.h:5673:0,
from util/scripting-engines/trace-event-perl.c:31:
/usr/lib/perl5/5.22.2/i686-linux/CORE/inline.h: In function 'S__is_utf8_char_slow':
/usr/lib/perl5/5.22.2/i686-linux/CORE/inline.h:270:5: error: nested extern declaration of 'Perl___notused' [-Werror=nested-externs]
dTHX; /* The function called below requires thread context */
^
cc1: all warnings being treated as errors
After digging perl5 repository, I find out that we will meet this compile error with perl from v5.21.1 to v5.25.4
--- tools/perf/util/scripting-engines/Build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/scripting-engines/Build +1 -1
@@ -1,6 +1,6 @@ libperf-$(CONFIG_LIBPERL) += trace-event-perl.o libperf-$(CONFIG_LIBPYTHON) += trace-event-python.o -CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default +CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 7/15 tools lib traceevent: Initialize lenght on OLD_RING_BUFFER_TYPE_TIME_STAMP
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (VMware)" <[email protected]>
A undefined value was being used for the OLD_RING_BUFFER_TYPE_TIME_STAMP case entry, as the 'length' variable was not being initialized, fix it.
Caught by the reporter when building tools/perf/ using clang, which emmitted this warning:
kbuffer-parse.c:312:7: warning: variable 'length' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
case OLD_RINGBUF_TYPE_TIME_EXTEND:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kbuffer-parse.c:339:29: note: uninitialized use occurs here
kbuf->next = kbuf->index + length;
^~~~~~
kbuffer-parse.c:297:21: note: initialize the variable 'length' to silence this warning
unsigned int length;
^
= 0--- tools/lib/traceevent/kbuffer-parse.c | 1 + 1 file changed, 1 insertion(+)
tools/lib/traceevent/kbuffer-parse.c +1 -0
@@ -315,6 +315,7 @@ static unsigned int old_update_pointers(struct kbuffer *kbuf) extend += delta; delta = extend; ptr +=4 ; + length =0 ;break ;case OLD_RINGBUF_TYPE_TIME_STAMP :
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 8/15 tools lib traceevent plugin function: Initialize 'index' variable
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Detected with clang:
CC /tmp/build/perf/plugin_function.o
plugin_function.c:145:6: warning: variable 'index' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (parent && ftrace_indent->set)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
plugin_function.c:148:29: note: uninitialized use occurs here
trace_seq_printf(s, "%*s", index*3, "");
^~~~~
plugin_function.c:145:2: note: remove the 'if' if its condition is always true
if (parent && ftrace_indent->set)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plugin_function.c:145:6: warning: variable 'index' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
if (parent && ftrace_indent->set)
^~~~~~
plugin_function.c:148:29: note: uninitialized use occurs here
trace_seq_printf(s, "%*s", index*3, "");
^~~~~
plugin_function.c:145:6: note: remove the '&&' if its condition is always true
if (parent && ftrace_indent->set)
^~~~~~~~~
plugin_function.c:133:11: note: initialize the variable 'index' to silence this warning
int index;
^
= 02 warnings generated.
--- tools/lib/traceevent/plugin_function.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/plugin_function.c +1 -1
@@ -130,7 +130,7 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record,unsigned long long pfunction;const char *func;const char *parent; -int index; +int index =0 ;if (pevent_get_field_val (s, event,"ip" , record, &function,1 ))return trace_seq_putc (s,'!' );
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 9/15 perf evsel: Inform how to make a sysctl setting permanent
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
When a tool can't open counters due to the kernel.perf_event_paranoit sysctl setting, we inform how to tweak it to allow the operation to succeed, in addition to that, suggest setting /etc/sysctl.conf to make the setting permanent.
--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/evsel.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-)
tools/perf/builtin-record.c +1 -1
@@ -418,7 +418,7 @@ static int record__mmap(struct record *rec)static int record__open (struct record *rec) { -char msg[512 ]; +char msg[BUFSIZ ];struct perf_evsel *pos;struct perf_evlist *evlist = rec->evlist;struct perf_session *session = rec->session;
tools/perf/builtin-stat.c +1 -1
@@ -533,7 +533,7 @@ static int store_counter_ids(struct perf_evsel *counter)static int __run_perf_stat (int argc,const char **argv) {int interval = stat_config.interval; -char msg[512 ]; +char msg[BUFSIZ ];unsigned long long t0, t1;struct perf_evsel *counter;struct timespec ts;
tools/perf/builtin-top.c +1 -1
@@ -859,7 +859,7 @@ static void perf_top__mmap_read(struct perf_top *top)static int perf_top__start_counters (struct perf_top *top) { -char msg[512 ]; +char msg[BUFSIZ ];struct perf_evsel *counter;struct perf_evlist *evlist = top->evlist;struct record_opts *opts = &top->record_opts;
tools/perf/util/evsel.c +3 -1
@@ -2469,7 +2469,9 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target," -1: Allow use of (almost) all events by all users\n" ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n" ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n" -">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN" , +">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN\n\n" +"To make this setting permanent, edit /etc/sysctl.conf too, e.g.:\n\n" +" kernel.perf_event_paranoid = -1\n" , target->system_wide ?"system-wide " :"" , perf_event_paranoid());case ENOENT :
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 10/15 perf symbols: No need to check if sym->name is NULL
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As it is an array, so will always evaluate to 'true', as reported by clang:
builtin-sched.c:2070:19: error: address of array 'sym->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
if (sym && sym->name) {
~~ ~~~~~^~~~1 warning generated.
So just ditch all those useless checks.
--- tools/perf/builtin-kmem.c | 4 ++-- tools/perf/builtin-sched.c | 2 +- tools/perf/util/evsel_fprintf.c | 1 - tools/perf/util/machine.c | 2 +- tools/perf/util/symbol_fprintf.c | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-)
tools/perf/builtin-kmem.c +2 -2
@@ -1065,7 +1065,7 @@ static void __print_page_alloc_result(struct perf_session *session, int n_lines) data = rb_entry(next, struct page_stat, node); sym =machine__find_kernel_function (machine, data->callsite, &map); -if (sym && sym->name) +if (sym) caller = sym->name;else scnprintf (buf,sizeof (buf),"%" PRIx64, data->callsite);
@@ -1107,7 +1107,7 @@ static void __print_page_caller_result(struct perf_session *session, int n_lines data = rb_entry(next, struct page_stat, node); sym =machine__find_kernel_function (machine, data->callsite, &map); -if (sym && sym->name) +if (sym) caller = sym->name;else scnprintf (buf,sizeof (buf),"%" PRIx64, data->callsite);
tools/perf/builtin-sched.c +1 -1
@@ -2067,7 +2067,7 @@ static void save_task_callchain(struct perf_sched *sched,break ; sym = node->sym; -if (sym && sym->name) { +if (sym) {if (!strcmp (sym->name,"schedule" ) || !strcmp (sym->name,"__schedule" ) || !strcmp (sym->name,"preempt_schedule" ))
tools/perf/util/evsel_fprintf.c +0 -1
@@ -168,7 +168,6 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,if (symbol_conf.bt_stop_list && node->sym && - node->sym->name &&strlist__has_entry (symbol_conf.bt_stop_list, node->sym->name)) {break ;
tools/perf/util/machine.c +1 -1
@@ -1565,7 +1565,7 @@ int machine__process_event(struct machine *machine, union perf_event *event,static bool symbol__match_regex (struct symbol *sym,regex_t *regex) { -if (sym->name && !regexec (regex, sym->name,0 ,NULL ,0 )) +if (!regexec (regex, sym->name,0 ,NULL ,0 ))return 1 ;return 0 ; }
tools/perf/util/symbol_fprintf.c +1 -1
@@ -21,7 +21,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym,unsigned long offset;size_t length; -if (sym && sym->name) { +if (sym) { length =fprintf (fp,"%s" , sym->name);if (al && print_offsets) {if (al->addr < sym->end)
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 11/15 perf tests record: No need to test an array against NULL
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It will always evaluate to 'true', as clang warns:
CC /tmp/build/perf/tests/perf-record.o
CC /tmp/build/perf/tests/evsel-roundtrip-name.o
tests/perf-record.c:69:24: error: comparison of array 'argv' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
if (evlist == NULL || argv == NULL) {
^~~~ ~~~~1 error generated.
--- tools/perf/tests/perf-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/perf-record.c +1 -1
@@ -66,7 +66,7 @@ int test__PERF_RECORD(int subtest __maybe_unused)if (evlist ==NULL )/* Fallback for kernels lacking PERF_COUNT_SW_DUMMY */ evlist =perf_evlist__new_default (); -if (evlist ==NULL || argv ==NULL ) { +if (evlist ==NULL ) {pr_debug ("Not enough memory to create evlist\n" ); goto out; }
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 12/15 perf symbols: dso->name is an array, no need to check it against NULL
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As it will always evaluate to 'true', as reported by clang:
util/map.c:390:36: error: address of array 'map->dso->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
if (map && map->dso && (map->dso->name || map->dso->long_name)) {
~~~~~~~~~~^~~~ ~~
util/map.c:393:22: error: address of array 'map->dso->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
else if (map->dso->name)
~~ ~~~~~~~~~~^~~~--- tools/perf/util/map.c | 4 ++-- tools/perf/util/scripting-engines/trace-event-perl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/map.c +2 -2
@@ -387,10 +387,10 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp) {const char *dsoname ="[unknown]" ; -if (map && map->dso && (map->dso->name || map->dso->long_name)) { +if (map && map->dso) {if (symbol_conf.show_kernel_path && map->dso->long_name) dsoname = map->dso->long_name; -else if (map->dso->name) +else dsoname = map->dso->name; }
tools/perf/util/scripting-engines/trace-event-perl.c +2 -2
@@ -309,10 +309,10 @@ static SV *perl_process_callchain(struct perf_sample *sample,if (node->map) {struct map *map = node->map;const char *dsoname ="[unknown]" ; -if (map && map->dso && (map->dso->name || map->dso->long_name)) { +if (map && map->dso) {if (symbol_conf.show_kernel_path && map->dso->long_name) dsoname = map->dso->long_name; -else if (map->dso->name) +else dsoname = map->dso->name; }if (!hv_stores (elem,"dso" ,newSVpv (dsoname,0 ))) {
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 13/15 samples/bpf: Add missing header
In reply to Arnaldo Carvalho de MeloFrom: Mickaël Salaün <[email protected]>
Include unistd.h to define __NR_getuid and __NR_getsid.
--- samples/bpf/tracex5_kern.c | 1 + 1 file changed, 1 insertion(+)
samples/bpf/tracex5_kern.c +1 -0
@@ -8,6 +8,7 @@#include <linux/version.h> #include <uapi/linux/bpf.h> #include <uapi/linux/seccomp.h> +#include <uapi/linux/unistd.h> #include "bpf_helpers.h" #define PROG (F ) SEC("kprobe/"__stringify(F)) int bpf_func_##F
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 14/15 samples/bpf: Ignore already processed ELF sections
In reply to Arnaldo Carvalho de MeloFrom: Mickaël Salaün <[email protected]>
Add a missing check for the map fixup loop.
--- samples/bpf/bpf_load.c | 2 ++ 1 file changed, 2 insertions(+)
samples/bpf/bpf_load.c +2 -0
@@ -328,6 +328,8 @@ int load_bpf_file(char *path)/* load programs that need map fixup (relocations) */ for (i =1 ; i < ehdr.e_shnum; i++) { +if (processed_sec[i]) +continue ;if (get_sec (elf, i, &ehdr, &shname, &shdr, &data))continue ;
Signature · 1 line
2.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 15/15 samples/bpf: Reset global variables
In reply to Arnaldo Carvalho de MeloFrom: Mickaël Salaün <[email protected]>
Before loading a new ELF, clean previous kernel version, license and processed sections.
--- samples/bpf/bpf_load.c | 5 +++++ 1 file changed, 5 insertions(+)
samples/bpf/bpf_load.c +5 -0
@@ -277,6 +277,11 @@ int load_bpf_file(char *path)Elf_Data *data, *data_prog, *symbols =NULL ;char *shname, *shname_prog; +/* reset global variables */ + kern_version =0 ; +memset (license,0 ,sizeof (license)); +memset (processed_sec,0 ,sizeof (processed_sec)); +if (elf_version (EV_CURRENT ) ==EV_NONE )return 1 ;
Signature · 1 line
2.9.3
Quoted 100 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit
f2029b1e47b607619d1dd2cb0bbb77f64ec6b7c2:perf/x86/intel: Add Kaby Lake support (2017-02-11 21:28:23 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-4.11-20170213for you to fetch changes up to
a734fb5d60067a73dd7099a58756847c07f9cd68:
samples/bpf: Reset global variables (2017-02-13 17:22:53 -0300)----------------------------------------------------------------
perf/core improvements and fixes:New feature:
- Introduce the 'delta-abs' 'perf diff' compute method, that orders the histogram entries by the absolute value of the percentage delta for a function in two perf.data files, i.e. the functions that changed the most (increase or decrease in samples) comes first (Namhyung Kim)
User visible:
- Improve message about tweaking the kernel.perf_event_paranoid setting, telling how to make the change permanent by editing
/etc/sysctl.conf(Ingo Molnar)Infrastructure:
- Introduce
linux/compiler-gcc.has a counterpart to the kernel's, initially containing the definition of__fallthrough, more to come (__maybe_unused, etc) (Arnaldo Carvalho de Melo)- Fixes for problems uncovered by building
tools/perfwith clang, such as always true tests of arrays against NULL and variables that sometimes were used without being initialized (Arnaldo Carvalho de Melo, Steven Rostedt)- Before loading a new ELF, clear global variables set by the
samples/bpfloader (Mickaël Salaün)- Ignore already processed ELF sections in the
samples/bpfloader (Mickaël Salaün)- Fix compile error in the scripting code with some perl5 versions (Wang YanQing)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (6):
tools include: Introducelinux/compiler-gcc.h
tools lib traceevent plugin function: Initialize 'index' variable perf evsel: Inform how to make a sysctl setting permanent perf symbols: No need to check ifsym->nameis NULL
perf tests record: No need to test an array against NULL perf symbols:dso->nameis an array, no need to check it against NULLMickaël Salaün (3):
samples/bpf: Add missing headersamples/bpf: Ignore already processed ELF sectionssamples/bpf: Reset global variablesNamhyung Kim (4):
perf diff: Add 'delta-abs' compute method perf diff: Add diff.order config option perf diff: Add diff.compute config option perf diff: Change default setting to "delta-abs"Steven Rostedt (VMware) (1):
tools lib traceevent: Initialize lenght onOLD_RING_BUFFER_TYPE_TIME_STAMPWang YanQing (1):
perf scripting perl: Fix compile error with some perl5 versionssamples/bpf/bpf_load.c | 7 ++ samples/bpf/tracex5_kern.c | 1 + tools/include/linux/compiler-gcc.h | 14 ++++ tools/include/linux/compiler.h | 10 +-- tools/lib/traceevent/kbuffer-parse.c | 1 + tools/lib/traceevent/plugin_function.c | 2 +- tools/perf/Documentation/perf-config.txt | 12 ++++ tools/perf/Documentation/perf-diff.txt | 15 ++++- tools/perf/MANIFEST | 1 + tools/perf/builtin-diff.c | 78 ++++++++++++++++++++-- tools/perf/builtin-kmem.c | 4 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/util/evsel.c | 4 +-
Quoted 8 lines
tools/perf/util/evsel_fprintf.c | 1 - tools/perf/util/machine.c | 2 +- tools/perf/util/map.c | 4 +- tools/perf/util/scripting-engines/Build | 2 +- .../perf/util/scripting-engines/trace-event-perl.c | 4 +- tools/perf/util/symbol_fprintf.c | 2 +- 23 files changed, 145 insertions(+), 29 deletions(-) create mode 100644 tools/include/linux/compiler-gcc.h
Pulled, thanks a lot Arnaldo!
Ingo