perf/urgent fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling,
Best Regards,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit c1883f10cfe05c707cce46d6999411c50a2413ca:
Merge tag 'perf-urgent-for-mingo-4.19-20181005' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2018-10-05 18:14:00 +0200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo-4.19-20181017
for you to fetch changes up to edeb0c90df3581b821a764052d185df985f8b8dc:
perf tools: Stop fallbacking to kallsyms for vdso symbols lookup (2018-10-17 15:56:15 -0300)
----------------------------------------------------------------
perf/urgent fixes:
- Stop fallbacking to kallsyms for vDSO symbols lookup, this wasn't being really used and is not valid in arches such as Sparc, where user and kernel space don't share the address space, relying only on cpumode to figure out what DSOs to lookup (Arnaldo Carvalho de Melo)
- Align cpu map synthesized events properly, fixing SIGBUS in CPUs like Sparc (David Miller)
- Fix use of alternatives to find JDIR (Jarod Wilson)
- Store ids for events with their own cpus when synthesizing user level event details (scale, unit, etc) events, fixing a crash when recording a PMU event with a cpumask defined (Jiri Olsa)
- Fix wrong filter_band* values for uncore Intel vendor events (Jiri Olsa)
- Fix detection of tracefs path in systems without tracefs, where that path should be the debugfs mountpoint plus "/tracing/" (Jiri Olsa)
- Pass build flags to traceevent build, allowing using alternative flags in distro packages, RPM, for instance (Jiri Olsa)
- Fix 'perf report' crash on invalid inline debug information (Milian Wolff)
- Synch kvm uapi copies (Arnaldo Carvalho de Melo)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
tools arch uapi: Sync the x86 kvm.h copy
tools headers uapi: Sync kvm.h copy
perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
David Miller (1):
perf cpu_map: Align cpu map synthesized events properly.
Jarod Wilson (1):
perf tools: Fix use of alternatives to find JDIR
Jiri Olsa (5):
Revert "perf tools: Fix PMU term format max value calculation"
perf vendor events intel: Fix wrong filter_band* values for uncore events perf evsel: Store ids for events with their own cpus perf_event__synthesize_event_update_cpus perf tools: Fix tracing_path_mount proper path
perf tools: Pass build flags to traceevent build
Milian Wolff (1):
perf report: Don't crash on invalid inline debug information
tools/arch/x86/include/uapi/asm/kvm.h | 1 + tools/include/uapi/linux/kvm.h | 1 + tools/lib/api/fs/tracing_path.c | 4 ++-- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- tools/perf/builtin-report.c | 1 + .../pmu-events/arch/x86/ivytown/uncore-power.json | 16 ++++++++-------- .../pmu-events/arch/x86/jaketown/uncore-power.json | 16 ++++++++-------- tools/perf/util/event.c | 22 +++------------------- tools/perf/util/evsel.c | 3 +++ tools/perf/util/pmu.c | 13 +++++++------ tools/perf/util/srcline.c | 3 +++ 12 files changed, 39 insertions(+), 45 deletions(-)
Test results:
The first ones are container (docker) based builds of tools/perf with and without libelf support. Where clang is available, it is also used to build perf with/without libelf, and building with LIBCLANGLLVM=1 (built-in clang) with gcc and clang when clang and its devel libraries are installed.
The objtool and samples/bpf/ builds are disabled now that I'm switching from using the sources in a local volume to fetching them from a http server to build it inside the container, to make it easier to build in a container cluster. Those will come back later.
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.
This one is being investigatd, doesn't look like its a regression introduced by this patchset.
63: probe libc's inet_pton & backtrace it with ping : FAILED!
# dm 1 alpine:3.4 : Ok gcc (Alpine 5.3.0) 5.3.0 2 alpine:3.5 : Ok gcc (Alpine 6.2.1) 6.2.1 20160822 3 alpine:3.6 : Ok gcc (Alpine 6.3.0) 6.3.0 4 alpine:3.7 : Ok gcc (Alpine 6.4.0) 6.4.0 5 alpine:3.8 : Ok gcc (Alpine 6.4.0) 6.4.0 6 alpine:edge : Ok gcc (Alpine 6.4.0) 6.4.0 7 amazonlinux:1 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) 8 amazonlinux:2 : Ok gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) 9 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 10 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) 11 centos:5 : Ok gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55) 12 centos:6 : Ok gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23) 13 centos:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) 14 clearlinux:latest : Ok gcc (Clear Linux OS for Intel Architecture) 8.2.1 20180502 15 debian:7 : Ok gcc (Debian 4.7.2-5) 4.7.2 16 debian:8 : Ok gcc (Debian 4.9.2-10+deb8u1) 4.9.2 17 debian:9 : Ok gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 18 debian:experimental : Ok gcc (Debian 8.2.0-7) 8.2.0 19 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0 20 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 8.1.0-12) 8.1.0 21 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 8.1.0-12) 8.1.0 22 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 8.1.0-12) 8.1.0 23 fedora:20 : Ok gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7) 24 fedora:21 : Ok gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) 25 fedora:22 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6) 26 fedora:23 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6) 27 fedora:24 : Ok gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) 28 fedora:24-x-ARC-uClibc : Ok arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710 29 fedora:25 : Ok gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) 30 fedora:26 : Ok gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2) 31 fedora:27 : Ok gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6) 32 fedora:28 : Ok gcc (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5) 33 fedora:rawhide : Ok gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3) 34 gentoo-stage3-amd64:latest : Ok gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0 35 mageia:5 : Ok gcc (GCC) 4.9.2 36 mageia:6 : Ok gcc (Mageia 5.5.0-1.mga6) 5.5.0 37 opensuse:13.2 : Ok gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064] 38 opensuse:42.1 : Ok gcc (SUSE Linux) 4.8.5 39 opensuse:42.2 : Ok gcc (SUSE Linux) 4.8.5 40 opensuse:42.3 : Ok gcc (SUSE Linux) 4.8.5 41 opensuse:tumbleweed : Ok gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812] 42 oraclelinux:6 : Ok gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1) 43 oraclelinux:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28.0.1) 44 ubuntu:12.04.5 : Ok gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 45 ubuntu:14.04.4 : Ok gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 46 ubuntu:14.04.4-x-linaro-arm64 : Ok aarch64-linux-gnu-gcc (Linaro GCC 5.5-2017.10) 5.5.0 47 ubuntu:16.04 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 48 ubuntu:16.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 49 ubuntu:16.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 50 ubuntu:16.04-x-powerpc : Ok powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 51 ubuntu:16.04-x-powerpc64 : Ok powerpc64-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 52 ubuntu:16.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 53 ubuntu:16.04-x-s390 : Ok s390x-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 54 ubuntu:16.10 : Ok gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005 55 ubuntu:17.10 : Ok gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0 56 ubuntu:18.04 : Ok gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0 57 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 58 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04) 7.3.0 59 ubuntu:18.04-x-m68k : Ok m68k-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 60 ubuntu:18.04-x-powerpc : Ok powerpc-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 61 ubuntu:18.04-x-powerpc64 : Ok powerpc64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 62 ubuntu:18.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 63 ubuntu:18.04-x-riscv64 : Ok riscv64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 64 ubuntu:18.04-x-s390 : Ok s390x-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 65 ubuntu:18.04-x-sh4 : Ok sh4-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 66 ubuntu:18.04-x-sparc64 : Ok sparc64-linux-gnu-gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 67 ubuntu:18.10 : Ok gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0
# uname -a
Linux seventh 4.19.0-rc8-00014-gc0cff31be705 #1 SMP Wed Oct 17 09:00:22 -03 2018 x86_64 x86_64 x86_64 GNU/Linux
# git log --oneline -1
edeb0c90df35 perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
# perf version --build-options
perf version 4.19.rc5.gedeb0c9
dwarf: [ on ] # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT
glibc: [ on ] # HAVE_GLIBC_SUPPORT
gtk2: [ on ] # HAVE_GTK2_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
libbfd: [ on ] # HAVE_LIBBFD_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
# 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: Test data source output : Ok
6: Parse event definition strings : Ok
7: Simple expression parser : Ok
8: PERF_RECORD_* events & perf_sample fields : Ok
9: Parse perf pmu format : Ok
10: DSO data read : Ok
11: DSO data cache : Ok
12: DSO data reopen : Ok
13: Roundtrip evsel->name : Ok
14: Parse sched tracepoints fields : Ok
15: syscalls:sys_enter_openat event fields : Ok
16: Setup struct perf_event_attr : Ok
17: Match and link multiple hists : Ok
18: 'import perf' in python : Ok
19: Breakpoint overflow signal handler : Ok
20: Breakpoint overflow sampling : Ok
21: Breakpoint accounting : Ok
22: Number of exit events of a simple workload : Ok
23: Software clock events period values : Ok
24: Object code reading : Ok
25: Sample parsing : Ok
26: Use a dummy software event to keep tracking : Ok
27: Parse with no sample_id_all bit set : Ok
28: Filter hist entries : Ok
29: Lookup mmap thread : Ok
30: Share thread mg : Ok
31: Sort output of hist entries : Ok
32: Cumulate child hist entries : Ok
33: Track with sched_switch : Ok
34: Filter fds with revents mask in a fdarray : Ok
35: Add fd to a fdarray, making it autogrow : Ok
36: kmod_path__parse : Ok
37: Thread map : Ok
38: LLVM search and compile :
38.1: Basic BPF llvm compile : Ok
38.2: kbuild searching : Ok
38.3: Compile source for BPF prologue generation : Ok
38.4: Compile source for BPF relocation : Ok
39: Session topology : Ok
40: BPF filter :
40.1: Basic BPF filtering : Ok
40.2: BPF pinning : Ok
40.3: BPF prologue generation : Ok
40.4: BPF relocation checker : Ok
41: Synthesize thread map : Ok
42: Remove thread map : Ok
43: Synthesize cpu map : Ok
44: Synthesize stat config : Ok
45: Synthesize stat : Ok
46: Synthesize stat round : Ok
47: Synthesize attr update : Ok
48: Event times : Ok
49: Read backward ring buffer : Ok
50: Print cpu map : Ok
51: Probe SDT events : Ok
52: is_printable_array : Ok
53: Print bitmap : Ok
54: perf hooks : Ok
55: builtin clang support : Skip (not compiled in)
56: unit_number__scnprintf : Ok
57: mem2node : Ok
58: x86 rdpmc : Ok
59: Convert perf time to TSC : Ok
60: DWARF unwind : Ok
61: x86 instruction decoder - new instructions : Ok
62: x86 bp modify : Ok
63: probe libc's inet_pton & backtrace it with ping : FAILED!
64: Check open filename arg using perf trace + vfs_getname: Ok
65: Use vfs_getname probe to get syscall args filenames : Ok
66: Add vfs_getname probe to get syscall args filenames : Ok $ make -C tools/perf build-test
make: Entering directory '/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_no_demangle_O: make NO_DEMANGLE=1
make_perf_o_O: make perf.o
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_install_O: make install
make_no_libaudit_O: make NO_LIBAUDIT=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_util_map_o_O: make util/map.o
make_no_slang_O: make NO_SLANG=1
make_tags_O: make tags
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_no_libelf_O: make NO_LIBELF=1
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_no_libpython_O: make NO_LIBPYTHON=1
make_no_libbionic_O: make NO_LIBBIONIC=1
make_no_libbpf_O: make NO_LIBBPF=1
make_help_O: make help
make_with_babeltrace_O: make LIBBABELTRACE=1
make_clean_all_O: make clean all
make_no_backtrace_O: make NO_BACKTRACE=1
make_no_libperl_O: make NO_LIBPERL=1
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_pure_O: make
make_debug_O: make DEBUG=1
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_no_libnuma_O: make NO_LIBNUMA=1
make_install_prefix_O: make install prefix=/tmp/krava
make_no_libunwind_O: make NO_LIBUNWIND=1
make_install_bin_O: make install-bin
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_static_O: make LDFLAGS=-static
make_no_newt_O: make NO_NEWT=1
make_doc_O: make doc
make_no_gtk2_O: make NO_GTK2=1
make_no_auxtrace_O: make NO_AUXTRACE=1
OK
make: Leaving directory '/home/acme/git/perf/tools/perf'
$ Arnaldo Carvalho de Melo
maintainerPATCH 1/11 tools arch uapi: Sync the x86 kvm.h copy
From: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in:
d1766202779e ("x86/kvm/lapic: always disable MMIO interface in x2APIC mode")
That at this time will not generate changes in tools such as 'perf trace', that still needs more work in tools/perf/examples/bpf/augmented_syscalls.c to need such id -> string tables.
This silences the following perf build warning:
Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h' differs from latest version at 'arch/x86/include/uapi/asm/kvm.h' diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
--- tools/arch/x86/include/uapi/asm/kvm.h | 1 + 1 file changed, 1 insertion(+)
tools/arch/x86/include/uapi/asm/kvm.h +1 -0
@@ -377,6 +377,7 @@ struct kvm_sync_regs {#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) +#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)#define KVM_STATE_NESTED_GUEST_MODE 0x00000001#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 2/11 tools headers uapi: Sync kvm.h copy
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To pick up the changes introduced in:
6fbbde9a1969 ("KVM: x86: Control guest reads of MSR_PLATFORM_INFO")
That is not yet used in tools such as 'perf trace'.
The type of the change in this file, a simple integer parameter to the KVM_CHECK_EXTENSION ioctl should be easier to implement tho, adding to the libbeauty TODO list.
This silences this perf build warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h' diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
--- tools/include/uapi/linux/kvm.h | 1 + 1 file changed, 1 insertion(+)
tools/include/uapi/linux/kvm.h +1 -0
@@ -952,6 +952,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_S390_HPAGE_1M 156#define KVM_CAP_NESTED_STATE 157#define KVM_CAP_ARM_INJECT_SERROR_ESR 158 +#define KVM_CAP_MSR_PLATFORM_INFO 159#ifdef KVM_CAP_IRQ_ROUTING
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 3/11 Revert "perf tools: Fix PMU term format max value calculation"
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
This reverts commit ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa.
Michael reported an issue with oversized terms values assignment and I noticed there was actually a misunderstanding of the max value check in the past.
The above commit's changelog says:
If bit 21 is set, there is parsing issues as below.
$ perf stat -a -e uncore_qpi_0/event=0x200002,umask=0x8/
event syntax error: '..pi_0/event=0x200002,umask=0x8/'
\___ value too big for format, maximum is 511But there's no issue there, because the event value is distributed along the value defined by the format. Even if the format defines separated bit, the value is treated as a continual number, which should follow the format definition.
In above case it's 9-bit value with last bit separated:
$ cat uncore_qpi_0/format/event config:0-7,21
Hence the value 0x200002 is correctly reported as format violation, because it exceeds 9 bits. It should have been 0x102 instead, which sets the 9th bit - the bit 21 of the format.
$ perf stat -vv -a -e uncore_qpi_0/event=0x102,umask=0x8/
Using CPUID GenuineIntel-6-2D
...
------------------------------------------------------------
perf_event_attr:
type 10
size 112
config 0x200802
sample_type IDENTIFIER
...--- tools/perf/util/pmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
tools/perf/util/pmu.c +7 -6
@@ -930,13 +930,14 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,static __u64 pmu_format_max_value (const unsigned long *format) { -__u64 w =0 ; -int fbit; - -for_each_set_bit (fbit, format,PERF_PMU_FORMAT_BITS ) - w |= (1ULL << fbit); +int w; -return w; + w =bitmap_weight (format,PERF_PMU_FORMAT_BITS ); +if (!w) +return 0 ; +if (w <64 ) +return (1ULL << w) -1 ; +return -1 ; }/*
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 4/11 perf vendor events intel: Fix wrong filter_band* values for uncore events
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Michael reported that he could not stat following event:
$ perf stat -e unc_p_freq_ge_1200mhz_cycles -a -- ls
event syntax error: '..e_1200mhz_cycles'
\___ value too big for format, maximum is 255
Run 'perf list' for a list of valid eventsThe event is unwrapped into:
uncore_pcu/event=0xb,filter_band0=1200/
where filter_band0 format says it's one byte only:
# cat uncore_pcu/format/filter_band0 config1:0-7
while JSON files specifies bigger number:
"Filter": "filter_band0=1200",
all the filter_band* formats show 1 byte width:
# cat uncore_pcu/format/filter_band1 config1:8-15 # cat uncore_pcu/format/filter_band2 config1:16-23 # cat uncore_pcu/format/filter_band3 config1:24-31
The reason of the issue is that filter_band* values are supposed to be in 100Mhz units.. it's stated in the JSON help for the events, like:
filter_band3=XXX, with XXX in 100Mhz units
This patch divides the filter_band* values by 100, plus there's couple of changes that actually change the number completely, like:
- "Filter": "edge=1,filter_band2=4000",
+ "Filter": "edge=1,filter_band2=30",
--- tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json | 16 ++++++++-------- .../perf/pmu-events/arch/x86/jaketown/uncore-power.json | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-)
tools/perf/pmu-events/arch/x86/ivytown/uncore-power.json +8 -8
@@ -188,7 +188,7 @@ "Counter": "0,1,2,3", "EventCode": "0xb", "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES", - "Filter": "filter_band0=1200", + "Filter": "filter_band0=12", "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_1200mhz_cycles %", "PerPkg": "1",
@@ -199,7 +199,7 @@ "Counter": "0,1,2,3", "EventCode": "0xc", "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES", - "Filter": "filter_band1=2000", + "Filter": "filter_band1=20", "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_2000mhz_cycles %", "PerPkg": "1",
@@ -210,7 +210,7 @@ "Counter": "0,1,2,3", "EventCode": "0xd", "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES", - "Filter": "filter_band2=3000", + "Filter": "filter_band2=30", "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_3000mhz_cycles %", "PerPkg": "1",
@@ -221,7 +221,7 @@ "Counter": "0,1,2,3", "EventCode": "0xe", "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES", - "Filter": "filter_band3=4000", + "Filter": "filter_band3=40", "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_4000mhz_cycles %", "PerPkg": "1",
@@ -232,7 +232,7 @@ "Counter": "0,1,2,3", "EventCode": "0xb", "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band0=1200", + "Filter": "edge=1,filter_band0=12", "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_1200mhz_cycles %", "PerPkg": "1",
@@ -243,7 +243,7 @@ "Counter": "0,1,2,3", "EventCode": "0xc", "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band1=2000", + "Filter": "edge=1,filter_band1=20", "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_2000mhz_cycles %", "PerPkg": "1",
@@ -254,7 +254,7 @@ "Counter": "0,1,2,3", "EventCode": "0xd", "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band2=4000", + "Filter": "edge=1,filter_band2=30", "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_3000mhz_cycles %", "PerPkg": "1",
@@ -265,7 +265,7 @@ "Counter": "0,1,2,3", "EventCode": "0xe", "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band3=4000", + "Filter": "edge=1,filter_band3=40", "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_4000mhz_cycles %", "PerPkg": "1",
tools/perf/pmu-events/arch/x86/jaketown/uncore-power.json +8 -8
@@ -187,7 +187,7 @@ "Counter": "0,1,2,3", "EventCode": "0xb", "EventName": "UNC_P_FREQ_GE_1200MHZ_CYCLES", - "Filter": "filter_band0=1200", + "Filter": "filter_band0=12", "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_1200mhz_cycles %", "PerPkg": "1",
@@ -198,7 +198,7 @@ "Counter": "0,1,2,3", "EventCode": "0xc", "EventName": "UNC_P_FREQ_GE_2000MHZ_CYCLES", - "Filter": "filter_band1=2000", + "Filter": "filter_band1=20", "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_2000mhz_cycles %", "PerPkg": "1",
@@ -209,7 +209,7 @@ "Counter": "0,1,2,3", "EventCode": "0xd", "EventName": "UNC_P_FREQ_GE_3000MHZ_CYCLES", - "Filter": "filter_band2=3000", + "Filter": "filter_band2=30", "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_3000mhz_cycles %", "PerPkg": "1",
@@ -220,7 +220,7 @@ "Counter": "0,1,2,3", "EventCode": "0xe", "EventName": "UNC_P_FREQ_GE_4000MHZ_CYCLES", - "Filter": "filter_band3=4000", + "Filter": "filter_band3=40", "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_4000mhz_cycles %", "PerPkg": "1",
@@ -231,7 +231,7 @@ "Counter": "0,1,2,3", "EventCode": "0xb", "EventName": "UNC_P_FREQ_GE_1200MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band0=1200", + "Filter": "edge=1,filter_band0=12", "MetricExpr": "(UNC_P_FREQ_GE_1200MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_1200mhz_cycles %", "PerPkg": "1",
@@ -242,7 +242,7 @@ "Counter": "0,1,2,3", "EventCode": "0xc", "EventName": "UNC_P_FREQ_GE_2000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band1=2000", + "Filter": "edge=1,filter_band1=20", "MetricExpr": "(UNC_P_FREQ_GE_2000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_2000mhz_cycles %", "PerPkg": "1",
@@ -253,7 +253,7 @@ "Counter": "0,1,2,3", "EventCode": "0xd", "EventName": "UNC_P_FREQ_GE_3000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band2=4000", + "Filter": "edge=1,filter_band2=30", "MetricExpr": "(UNC_P_FREQ_GE_3000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_3000mhz_cycles %", "PerPkg": "1",
@@ -264,7 +264,7 @@ "Counter": "0,1,2,3", "EventCode": "0xe", "EventName": "UNC_P_FREQ_GE_4000MHZ_TRANSITIONS", - "Filter": "edge=1,filter_band3=4000", + "Filter": "edge=1,filter_band3=40", "MetricExpr": "(UNC_P_FREQ_GE_4000MHZ_CYCLES / UNC_P_CLOCKTICKS) * 100.", "MetricName": "freq_ge_4000mhz_cycles %", "PerPkg": "1",
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 5/11 perf evsel: Store ids for events with their own cpus perf_event__synthesize_event_update_cpus
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
John reported crash when recording on an event under PMU with cpumask defined:
root at localhost:~# ./perf_debug_ record -e armv8_pmuv3_0/br_mis_pred/ sleep 1
perf: Segmentation fault
Obtained 9 stack frames.
./perf_debug_() [0x4c5ef8]
[0xffff82ba267c]
./perf_debug_() [0x4bc5a8]
./perf_debug_() [0x419550]
./perf_debug_() [0x41a928]
./perf_debug_() [0x472f58]
./perf_debug_() [0x473210]
./perf_debug_() [0x4070f4] /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0xe0) [0xffff8294c8a0] Segmentation fault (core dumped)
We synthesize an update event that needs to touch the evsel id array, which is not defined at that time. Fixing this by forcing the id allocation for events with their own cpus.
--- tools/perf/builtin-report.c | 1 + tools/perf/util/evsel.c | 3 +++ 2 files changed, 4 insertions(+)
tools/perf/builtin-report.c +1 -0
@@ -981,6 +981,7 @@ int cmd_report(int argc, const char **argv) .id_index = perf_event__process_id_index, .auxtrace_info = perf_event__process_auxtrace_info, .auxtrace = perf_event__process_auxtrace, + .event_update = perf_event__process_event_update, .feature = process_feature_event, .ordered_events = true, .ordering_requires_timestamps = true,
tools/perf/util/evsel.c +3 -0
@@ -1089,6 +1089,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, attr->exclude_user =1 ; } +if (evsel->own_cpus) + evsel->attr.read_format |=PERF_FORMAT_ID ; +/* * Apply event specific term settings, * it overloads any global configuration.
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 6/11 perf tools: Fix use of alternatives to find JDIR
In reply to Arnaldo Carvalho de MeloFrom: Jarod Wilson <[email protected]>
When a build is run from something like a cron job, the user's $PATH is rather minimal, of note, not including /usr/sbin in my own case. Because of that, an automated rpm package build ultimately fails to find libperf-jvmti.so, because somewhere within the build, this happens...
/bin/sh: alternatives: command not found
/bin/sh: alternatives: command not found
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
...and while the build continues, libperf-jvmti.so isn't built, and things fall down when rpm tries to find all the %files specified. Exact same system builds everything just fine when the job is launched from a login shell instead of a cron job, since alternatives is in $PATH, so openjdk is actually found.
The test required to get into this section of code actually specifies the full path, as does a block just above it, so let's do that here too.
--- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -833,7 +833,7 @@ ifndef NO_JVMTI 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') + JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g') endif endif ifndef JDIR
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 7/11 perf tools: Fix tracing_path_mount proper path
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
If there's no tracefs (RHEL7) support the tracing_path_mount returns debugfs path which results in following fail:
# perf probe sys_write kprobe_events file does not exist - please rebuild kernel with CONFIG_KPROBE_EVENTS. Error: Failed to add events.
In tracing_path_debugfs_mount function we need to return the 'tracing' path instead of just the mount to make it work:
# perf probe sys_write
Added new event:
probe:sys_write (on sys_write)You can now use it in all perf tools, such as:
perf record -e probe:sys_write -aR sleep 1
Adding the 'return tracing_path;' also to tracing_path_tracefs_mount function just for consistency with tracing_path_debugfs_mount.
Upstream keeps working, because it has the tracefs support.
--- tools/lib/api/fs/tracing_path.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/api/fs/tracing_path.c +2 -2
@@ -36,7 +36,7 @@ static const char *tracing_path_tracefs_mount(void)__tracing_path_set ("" , mnt); -return mnt; +return tracing_path; }static const char *tracing_path_debugfs_mount (void )
@@ -49,7 +49,7 @@ static const char *tracing_path_debugfs_mount(void)__tracing_path_set ("tracing/" , mnt); -return mnt; +return tracing_path; }const char *tracing_path_mount (void )
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 8/11 perf cpu_map: Align cpu map synthesized events properly.
In reply to Arnaldo Carvalho de MeloFrom: David Miller <[email protected]>
The size of the resulting cpu map can be smaller than a multiple of sizeof(u64), resulting in SIGBUS on cpus like Sparc as the next event will not be aligned properly.
--- tools/perf/util/event.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/event.c +1 -0
@@ -1081,6 +1081,7 @@ void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max } *size +=sizeof (struct cpu_map_data ); + *size =PERF_ALIGN (*size,sizeof (u64));return zalloc (*size); }
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 9/11 perf report: Don't crash on invalid inline debug information
In reply to Arnaldo Carvalho de MeloFrom: Milian Wolff <[email protected]>
When the function name for an inline frame is invalid, we must not try to demangle this symbol, otherwise we crash with:
#0 0x0000555555895c01 in bfd_demangle ()
#1 0x0000555555823262 in demangle_sym (dso=0x555555d92b90, elf_name=0x0, kmodule=0) at util/symbol-elf.c:215
#2 dso__demangle_sym (dso=dso@entry=0x555555d92b90, kmodule=<optimized out>, kmodule@entry=0, elf_name=elf_name@entry=0x0) at util/symbol-elf.c:400
#3 0x00005555557fef4b in new_inline_sym (funcname=0x0, base_sym=0x555555d92b90, dso=0x555555d92b90) at util/srcline.c:89
#4 inline_list__append_dso_a2l (dso=dso@entry=0x555555c7bb00, node=node@entry=0x555555e31810, sym=sym@entry=0x555555d92b90) at util/srcline.c:264
#5 0x00005555557ff27f in addr2line (dso_name=dso_name@entry=0x555555d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf", addr=addr@entry=2888, file=file@entry=0x0,
line=line@entry=0x0, dso=dso@entry=0x555555c7bb00, unwind_inlines=unwind_inlines@entry=true, node=0x555555e31810, sym=0x555555d92b90) at util/srcline.c:313
#6 0x00005555557ffe7c in addr2inlines (sym=0x555555d92b90, dso=0x555555c7bb00, addr=2888, dso_name=0x555555d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf")
at util/srcline.c:358So instead handle the case where we get invalid function names for inlined frames and use a fallback '??' function name instead.
While this crash was originally reported by Hadrien for rust code, I can now also reproduce it with trivial C++ code. Indeed, it seems like libbfd fails to interpret the debug information for the inline frame symbol name:
$ addr2line -e /home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf -if b48 main /usr/include/c++/8.2.1/complex:610 ?? /usr/include/c++/8.2.1/complex:618 ?? /usr/include/c++/8.2.1/complex:675 ?? /usr/include/c++/8.2.1/complex:685 main /home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
I've reported this bug upstream and also attached a patch there which should fix this issue:
https://sourceware.org/bugzilla/show_bug.cgi?id=23715
[ The above 'Fixes:' cset is where originally the problem was
introduced, i.e. using a2l->funcname without checking if it is NULL, but this current patch fixes the current codebase, i.e. multiple csets were applied after a64489c56c30 before the problem was reported by Hadrien ]
--- tools/perf/util/srcline.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/srcline.c +3 -0
@@ -85,6 +85,9 @@ static struct symbol *new_inline_sym(struct dso *dso,struct symbol *inline_sym;char *demangled =NULL ; +if (!funcname) + funcname ="??" ; +if (dso) { demangled =dso__demangle_sym (dso,0 , funcname);if (demangled)
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 10/11 perf tools: Pass build flags to traceevent build
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
So the extra user build flags are propagated to libtraceevent.
--- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
@@ -635,7 +635,7 @@ $(LIBPERF_IN): prepare FORCE $(LIB_FILE): $(LIBPERF_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIB_OBJS) -LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) +LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)' $(LIBTRACEEVENT): FORCE $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
Signature · 1 line
2.14.4
Arnaldo Carvalho de Melo
maintainerPATCH 11/11 perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).
This causes problems because the tests driving this code path use machine__kernel_ip(), and that is completely meaningless on Sparc. On sparc64 the kernel and user live in physically separate virtual address spaces, rather than a shared one. And the kernel lives at a virtual address that overlaps common userspace addresses. So this test passes almost all the time when a user symbol lookup fails.
The consequence of this is that, if the unfound user virtual address in the sample doesn't match up to a kernel symbol either, we trigger things like this code in builtin-top.c:
if (al.sym == NULL && al.map != NULL) {
const char *msg = "Kernel samples will not be resolved.\n";
/*
* As we do lazy loading of symtabs we only will know if the
* specified vmlinux file is invalid when we actually have a
* hit in kernel space and then try to load it. So if we get
* here and there are _no_ symbols in the DSO backing the
* kernel map, bail out.
*
* We may never get here, for instance, if we use -K/
* --hide-kernel-symbols, even if the user specifies an
* invalid --vmlinux ;-)
*/
if (!machine->kptr_restrict_warned && !top->vmlinux_warned &&
__map__is_kernel(al.map) && map__has_symbols(al.map)) {
if (symbol_conf.vmlinux_name) {
char serr[256];
dso__strerror_load(al.map->dso, serr, sizeof(serr));
ui__warning("The %s file can't be used: %s\n%s",
symbol_conf.vmlinux_name, serr, msg);
} else {
ui__warning("A vmlinux file was not found.\n%s",
msg);
}
if (use_browser <= 0)
sleep(5);
top->vmlinux_warned = true;
}
}When I fire up a compilation on sparc, this triggers immediately.
I'm trying to figure out what the "backup to kernel map" code is accomplishing.
I see some language in the current code and in the changes that have happened in this area talking about vdso. Does that really happen?
The vdso is mapped into userspace virtual addresses, not kernel ones.
More history. This didn't cause problems on sparc some time ago, because the kernel IP check used to be "ip < 0" :-) Sparc kernel addresses are not negative. But now with machine__kernel_ip(), which works using the symbol table determined kernel address range, it does trigger.
What it all boils down to is that on architectures like sparc, machine__kernel_ip() should always return false in this scenerio, and therefore this kind of logic:
if (cpumode == PERF_RECORD_MISC_USER && machine &&
mg != &machine->kmaps &&
machine__kernel_ip(machine, al->addr)) {is basically invalid. PERF_RECORD_MISC_USER implies no kernel address can possibly match for the sample/event in question (no matter how hard you try!) :-)
</>
So, I thought something had changed and in the past we would somehow find that address in the kallsyms, but I couldn't find anything to back that up, the patch introducing this is over a decade old, lots of things changed, so I was just thinking I was missing something.
I tried a gtod busy loop to generate vdso activity and added a 'perf probe' at that branch, on x86_64 to see if it ever gets hit:
Made thread__find_map() noinline, as 'perf probe' in lines of inline functions seems to not be working, only at function start. (Masami?)
# perf probe -x ~/bin/perf -L thread__find_map:57
<thread__find_map@/home/acme/git/perf/tools/perf/util/event.c:57>
57 if (cpumode == PERF_RECORD_MISC_USER && machine &&
58 mg != &machine->kmaps &&
59 machine__kernel_ip(machine, al->addr)) {
60 mg = &machine->kmaps;
61 load_map = true;
62 goto try_again;
}
} else {
/*
* Kernel maps might be changed when loading
* symbols so loading
* must be done prior to using kernel maps.
*/
69 if (load_map)
70 map__load(al->map);
71 al->addr = al->map->map_ip(al->map, al->addr); # perf probe -x ~/bin/perf thread__find_map:60
Added new event:
probe_perf:thread__find_map (on thread__find_map:60 in /home/acme/bin/perf)You can now use it in all perf tools, such as:
perf record -e probe_perf:thread__find_map -aR sleep 1
#
Then used this to see if, system wide, those probe points were being hit:
# perf trace -e *perf:thread*/max-stack=8/ ^C[root@jouet ~]#
No hits when running 'perf top' and:
# cat gtod.c #include <sys/time.h>
int main(void)
{
struct timeval tv;
while (1)
gettimeofday(&tv, 0);
return 0; }
[root@jouet c]# ./gtod
^C
Pressed 'P' in 'perf top' and the [vdso] samples are there:
62.84% [vdso] [.] __vdso_gettimeofday 8.13% gtod [.] main 7.51% [vdso] [.] 0x0000000000000914 5.78% [vdso] [.] 0x0000000000000917 5.43% gtod [.] _init 2.71% [vdso] [.] 0x000000000000092d 0.35% [kernel] [k] native_io_delay 0.33% libc-2.26.so [.] __memmove_avx_unaligned_erms 0.20% [vdso] [.] 0x000000000000091d 0.17% [i2c_i801] [k] i801_access 0.06% firefox [.] free 0.06% libglib-2.0.so.0.5400.3 [.] g_source_iter_next 0.05% [vdso] [.] 0x0000000000000919 0.05% libpthread-2.26.so [.] __pthread_mutex_lock 0.05% libpixman-1.so.0.34.0 [.] 0x000000000006d3a7 0.04% [kernel] [k] entry_SYSCALL_64_trampoline 0.04% libxul.so [.] style::dom_apis::query_selector_slow 0.04% [kernel] [k] module_get_kallsym 0.04% firefox [.] malloc 0.04% [vdso] [.] 0x0000000000000910
I added a 'perf probe' to thread__find_map:69, and that surely got tons of hits, i.e. for every map found, just to make sure the 'perf probe' command was really working.
In the process I noticed a bug, we're only have records for '[vdso]' for pre-existing commands, i.e. ones that are running when we start 'perf top', when we will generate the PERF_RECORD_MMAP by looking at /perf/PID/maps.
I.e. like this, for preexisting processes with a vdso map, again, tracing for all the system, only pre-existing processes get a [vdso] map (when having one):
[root@jouet ~]# perf probe -x ~/bin/perf __machine__addnew_vdso
Added new event:
probe_perf:__machine__addnew_vdso (on __machine__addnew_vdso in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:__machine__addnew_vdso -aR sleep 1
[root@jouet ~]# perf trace -e probe_perf:__machine__addnew_vdso/max-stack=8/
0.000 probe_perf:__machine__addnew_vdso:(568eb3)
__machine__addnew_vdso (/home/acme/bin/perf)
map__new (/home/acme/bin/perf)
machine__process_mmap2_event (/home/acme/bin/perf)
machine__process_event (/home/acme/bin/perf)
perf_event__process (/home/acme/bin/perf)
perf_tool__process_synth_event (/home/acme/bin/perf)
perf_event__synthesize_mmap_events (/home/acme/bin/perf)
__event__synthesize_thread (/home/acme/bin/perf)The kernel is generating a PERF_RECORD_MMAP for vDSOs, but somehow 'perf top' is not getting those records while 'perf record' is:
# perf record ~acme/c/gtod ^C[ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.076 MB perf.data (1499 samples) ]
# perf report -D | grep PERF_RECORD_MMAP2
71293612401913 0x11b48 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x400000(0x1000) @ 0 fd:02 1137 541179306]: r-xp /home/acme/c/gtod
71293612419012 0x11be0 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x7fa4a2783000(0x227000) @ 0 fd:00 3146370 854107250]: r-xp /usr/lib64/ld-2.26.so
71293612432110 0x11c50 [0x60]: PERF_RECORD_MMAP2 25484/25484: [0x7ffcdb53a000(0x2000) @ 0 00:00 0 0]: r-xp [vdso]
71293612509944 0x11cb0 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x7fa4a23cd000(0x3b6000) @ 0 fd:00 3149723 262067164]: r-xp /usr/lib64/libc-2.26.so
#
# perf script | grep vdso | head
gtod 25484 71293.612768: 2485554 cycles:ppp: 7ffcdb53a914 [unknown] ([vdso])
gtod 25484 71293.613576: 2149343 cycles:ppp: 7ffcdb53a917 [unknown] ([vdso])
gtod 25484 71293.614274: 1814652 cycles:ppp: 7ffcdb53aca8 __vdso_gettimeofday+0x98 ([vdso])
gtod 25484 71293.614862: 1669070 cycles:ppp: 7ffcdb53acc5 __vdso_gettimeofday+0xb5 ([vdso])
gtod 25484 71293.615404: 1451589 cycles:ppp: 7ffcdb53acc5 __vdso_gettimeofday+0xb5 ([vdso])
gtod 25484 71293.615999: 1269941 cycles:ppp: 7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
gtod 25484 71293.616405: 1177946 cycles:ppp: 7ffcdb53a914 [unknown] ([vdso])
gtod 25484 71293.616775: 1121290 cycles:ppp: 7ffcdb53ac47 __vdso_gettimeofday+0x37 ([vdso])
gtod 25484 71293.617150: 1037721 cycles:ppp: 7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
gtod 25484 71293.617478: 994526 cycles:ppp: 7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
#The patch is the obvious one and with it we also continue to resolve vdso symbols for pre-existing processes in 'perf top' and for all processes in 'perf record' + 'perf report/script'.
--- tools/perf/util/event.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
tools/perf/util/event.c +2 -19
@@ -1561,26 +1561,9 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,return NULL ; } -try_again: + al->map =map_groups__find (mg, al->addr); -if (al->map ==NULL ) { -/* -* If this is outside of all known maps, and is a negative -* address, try to look it up in the kernel dso, as it might be -* a vsyscall or vdso (which executes in user-mode). -* -* XXX This is nasty, we should have a symbol list in the -* "[vdso]" dso, but for now lets use the old trick of looking -* in the whole kernel symbol list. -*/ -if (cpumode ==PERF_RECORD_MISC_USER && machine && - mg != &machine->kmaps && -machine__kernel_ip (machine, al->addr)) { - mg = &machine->kmaps; - load_map = true; - goto try_again; - } - }else { +if (al->map !=NULL ) {/* * Kernel maps might be changed when loading symbols so loading * must be done prior to using kernel maps.
Signature · 1 line
2.14.4
Adrian Hunter
reviewerRe: [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).
I don't think this is a complete fix because it exposes new problems. This code caters for branches from kernel space to user space and vice versa. That is, since there is only one cpumode so it is certain to be wrong for either 'ip' or 'addr' when they are not both in the kernel or both in userspace.
Quoted 47 lines
Cc Adrian Hunter <[email protected]>Cc David Ahern <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Wang Nan <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/perf/util/event.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)tools/perf/util/event.c +2
-19@@ -1561,26 +1561,9 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,return NULL ; } -try_again: + al->map =map_groups__find (mg, al->addr); -if (al->map ==NULL ) { -/* -* If this is outside of all known maps, and is a negative -* address, try to look it up in the kernel dso, as it might be -* a vsyscall or vdso (which executes in user-mode). -* -* XXX This is nasty, we should have a symbol list in the -* "[vdso]" dso, but for now lets use the old trick of looking -* in the whole kernel symbol list. -*/ -if (cpumode ==PERF_RECORD_MISC_USER && machine && - mg != &machine->kmaps && -machine__kernel_ip (machine, al->addr)) { - mg = &machine->kmaps; - load_map = true; - goto try_again; - } - }else { +if (al->map !=NULL ) {/* * Kernel maps might be changed when loading symbols so loading * must be done prior to using kernel maps.
Re: [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
Hi,
Quoted 10 lines · Adrian Hunter
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).I don't think this is a complete fix because it exposes new problems.
This commit broke function name resolution for 'perf record -g' for me.
What I mean is, with this commit applied:
$ ./tools/perf/perf record -g -- sleep 1
$ ./tools/perf/perf report
'perf report' doesn't seem to be able to show the function names of the trace.
If I revert this commit, function names are resolved fine.
Quoted 44 lines
This code caters for branches from kernel space to user space and vice versa. That is, since there is only one cpumode so it is certain to be wrong for either 'ip' or 'addr' when they are not both in the kernel or both in userspace.
Quoted 39 lines
Cc Adrian Hunter <[email protected]>Cc David Ahern <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Wang Nan <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/perf/util/event.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)tools/perf/util/event.c +1
-16@@ -1561,26 +1561,9 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,return NULL ; } -try_again: + al->map =map_groups__find (mg, al->addr); -if (al->map ==NULL ) { -/* -* If this is outside of all known maps, and is a negative -* address, try to look it up in the kernel dso, as it might be -* a vsyscall or vdso (which executes in user-mode). -* -* XXX This is nasty, we should have a symbol list in the -* "[vdso]" dso, but for now lets use the old trick of looking -* in the whole kernel symbol list. -*/ -if (cpumode ==PERF_RECORD_MISC_USER && machine && - mg != &machine->kmaps && -machine__kernel_ip (machine, al->addr)) { - mg = &machine->kmaps; - load_map = true;
Quoted 8 lines
tools/perf/util/event.c struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr, · line 1569
Quoted 8 lines
tools/perf/util/event.c +1
-3- goto try_again; - } - }else { +if (al->map !=NULL ) {/* * Kernel maps might be changed when loading symbols so loading * must be done prior to using kernel maps.
--
Vinicius
Re: [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
Quoted 19 lines · Vinicius Costa Gomes
Hi,
Quoted 10 lines · Adrian Hunter
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).I don't think this is a complete fix because it exposes new problems.
This commit broke function name resolution for 'perf record -g' for me.
What I mean is, with this commit applied:
Quoted 8 lines
$ ./tools/perf/perf record -g -- sleep 1$ ./tools/perf/perf report'perf report' doesn't seem to be able to show the function names of the trace.
If I revert this commit, function names are resolved fine.
that commit just showed up some places where we have the ip resolve wrong.. would attached patch fix it for you?
jirka
---
tools/perf/util/machine.c +4 -4
@@ -1824,7 +1824,7 @@ static void ip__resolve_ams(struct thread *thread,* Thus, we have to try consecutively until we find a match * or else, the symbol is unknown */ -thread__find_cpumode_addr_location (thread, ip, &al); +thread__find_cpumode_addr_location (thread, ip, &al,NULL ); ams->addr = ip; ams->al_addr = al.addr;
@@ -1909,8 +1909,8 @@ static int add_callchain_ip(struct thread *thread, al.filtered =0 ; al.sym =NULL ; -if (!cpumode) { -thread__find_cpumode_addr_location (thread, ip, &al); +if (!cpumode || *cpumode ==PERF_RECORD_MISC_CPUMODE_UNKNOWN ) { +thread__find_cpumode_addr_location (thread, ip, &al, cpumode); }else {if (ip >=PERF_CONTEXT_MAX ) {switch (ip) {
@@ -2151,7 +2151,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,struct branch_stack *branch = sample->branch_stack;struct ip_callchain *chain = sample->callchain;int chain_nr =0 ; -u8 cpumode =PERF_RECORD_MISC_USER ; +u8 cpumode =PERF_RECORD_MISC_CPUMODE_UNKNOWN ;int i, j, err, nr_entries;int skip_idx =-1 ;int first_call =0 ;
tools/perf/util/thread.c +5 -2
@@ -366,7 +366,7 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) }void thread__find_cpumode_addr_location (struct thread *thread,u64 addr, -struct addr_location *al) +struct addr_location *al,u8 *cpumode) {size_t i;const u8 cpumodes[] = {
@@ -378,8 +378,11 @@ void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,for (i =0 ; i <ARRAY_SIZE (cpumodes); i++) {thread__find_symbol (thread, cpumodes[i], addr, al); -if (al->map) +if (al->map) { +if (cpumode) + *cpumode = cpumodes[i];break ; + } } }
tools/perf/util/thread.h +1 -1
@@ -99,7 +99,7 @@ struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode, u64 addr, struct addr_location *al);void thread__find_cpumode_addr_location (struct thread *thread,u64 addr, -struct addr_location *al); +struct addr_location *al,u8 *cpumode);static inline void *thread__priv (struct thread *thread) {
Re: [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
Hi Jirka,
Quoted 24 lines · Jiri Olsa
Quoted 23 lines · Vinicius Costa Gomes
Hi,
Quoted 10 lines · Adrian Hunter
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).I don't think this is a complete fix because it exposes new problems.
This commit broke function name resolution for 'perf record -g' for me.
What I mean is, with this commit applied:
$ ./tools/perf/perf record -g -- sleep 1$ ./tools/perf/perf report
Quoted 7 lines
Quoted 4 lines
'perf report' doesn't seem to be able to show the function names of the trace.
If I revert this commit, function names are resolved fine.
that commit just showed up some places where we have the ip resolve wrong.. would attached patch fix it for you?
Thank you for your patch.
I can some difference in the output, but I wouldn't say that it's fixed.
Here are some samples, if it's useful somehow:
https://gist.github.com/vcgomes/985626705e0968b973e426964f86a4b0
The "ping" tests were done running
$ sudo ./tools/perf/perf record -g -- ping -f -c 1000 127.0.0.1
And the "sleep" tests were done running
$ sudo ./tools/perf/perf record -g -- /bin/sleep 1
--
Vinicius
Re: [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup
Quoted 44 lines · Vinicius Costa Gomes
Hi Jirka,
Quoted 24 lines · Jiri Olsa
Quoted 23 lines · Vinicius Costa Gomes
Hi,
Quoted 10 lines · Adrian Hunter
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
David reports that:
<quote>
Perf has this hack where it uses the kernel symbol map as a backup when a symbol can't be found in the user's symbol table(s).I don't think this is a complete fix because it exposes new problems.
This commit broke function name resolution for 'perf record -g' for me.
What I mean is, with this commit applied:
$ ./tools/perf/perf record -g -- sleep 1$ ./tools/perf/perf reportQuoted 7 lines
Quoted 4 lines
'perf report' doesn't seem to be able to show the function names of the trace.
If I revert this commit, function names are resolved fine.
that commit just showed up some places where we have the ip resolve wrong.. would attached patch fix it for you?
Thank you for your patch.
I can some difference in the output, but I wouldn't say that it's fixed.
Here are some samples, if it's useful somehow:
https://gist.github.com/vcgomes/985626705e0968b973e426964f86a4b0
Quoted 7 lines
The "ping" tests were done running
$ sudo ./tools/perf/perf record -g -- ping -f -c 1000 127.0.0.1And the "sleep" tests were done running
$ sudo ./tools/perf/perf record -g -- /bin/sleep 1
ugh, I tried with 'sudo ./perf record -g' and it looks like it matter to callchains if there's a workload
Adrian said he's preparing complex patch for this
let's wait for his changes
thanks,
jirka
Quoted 75 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
Best Regards,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit
c1883f10cfe05c707cce46d6999411c50a2413ca:Merge tag 'perf-urgent-for-mingo-4.19-20181005' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/urgent (2018-10-05 18:14:00 +0200)are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-urgent-for-mingo-4.19-20181017for you to fetch changes up to
edeb0c90df3581b821a764052d185df985f8b8dc:perf tools: Stop fallbacking to kallsyms for vdso symbols lookup (2018-10-17 15:56:15 -0300)
----------------------------------------------------------------
perf/urgent fixes:- Stop fallbacking to kallsyms for vDSO symbols lookup, this wasn't being really used and is not valid in arches such as Sparc, where user and kernel space don't share the address space, relying only on cpumode to figure out what DSOs to lookup (Arnaldo Carvalho de Melo)
- Align cpu map synthesized events properly, fixing SIGBUS in CPUs like Sparc (David Miller)
- Fix use of alternatives to find JDIR (Jarod Wilson)
- Store ids for events with their own cpus when synthesizing user level event details (scale, unit, etc) events, fixing a crash when recording a PMU event with a cpumask defined (Jiri Olsa)
- Fix wrong filter_band* values for uncore Intel vendor events (Jiri Olsa)
- Fix detection of tracefs path in systems without tracefs, where that path should be the debugfs mountpoint plus "/tracing/" (Jiri Olsa)
- Pass build flags to traceevent build, allowing using alternative flags in distro packages, RPM, for instance (Jiri Olsa)
- Fix 'perf report' crash on invalid inline debug information (Milian Wolff)
- Synch kvm uapi copies (Arnaldo Carvalho de Melo)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
tools arch uapi: Sync the x86kvm.hcopy
tools headers uapi: Synckvm.hcopy
perf tools: Stop fallbacking to kallsyms for vdso symbols lookupDavid Miller (1):
perfcpu_map: Align cpu map synthesized events properly.Jarod Wilson (1):
perf tools: Fix use of alternatives to find JDIRJiri Olsa (5):
Revert "perf tools: Fix PMU term format max value calculation"
perf vendor events intel: Fix wrong filter_band* values for uncore events perf evsel: Store ids for events with their own cpusperf_event__synthesize_event_update_cpusperf tools: Fixtracing_path_mountproper path
perf tools: Pass build flags to traceevent buildMilian Wolff (1):
perf report: Don't crash on invalid inline debug information
Quoted 13 lines
tools/arch/x86/include/uapi/asm/kvm.h | 1 + tools/include/uapi/linux/kvm.h | 1 + tools/lib/api/fs/tracing_path.c | 4 ++-- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- tools/perf/builtin-report.c | 1 + .../pmu-events/arch/x86/ivytown/uncore-power.json | 16 ++++++++-------- .../pmu-events/arch/x86/jaketown/uncore-power.json | 16 ++++++++-------- tools/perf/util/event.c | 22 +++------------------- tools/perf/util/evsel.c | 3 +++ tools/perf/util/pmu.c | 13 +++++++------ tools/perf/util/srcline.c | 3 +++ 12 files changed, 39 insertions(+), 45 deletions(-)
Pulled, thanks a lot Arnaldo!
Ingo