1. 09 3月, 2020 5 次提交
    • M
      perf probe: Do not depend on dwfl_module_addrsym() · 1efde275
      Masami Hiramatsu 提交于
      Do not depend on dwfl_module_addrsym() because it can fail on user-space
      shared libraries.
      
      Actually, same bug was fixed by commit 664fee3d ("perf probe: Do not
      use dwfl_module_addrsym if dwarf_diename finds symbol name"), but commit
      07d36985 ("perf probe: Fix wrong address verification) reverted to
      get actual symbol address from symtab.
      
      This fixes it again by getting symbol address from DIE, and only if the
      DIE has only address range, it uses dwfl_module_addrsym().
      
      Fixes: 07d36985 ("perf probe: Fix wrong address verification)
      Reported-by: NAlexandre Ghiti <alex@ghiti.fr>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NAlexandre Ghiti <alex@ghiti.fr>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Link: http://lore.kernel.org/lkml/158281812176.476.14164573830975116234.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1efde275
    • M
      perf probe: Fix to delete multiple probe event · 6b8d68f1
      Masami Hiramatsu 提交于
      When we put an event with multiple probes, perf-probe fails to delete
      with filters. This comes from a failure to list up the event name
      because of overwrapping its name.
      
      To fix this issue, skip to list up the event which has same name.
      
      Without this patch:
      
        # perf probe -l \*
          probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:21@
          probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:25@
          probe_perf:map__map_ip (on append_inlines:12@util/machine.c in
          probe_perf:map__map_ip (on unwind_entry:19@util/machine.c in /
          probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
          probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
        # perf probe -d \*
        "*" does not hit any event.
          Error: Failed to delete events. Reason: No such file or directory (Code: -2)
      
      With it:
      
        # perf probe -d \*
        Removed event: probe_perf:map__map_ip
        #
      
      Fixes: 72363540 ("perf probe: Support multiprobe event")
      Reported-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Reported-by: NHe Zhe <zhe.he@windriver.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/158287666197.16697.7514373548551863562.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6b8d68f1
    • I
      perf parse-events: Fix reading of invalid memory in event parsing · 05e54e23
      Ian Rogers 提交于
      ADD_CONFIG_TERM accesses term->weak, however, in get_config_chgs this
      value is accessed outside of the list_for_each_entry and references
      invalid memory. Add an argument for ADD_CONFIG_TERM for weak and set it
      to false in the get_config_chgs case.
      
      This bug was cause by clang's address sanitizer and libfuzzer. It can be
      reproduced with a command line of:
      
        perf stat -a -e i/bs,tsc,L2/o
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20200307073121.203816-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      05e54e23
    • I
      perf python: Fix clang detection when using CC=clang-version · a7ffd416
      Ilie Halip 提交于
      Currently, the setup.py script detects the clang compiler only when invoked
      with CC=clang. But when using a specific version (e.g. CC=clang-11), this
      doesn't work correctly and wrong compiler flags are set, leading to build
      errors.
      
      To properly detect clang, invoke the compiler with -v and check the output.
      The first line should start with "clang version ...".
      
      Committer testing:
      
        $ make CC=clang-9 O=/tmp/build/perf -C tools/perf install-bin
        <SNIP>
        $ readelf -wi /tmp/build/perf/python/perf.cpython-37m-x86_64-linux-gnu.so | grep DW_AT_producer | head -1
          <c>   DW_AT_producer    : (indirect string, offset: 0x0): clang version 9.0.1 (Fedora 9.0.1-2.fc31) /usr/bin/clang-9 -Wno-unused-result -Wsign-compare -D DYNAMIC_ANNOTATIONS_ENABLED=1 -D NDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-command-line -m64 -mtune=generic -fasynchronous-unwind-tables -fcf-protection=full -D _GNU_SOURCE -fPIC -fwrapv -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wshadow -D HAVE_ARCH_X86_64_SUPPORT -I /tmp/build/perf/arch/x86/include/generated -D HAVE_SYSCALL_TABLE_SUPPORT -D HAVE_PERF_REGS_SUPPORT -D HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET -Werror -O3 -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 -fstack-protector-all -D _FORTIFY_SOURCE=2 -D _LARGEFILE64_SOURCE -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -I /home/acme/git/perf/tools/lib/perf/include -I /home/acme/git/perf/tools/perf/util/include -I /home/acme/git/perf/tools/perf/arch/x86/include -I /home/acme/git/perf/tools/include/ -I /home/acme/git/perf/tools/arch/x86/include/uapi -I /home/acme/git/perf/tools/include/uapi -I /home/acme/git/perf/tools/arch/x86/include/ -I /home/acme/git/perf/tools/arch/x86/ -I /tmp/build/perf//util -I /tmp/build/perf/ -I /home/acme/git/perf/tools/perf/util -I /home/acme/git/perf/tools/perf -I /home/acme/git/perf/tools/lib/ -D HAVE_PTHREAD_ATTR_SETAFFINITY_NP -D HAVE_PTHREAD_BARRIER -D HAVE_EVENTFD -D HAVE_GET_CURRENT_DIR_NAME -D HAVE_GETTID -D HAVE_DWARF_GETLOCATIONS_SUPPORT -D HAVE_GLIBC_SUPPORT -D HAVE_AIO_SUPPORT -D HAVE_SCHED_GETCPU_SUPPORT -D HAVE_SETNS_SUPPORT -D HAVE_LIBELF_SUPPORT -D HAVE_LIBELF_MMAP_SUPPORT -D HAVE_ELF_GETPHDRNUM_SUPPORT -D HAVE_GELF_GETNOTE_SUPPORT -D HAVE_ELF_GETSHDRSTRNDX_SUPPORT -D HAVE_DWARF_SUPPORT -D HAVE_LIBBPF_SUPPORT -D HAVE_BPF_PROLOGUE -D HAVE_SDT_EVENT -D HAVE_JITDUMP -D HAVE_DWARF_UNWIND_SUPPORT -D NO_LIBUNWIND_DEBUG_FRAME -D HAVE_LIBUNWIND_SUPPORT -D HAVE_LIBCRYPTO_SUPPORT -D HAVE_SLANG_SUPPORT -D HAVE_GTK2_SUPPORT -D NO_LIBPERL -D HAVE_TIMERFD_SUPPORT -D HAVE_LIBPYTHON_SUPPORT -D HAVE_CPLUS_DEMANGLE_SUPPORT -D HAVE_LIBBFD_SUPPORT -D HAVE_ZLIB_SUPPORT -D HAVE_LZMA_SUPPORT -D HAVE_ZSTD_SUPPORT -D HAVE_LIBCAP_SUPPORT -D HAVE_BACKTRACE_SUPPORT -D HAVE_LIBNUMA_SUPPORT -D HAVE_KVM_STAT_SUPPORT -D DISASM_FOUR_ARGS_SIGNATURE -D HAVE_LIBBABELTRACE_SUPPORT -D HAVE_AUXTRACE_SUPPORT -D HAVE_JVMTI_CMLR -I /tmp/build/perf/ -fPIC -I util/include -I /usr/include/python3.7m -c /home/acme/git/perf/tools/perf/util/python.c -o /tmp/build/perf/python_ext_build/tmp/home/acme/git/perf/tools/perf/util/python.o -Wbad-function-cast -Wdeclaration-after-statement -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-system-headers -Wold-style-definition -Wpacked -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wwrite-strings -Wformat -Wshadow -D HAVE_ARCH_X86_64_SUPPORT -I /tmp/build/perf/arch/x86/include/generated -D HAVE_SYSCALL_TABLE_SUPPORT -D HAVE_PERF_REGS_SUPPORT -D HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET -Werror -O3 -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 -fstack-protector-all -D _FORTIFY_SOURCE=2 -D _LARGEFILE64_SOURCE -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -I /home/acme/git/perf/tools/lib/perf/include -I /home/acme/git/perf/tools/perf/util/include -I /home/acme/git/perf/tools/perf/arch/x86/include -I /home/acme/git/perf/tools/include/ -I /home/acme/git/perf/tools/arch/x86/include/uapi -I /home/acme/git/perf/tools/include/uapi -I /home/acme/git/perf/tools/arch/x86/include/ -I /home/acme/git/perf/tools/arch/x86/ -I /tmp/build/perf//util -I /tmp/build/perf/ -I /home/acme/git/perf/tools/perf/util -I /home/acme/git/perf/tools/perf -I /home/acme/git/perf/tools/lib/ -D HAVE_PTHREAD_ATTR_SETAFFINITY_NP -D HAVE_PTHREAD_BARRIER -D HAVE_EVENTFD -D HAVE_GET_CURRENT_DIR_NAME -D HAVE_GETTID -D HAVE_DWARF_GETLOCATIONS_SUPPORT -D HAVE_GLIBC_SUPPORT -D HAVE_AIO_SUPPORT -D HAVE_SCHED_GETCPU_SUPPORT -D HAVE_SETNS_SUPPORT -D HAVE_LIBELF_SUPPORT -D HAVE_LIBELF_MMAP_SUPPORT -D HAVE_ELF_GETPHDRNUM_SUPPORT -D HAVE_GELF_GETNOTE_SUPPORT -D HAVE_ELF_GETSHDRSTRNDX_SUPPORT -D HAVE_DWARF_SUPPORT -D HAVE_LIBBPF_SUPPORT -D HAVE_BPF_PROLOGUE -D HAVE_SDT_EVENT -D HAVE_JITDUMP -D HAVE_DWARF_UNWIND_SUPPORT -D NO_LIBUNWIND_DEBUG_FRAME -D HAVE_LIBUNWIND_SUPPORT -D HAVE_LIBCRYPTO_SUPPORT -D HAVE_SLANG_SUPPORT -D HAVE_GTK2_SUPPORT -D NO_LIBPERL -D HAVE_TIMERFD_SUPPORT -D HAVE_LIBPYTHON_SUPPORT -D HAVE_CPLUS_DEMANGLE_SUPPORT -D HAVE_LIBBFD_SUPPORT -D HAVE_ZLIB_SUPPORT -D HAVE_LZMA_SUPPORT -D HAVE_ZSTD_SUPPORT -D HAVE_LIBCAP_SUPPORT -D HAVE_BACKTRACE_SUPPORT -D HAVE_LIBNUMA_SUPPORT -D HAVE_KVM_STAT_SUPPORT -D DISASM_FOUR_ARGS_SIGNATURE -D HAVE_LIBBABELTRACE_SUPPORT -D HAVE_AUXTRACE_SUPPORT -D HAVE_JVMTI_CMLR -I /tmp/build/perf/ -fno-strict-aliasing -Wno-write-strings -Wno-unused-parameter -Wno-redundant-decls
        $
      
      And here is how tools/perf/util/setup.py checks if the used clang has
      options that the distro specific python extension building compiler
      defaults:
      
        if cc_is_clang:
            from distutils.sysconfig import get_config_vars
            vars = get_config_vars()
            for var in ('CFLAGS', 'OPT'):
                vars[var] = sub("-specs=[^ ]+", "", vars[var])
                if not clang_has_option("-mcet"):
                    vars[var] = sub("-mcet", "", vars[var])
                if not clang_has_option("-fcf-protection"):
                    vars[var] = sub("-fcf-protection", "", vars[var])
                if not clang_has_option("-fstack-clash-protection"):
                    vars[var] = sub("-fstack-clash-protection", "", vars[var])
                if not clang_has_option("-fstack-protector-strong"):
                    vars[var] = sub("-fstack-protector-strong", "", vars[var])
      
      So "-fcf-protection=full" is used, clang-9 has this option and thus it
      was kept, the perf python extension was built with it and the build
      completed successfully.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/903Signed-off-by: NIlie Halip <ilie.halip@gmail.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20200309085618.14307-1-ilie.halip@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a7ffd416
    • D
      perf map: Fix off by one in strncpy() size argument · db2c5494
      disconnect3d 提交于
      This patch fixes an off-by-one error in strncpy size argument in
      tools/perf/util/map.c. The issue is that in:
      
              strncmp(filename, "/system/lib/", 11)
      
      the passed string literal: "/system/lib/" has 12 bytes (without the NULL
      byte) and the passed size argument is 11. As a result, the logic won't
      match the ending "/" byte and will pass filepaths that are stored in
      other directories e.g. "/system/libmalicious/bin" or just
      "/system/libmalicious".
      
      This functionality seems to be present only on Android. I assume the
      /system/ directory is only writable by the root user, so I don't think
      this bug has much (or any) security impact.
      
      Fixes: eca81836 ("perf tools: Add automatic remapping of Android libraries")
      Signed-off-by: Ndisconnect3d <dominik.b.czarnota@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Keeping <john@metanate.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Lentine <mlentine@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200309104855.3775-1-dominik.b.czarnota@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      db2c5494
  2. 06 3月, 2020 1 次提交
    • N
      perf diff: Fix undefined string comparision spotted by clang's -Wstring-compare · cfd3bc75
      Nick Desaulniers 提交于
      clang warns:
      
        util/block-info.c:298:18: error: result of comparison against a string
        literal is unspecified (use an explicit string comparison function
        instead) [-Werror,-Wstring-compare]
                if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) {
                                ^  ~~~~~~~~~~~~~~~
        util/block-info.c:298:51: error: result of comparison against a string
        literal is unspecified (use an explicit string comparison function
        instead) [-Werror,-Wstring-compare]
                if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) {
                                                                 ^  ~~~~~~~~~~~~~~~
        util/block-info.c:298:18: error: result of comparison against a string
        literal is unspecified (use an explicit string
        comparison function instead) [-Werror,-Wstring-compare]
                if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) {
                                ^  ~~~~~~~~~~~~~~~
        util/block-info.c:298:51: error: result of comparison against a string
        literal is unspecified (use an explicit string comparison function
        instead) [-Werror,-Wstring-compare]
                if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) {
                                                                 ^  ~~~~~~~~~~~~~~~
        util/map.c:434:15: error: result of comparison against a string literal
        is unspecified (use an explicit string comparison function instead)
        [-Werror,-Wstring-compare]
                        if (srcline != SRCLINE_UNKNOWN)
                                    ^  ~~~~~~~~~~~~~~~
      
      Reviewer Notes:
      
      Looks good to me. Some more context:
      https://clang.llvm.org/docs/DiagnosticsReference.html#wstring-compare
      The spec says:
      J.1 Unspecified behavior
      The following are unspecified:
      .. Whether two string literals result in distinct arrays (6.4.5).
      Signed-off-by: NNick Desaulniers <nick.desaulniers@gmail.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Keeping <john@metanate.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: clang-built-linux@googlegroups.com
      Link: https://github.com/ClangBuiltLinux/linux/issues/900
      Link: http://lore.kernel.org/lkml/20200223193456.25291-1-nick.desaulniers@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cfd3bc75
  3. 04 3月, 2020 1 次提交
    • A
      perf symbols: Don't try to find a vmlinux file when looking for kernel modules · b5c09518
      Arnaldo Carvalho de Melo 提交于
      The dso->kernel value is now set to everything that is in
      machine->kmaps, but that was being used to decide if vmlinux lookup is
      needed, which ended up making that lookup be made for kernel modules,
      that now have dso->kernel set, leading to these kinds of warnings when
      running on a machine with compressed kernel modules, like fedora:31:
      
        [root@five ~]# perf record -F 10000 -a sleep 2
        [ perf record: Woken up 1 times to write data ]
        lzma: fopen failed on vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /usr/lib/debug/boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /lib/modules/5.5.5-200.fc31.x86_64/build/vmlinux: 'No such file or directory'
        lzma: fopen failed on vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /usr/lib/debug/boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /lib/modules/5.5.5-200.fc31.x86_64/build/vmlinux: 'No such file or directory'
        lzma: fopen failed on vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /usr/lib/debug/boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /lib/modules/5.5.5-200.fc31.x86_64/build/vmlinux: 'No such file or directory'
        lzma: fopen failed on vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /usr/lib/debug/boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /lib/modules/5.5.5-200.fc31.x86_64/build/vmlinux: 'No such file or directory'
        lzma: fopen failed on vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux: 'No such file or directory'
        lzma: fopen failed on /boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /usr/lib/debug/boot/vmlinux-5.5.5-200.fc31.x86_64: 'No such file or directory'
        lzma: fopen failed on /lib/modules/5.5.5-200.fc31.x86_64/build/vmlinux: 'No such file or directory'
        [ perf record: Captured and wrote 1.024 MB perf.data (1366 samples) ]
        [root@five ~]#
      
      This happens when collecting the buildid, when we find samples for
      kernel modules, fix it by checking if the looked up DSO is a kernel
      module by other means.
      
      Fixes: 02213cec ("perf maps: Mark module DSOs with kernel type")
      Tested-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200302191007.GD10335@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b5c09518
  4. 02 3月, 2020 2 次提交
    • A
      perf parse-events: Use asprintf() instead of strncpy() to read tracepoint files · 7125f204
      Arnaldo Carvalho de Melo 提交于
      Make the code more compact by using asprintf() instead of malloc()+strncpy() which also uses
      less memory and avoids these warnings with gcc 10:
      
          CC       /tmp/build/perf/util/cloexec.o
        In file included from /usr/include/string.h:495,
                         from util/parse-events.h:12,
                         from util/parse-events.c:18:
        In function ‘strncpy’,
            inlined from ‘tracepoint_id_to_path’ at util/parse-events.c:271:5:
        /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ offset [275, 511] from the object at ‘sys_dirent’ is out of the bounds of referenced subobject ‘d_name’ with type ‘char[256]’ at offset 19 [-Werror=array-bounds]
          106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        In file included from /usr/include/dirent.h:61,
                         from util/parse-events.c:5:
        util/parse-events.c: In function ‘tracepoint_id_to_path’:
        /usr/include/bits/dirent.h:33:10: note: subobject ‘d_name’ declared here
           33 |     char d_name[256];  /* We must not include limits.h! */
              |          ^~~~~~
        In file included from /usr/include/string.h:495,
                         from util/parse-events.h:12,
                         from util/parse-events.c:18:
        In function ‘strncpy’,
            inlined from ‘tracepoint_id_to_path’ at util/parse-events.c:273:5:
        /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ offset [275, 511] from the object at ‘evt_dirent’ is out of the bounds of referenced subobject ‘d_name’ with type ‘char[256]’ at offset 19 [-Werror=array-bounds]
          106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        In file included from /usr/include/dirent.h:61,
                         from util/parse-events.c:5:
        util/parse-events.c: In function ‘tracepoint_id_to_path’:
        /usr/include/bits/dirent.h:33:10: note: subobject ‘d_name’ declared here
           33 |     char d_name[256];  /* We must not include limits.h! */
              |          ^~~~~~
          CC       /tmp/build/perf/util/call-path.o
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200302145535.GA28183@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7125f204
    • A
      perf env: Do not return pointers to local variables · ebcb9464
      Arnaldo Carvalho de Melo 提交于
      It is possible to return a pointer to a local variable when looking up
      the architecture name for the running system and no normalization is
      done on that value, i.e. we may end up returning the uts.machine local
      variable.
      
      While this doesn't happen on most arches, as normalization takes place,
      lets fix this by making that a static variable and optimize it a bit by
      not always running uname(), only the first time.
      
      Noticed in fedora rawhide running with:
      
        [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version
        gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)
      Reported-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ebcb9464
  5. 27 2月, 2020 9 次提交
    • R
      perf annotate: Fix segfault with source toggle · e0560ba6
      Ravi Bangoria 提交于
      While rendering annotate browser from perf report tui, we keep track
      of total number of lines(asm + source) in annotation->nr_entries and
      total number of asm lines in annotation->nr_asm_entries. But we don't
      reset them before starting. Thus if user annotates same function
      multiple times, we restart incrementing these fields with old values.
      
      This causes a segfault when user tries to toggle source code after
      annotating same function multiple times. Fix it.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: http://lore.kernel.org/lkml/20200204045233.474937-5-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e0560ba6
    • R
      perf annotate: Align struct annotate_args · d3c03147
      Ravi Bangoria 提交于
      Align fields of struct annotate_args.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: http://lore.kernel.org/lkml/20200204045233.474937-4-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d3c03147
    • R
      perf annotate: Simplify disasm_line allocation and freeing code · 2316f861
      Ravi Bangoria 提交于
      We are allocating disasm_line object in annotation_line__new() instead
      of disasm_line__new(). Similarly annotation_line__delete() is actually
      freeing disasm_line object as well. This complexity is because of
      privsize.  But we don't need privsize anymore so get rid of privsize and
      simplify disasm_line allocation and freeing code.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: http://lore.kernel.org/lkml/20200204045233.474937-3-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2316f861
    • R
      perf annotate: Remove privsize from symbol__annotate() args · e0ad4d68
      Ravi Bangoria 提交于
      privsize is passed as 0 from all the symbol__annotate() callers.
      Remove it from argument list.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: http://lore.kernel.org/lkml/20200204045233.474937-2-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e0ad4d68
    • H
      perf probe: Check return value of strlist__add() for -ENOMEM · bd862b1d
      He Zhe 提交于
      strlist__add() may fail with -ENOMEM. Check it and give debugging hint
      in advance.
      Signed-off-by: NHe Zhe <zhe.he@windriver.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/1582727404-180095-1-git-send-email-zhe.he@windriver.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bd862b1d
    • R
      perf annotate: Make perf config effective · 7384083b
      Ravi Bangoria 提交于
      perf default config set by user in [annotate] section is totally ignored
      by annotate code. Fix it.
      
      Before:
      
        $ ./perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
      
        $ ./perf annotate shash
               │    unsigned h = 0;
               │      movl   $0x0,-0xc(%rbp)
               │    while (*s)
               │    ↓ jmp    44
               │    h = 65599 * h + *s++;
         11.33 │24:   mov    -0xc(%rbp),%eax
         43.50 │      imul   $0x1003f,%eax,%ecx
               │      mov    -0x18(%rbp),%rax
      
      After:
      
               │        movl   $0x0,-0xc(%rbp)
               │      ↓ jmp    44
             1 │1 24:   mov    -0xc(%rbp),%eax
             4 │        imul   $0x1003f,%eax,%ecx
               │        mov    -0x18(%rbp),%rax
      
      Note that we have removed show_nr_samples and show_total_period from
      annotation_options because they are not used. Instead of them we use
      symbol_conf.show_nr_samples and symbol_conf.show_total_period.
      
      Committer testing:
      
      Using 'perf annotate --stdio2' to use the TUI rendering but emitting the output to stdio:
      
        # perf config
        #
        # perf config annotate.hide_src_code=true
        # perf config
        annotate.hide_src_code=true
        #
        # perf config annotate.show_nr_jumps=true
        # perf config annotate.show_nr_samples=true
        # perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
        #
        #
      
      Before:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Percent
                    00000000000609f0 <ObjectInstance::weak_pointer_was_finalized()@@base>:
                      endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
        100.00  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      
      After:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
           1  1 10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
              1 1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
              1 20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=true
        # perf config annotate.show_nr_jumps=false
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=false
        #
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
             1  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-6-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7384083b
    • R
      perf config: Introduce perf_config_u8() · 7b43b697
      Ravi Bangoria 提交于
      Introduce perf_config_u8() utility function to convert char * input into
      u8 destination. We will utilize it in followup patch.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-5-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b43b697
    • R
      perf annotate: Fix --show-nr-samples for tui/stdio2 · 46ccb442
      Ravi Bangoria 提交于
      perf annotate --show-nr-samples does not really show number of samples.
      
      The reason is we have two separate variables for the same purpose.
      
      One is in symbol_conf.show_nr_samples and another is
      annotation_options.show_nr_samples.
      
      We save command line option in symbol_conf.show_nr_samples but uses
      annotation_option.show_nr_samples while rendering tui/stdio2 browser.
      
      Though, we copy symbol_conf.show_nr_samples to
      annotation__default_options.show_nr_samples but that is not really
      effective as we don't use annotation__default_options once we copy
      default options to dynamic variable annotate.opts in cmd_annotate().
      
      Instead of all these complication, keep only one variable and use it all
      over. symbol_conf.show_nr_samples is used by perf report/top as well. So
      let's kill annotation_options.show_nr_samples.
      
      On a side note, I've kept annotation_options.show_nr_samples definition
      because it's still used by perf-config code. Follow up patch to fix
      perf-config for annotate will remove annotation_options.show_nr_samples.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-4-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      46ccb442
    • R
      perf annotate: Fix --show-total-period for tui/stdio2 · 68aac855
      Ravi Bangoria 提交于
      perf annotate --show-total-period does not really show total period.
      
      The reason is we have two separate variables for the same purpose.
      
      One is in symbol_conf.show_total_period and another is
      annotation_options.show_total_period.
      
      We save command line option in symbol_conf.show_total_period but uses
      annotation_option.show_total_period while rendering tui/stdio2 browser.
      
      Though, we copy symbol_conf.show_total_period to
      annotation__default_options.show_total_period but that is not really
      effective as we don't use annotation__default_options once we copy
      default options to dynamic variable annotate.opts in cmd_annotate().
      
      Instead of all these complication, keep only one variable and use it all
      over. symbol_conf.show_total_period is used by perf report/top as well.
      So let's kill annotation_options.show_total_period.
      
      On a side note, I've kept annotation_options.show_total_period
      definition because it's still used by perf-config code. Follow up patch
      to fix perf-config for annotate will remove
      annotation_options.show_total_period.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-3-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      68aac855
  6. 18 2月, 2020 1 次提交
  7. 14 2月, 2020 1 次提交
    • A
      perf llvm: Fix script used to obtain kernel make directives to work with new kbuild · 62765941
      Arnaldo Carvalho de Melo 提交于
      Before this patch:
      
        # ./perf test 39 41
        39: LLVM search and compile                               :
        39.1: Basic BPF llvm compile                              : Ok
        39.2: kbuild searching                                    : FAILED!
        39.3: Compile source for BPF prologue generation          : Skip
        39.4: Compile source for BPF relocation                   : Skip
        41: BPF filter                                            :
        41.1: Basic BPF filtering                                 : Ok
        41.2: BPF pinning                                         : Ok
        41.3: BPF prologue generation                             : FAILED!
        41.4: BPF relocation checker                              : Skip
        #
      
      Using 'perf test -v' for these tests shows that it is not finding
      uapi/linux/fs.h, which ends up being because we don't setup the right header
      path. Fix it.
      
      After this patch:
      
        # perf test 39 41
        39: LLVM search and compile                               :
        39.1: Basic BPF llvm compile                              : Ok
        39.2: kbuild searching                                    : Ok
        39.3: Compile source for BPF prologue generation          : Ok
        39.4: Compile source for BPF relocation                   : Ok
        41: BPF filter                                            :
        41.1: Basic BPF filtering                                 : Ok
        41.2: BPF pinning                                         : Ok
        41.3: BPF prologue generation                             : Ok
        41.4: BPF relocation checker                              : Ok
        #
      
      Longer description:
      
      In llvm-utils.c we use some techniques to obtain the kbuild make
      directives and that recently stopped working as now 'ar' gets called and
      expects to find the dummy.o used to echo these variables:
      
        $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)
      
      Add the $(CC) line to satisfy that, making sure this works with all
      kernels, i.e. preserving the temp directory and files in it used for
      this technique we can see that it works everywhere:
      
        # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ clean
        # ls -la /tmp/tmp.qgaFHgxjZ4/
        total 4
        drwx------.  2 root root   80 Feb 14 09:42 .
        drwxrwxrwt. 47 root root 1200 Feb 14 09:42 ..
        -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
        -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
        #
        # cat /tmp/tmp.qgaFHgxjZ4/Makefile
        obj-y := dummy.o
        $(obj)/%.o: $(src)/%.c
                @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)"
                $(CC) -c -o $@ $<
        #
      
      Then build with an old kernel Makefile:
      
        # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ dummy.o
        -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/9/include -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
        #
        # ls -la /tmp/tmp.qgaFHgxjZ4/
        total 8
        drwx------.  2 root root  100 Feb 14 09:43 .
        drwxrwxrwt. 47 root root 1200 Feb 14 09:43 ..
        -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
        -rw-r--r--.  1 root root  936 Feb 14 09:43 dummy.o
        -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
        #
      
      And a new one:
      
        # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ clean
        # ls -la /tmp/tmp.qgaFHgxjZ4/
        total 4
        drwx------.  2 root root   80 Feb 14 09:43 .
        drwxrwxrwt. 47 root root 1200 Feb 14 09:43 ..
        -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
        -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
        # make -s -C /lib/modules/5.6.0-rc1+/build M=/tmp/tmp.qgaFHgxjZ4/ dummy.o
         -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/9/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h
        #
        # ls -la /tmp/tmp.qgaFHgxjZ4/
        total 16
        drwx------.  2 root root  160 Feb 14 09:44 .
        drwxrwxrwt. 47 root root 1200 Feb 14 09:44 ..
        -rw-r--r--.  1 root root  158 Feb 14 09:44 built-in.a
        -rw-r--r--.  1 root root  149 Feb 14 09:44 .built-in.a.cmd
        -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
        -rw-r--r--.  1 root root  936 Feb 14 09:44 dummy.o
        -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
        -rw-r--r--.  1 root root    0 Feb 14 09:44 modules.order
        #
      Reported-by: NThomas Richter <tmricht@linux.ibm.com>
      Tested-by: NThomas Richter <tmricht@linux.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: https://www.spinics.net/lists/linux-perf-users/msg10600.htmlSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      62765941
  8. 12 2月, 2020 4 次提交
  9. 11 2月, 2020 3 次提交
    • K
      perf symbols: Convert symbol__is_idle() to use strlist · bc5f15be
      Kim Phillips 提交于
      Use the more optimized strlist implementation to do the idle function
      lookup.
      Signed-off-by: NKim Phillips <kim.phillips@amd.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200210163147.25358-1-kim.phillips@amd.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bc5f15be
    • K
      perf symbols: Update the list of kernel idle symbols · 0e71459a
      Kim Phillips 提交于
      The "acpi_idle_do_entry", "acpi_processor_ffh_cstate_enter", and
      "idle_cpu" symbols appear in 'perf top' output, at least on AMD systems.
      
      Add them to perf's idle_symbols list, so they don't dominate 'perf top'
      output.
      Signed-off-by: NKim Phillips <kim.phillips@amd.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200207230613.26709-2-kim.phillips@amd.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0e71459a
    • K
      perf stat: Don't report a null stalled cycles per insn metric · 80cc7bb6
      Kim Phillips 提交于
      For data collected on machines with front end stalled cycles supported,
      such as found on modern AMD CPU families, commit 146540fb ("perf
      stat: Always separate stalled cycles per insn") introduces a new line in
      CSV output with a leading comma that upsets some automated scripts.
      Scripts have to use "-e ex_ret_instr" to work around this issue, after
      upgrading to a version of perf with that commit.
      
      We could add "if (have_frontend_stalled && !config->csv_sep)" to the not
      (total && avg) else clause, to emphasize that CSV users are usually
      scripts, and are written to do only what is needed, i.e., they wouldn't
      typically invoke "perf stat" without specifying an explicit event list.
      
      But - let alone CSV output - why should users now tolerate a constant
      0-reporting extra line in regular terminal output?:
      
      BEFORE:
      
      $ sudo perf stat --all-cpus -einstructions,cycles -- sleep 1
      
       Performance counter stats for 'system wide':
      
             181,110,981      instructions              #    0.58  insn per cycle
                                                        #    0.00  stalled cycles per insn
             309,876,469      cycles
      
             1.002202582 seconds time elapsed
      
      The user would not like to see the now permanent:
      
        "0.00  stalled cycles per insn"
      
      line fixture, as it gives no useful information.
      
      So this patch removes the printing of the zeroed stalled cycles line
      altogether, almost reverting the very original commit fb4605ba
      ("perf stat: Check for frontend stalled for metrics"), which seems like
      it was written to normalize --metric-only column output of common Intel
      machines at the time: modern Intel machines have ceased to support the
      genericised frontend stalled metrics AFAICT.
      
      AFTER:
      
      $ sudo perf stat --all-cpus -einstructions,cycles -- sleep 1
      
       Performance counter stats for 'system wide':
      
             244,071,432      instructions              #    0.69  insn per cycle
             355,353,490      cycles
      
             1.001862516 seconds time elapsed
      
      Output behaviour when stalled cycles is indeed measured is not affected
      (BEFORE == AFTER):
      
      $ sudo perf stat --all-cpus -einstructions,cycles,stalled-cycles-frontend -- sleep 1
      
       Performance counter stats for 'system wide':
      
             247,227,799      instructions              #    0.63  insn per cycle
                                                        #    0.26  stalled cycles per insn
             394,745,636      cycles
              63,194,485      stalled-cycles-frontend   #   16.01% frontend cycles idle
      
             1.002079770 seconds time elapsed
      
      Fixes: 146540fb ("perf stat: Always separate stalled cycles per insn")
      Signed-off-by: NKim Phillips <kim.phillips@amd.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200207230613.26709-1-kim.phillips@amd.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      80cc7bb6
  10. 31 1月, 2020 2 次提交
    • C
      perf maps: Add missing unlock to maps__insert() error case · 85fc95d7
      Cengiz Can 提交于
      `tools/perf/util/map.c` has a function named `maps__insert` that
      acquires a write lock if its in multithread context.
      
      Even though this lock is released when function successfully completes,
      there's a branch that is executed when `maps_by_name == NULL` that
      returns from this function without releasing the write lock.
      
      Added an `up_write` to release the lock when this happens.
      
      Fixes: a7c2b572 ("perf map_groups: Auto sort maps by name, if needed")
      Signed-off-by: NCengiz Can <cengiz@kernel.wtf>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200120141553.23934-1-cengiz@kernel.wtfSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      85fc95d7
    • T
      perf probe: Add ustring support for perf probe command · 1873f154
      Thomas Richter 提交于
      Kernel commit 88903c46 ("tracing/probe: Add ustring type for user-space string")
      adds support for user-space strings when type 'ustring' is specified.
      
      Here is an example using sysfs command line interface
      for kprobes:
      
      Function to probe:
        struct filename *
        getname_flags(const char __user *filename, int flags, int *empty)
      
      Setup:
        # cd /sys/kernel/debug/tracing/
        # echo 'p:tmr1 getname_flags +0(%r2):ustring' > kprobe_events
        # cat events/kprobes/tmr1/format | fgrep print
        print fmt: "(%lx) arg1=\"%s\"", REC->__probe_ip, REC->arg1
        # echo 1 > events/kprobes/tmr1/enable
        # touch /tmp/111
        # echo 0 > events/kprobes/tmr1/enable
        # cat trace|fgrep /tmp/111
        touch-5846  [005] d..2 255520.717960: tmr1:\
      	  (getname_flags+0x0/0x400) arg1="/tmp/111"
      
      Doing the same with the perf tool fails.
      Using type 'string' succeeds:
       # perf probe "vfs_getname=getname_flags:72 pathname=filename:string"
       Added new event:
         probe:vfs_getname (on getname_flags:72 with pathname=filename:string)
         ....
       # perf probe -d probe:vfs_getname
       Removed event: probe:vfs_getname
      
      However using type 'ustring' fails (output before):
       # perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring"
       Failed to write event: Invalid argument
         Error: Failed to add events.
       #
      
      Fix this by adding type 'ustring' in function
      convert_variable_type().
      
      Using ustring succeeds (output after):
       # ./perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring"
       Added new event:
         probe:vfs_getname (on getname_flags:72 with pathname=filename:ustring)
      
       You can now use it in all perf tools, such as:
      
      	perf record -e probe:vfs_getname -aR sleep 1
      
       #
      
      Note: This issue also exists on x86, it is not s390 specific.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: sumanthk@linux.ibm.com
      Link: http://lore.kernel.org/lkml/20200120132011.64698-2-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1873f154
  11. 30 1月, 2020 3 次提交
    • C
      perf: Make perf able to build with latest libbfd · 0ada120c
      Changbin Du 提交于
      libbfd has changed the bfd_section_* macros to inline functions
      bfd_section_<field> since 2019-09-18. See below two commits:
        o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
        o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html
      
      This fix make perf able to build with both old and new libbfd.
      Signed-off-by: NChangbin Du <changbin.du@gmail.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200128152938.31413-1-changbin.du@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0ada120c
    • L
      perf parse: Copy string to perf_evsel_config_term · 3220fb8d
      Leo Yan 提交于
      perf with CoreSight fails to record trace data with command:
      
        perf record -e cs_etm/@tmc_etr0/u --per-thread ls
        failed to set sink "" on event cs_etm/@tmc_etr0/u with 21 (Is a
        directory)/perf/
      
      This failure is root caused with the commit 1dc92556 ("perf
      parse: Add a deep delete for parse event terms").
      
      The log shows, cs_etm fails to parse the sink attribution; cs_etm event
      relies on the event configuration to pass sink name, but the event
      specific configuration data cannot be passed properly with flow:
      
        get_config_terms()
          ADD_CONFIG_TERM(DRV_CFG, term->val.str);
            __t->val.str = term->val.str;
              `> __t->val.str is assigned to term->val.str;
      
        parse_events_terms__purge()
          parse_events_term__delete()
            zfree(&term->val.str);
              `> term->val.str is freed and assigned to NULL pointer;
      
        cs_etm_set_sink_attr()
          sink = __t->val.str;
            `> sink string has been freed.
      
      To fix this issue, in the function get_config_terms(), this patch
      changes to use strdup() for allocation a new duplicate string rather
      than directly assignment string pointer.
      
      This patch addes a new field 'free_str' in the data structure
      perf_evsel_config_term; 'free_str' is set to true when the union is used
      as a string pointer; thus it can tell perf_evsel__free_config_terms() to
      free the string.
      
      Fixes: 1dc92556 ("perf parse: Add a deep delete for parse event terms")
      Suggested-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200117055251.24058-2-leo.yan@linaro.org
      [ Use zfree() in perf_evsel__free_config_terms ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      
      :#	modified:   tools/perf/util/evsel_config.h
      3220fb8d
    • L
      perf parse: Refactor 'struct perf_evsel_config_term' · e884602b
      Leo Yan 提交于
      The struct perf_evsel_config_term::val is a union which contains fields
      'callgraph', 'drv_cfg' and 'branch' as string pointers.  This leads to
      the complex code logic for handling every type's string separately, and
      it's hard to release string as a general way.
      
      This patch refactors the structure to add a common field 'str' in the
      'val' union as string pointer and remove the other three fields
      'callgraph', 'drv_cfg' and 'branch'.  Without passing field name, the
      patch simplifies the string handling with macro ADD_CONFIG_TERM_STR()
      for string pointer assignment.
      
      This patch fixes multiple warnings of line over 80 characters detected
      by checkpatch tool.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200117055251.24058-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e884602b
  12. 15 1月, 2020 1 次提交
    • M
      perf header: Use last modification time for timestamp · 8af19d66
      Michael Petlan 提交于
      Using .st_ctime clobbers the timestamp information in perf report header
      whenever any operation is done with the file. Even tar-ing and untar-ing
      the perf.data file (which preserves the file last modification timestamp)
      doesn't prevent that:
      
          [Michael@Diego tmp]$ ls -l perf.data
      ->	-rw-------. 1 Michael Michael 169888 Dec  2 15:23 perf.data
      
      	[Michael@Diego tmp]$ perf report --header-only
      	# ========
      ->	# captured on    : Mon Dec  2 15:23:42 2019
      	 [...]
      
      	[Michael@Diego tmp]$ tar c perf.data | xz > perf.data.tar.xz
      	[Michael@Diego tmp]$ mkdir aaa
      	[Michael@Diego tmp]$ cd aaa
      	[Michael@Diego aaa]$ xzcat ../perf.data.tar.xz | tar x
      	[Michael@Diego aaa]$ ls -l -a
      	total 172
      	drwxrwxr-x. 2 Michael Michael     23 Jan 14 11:26 .
      	drwxrwxr-x. 6 Michael Michael   4096 Jan 14 11:26 ..
      ->	-rw-------. 1 Michael Michael 169888 Dec  2 15:23 perf.data
      
      	[Michael@Diego aaa]$ perf report --header-only
      	# ========
      ->	# captured on    : Tue Jan 14 11:26:16 2020
      	 [...]
      
      When using .st_mtime instead, correct information is printed:
      
      	[Michael@Diego aaa]$ ~/acme/tools/perf/perf report --header-only
      	# ========
      ->	# captured on    : Mon Dec  2 15:23:42 2019
      	 [...]
      Signed-off-by: NMichael Petlan <mpetlan@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20200114104236.31555-1-mpetlan@redhat.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8af19d66
  13. 14 1月, 2020 3 次提交
  14. 06 1月, 2020 3 次提交
  15. 21 12月, 2019 1 次提交