1. 27 4月, 2018 6 次提交
  2. 13 4月, 2018 1 次提交
    • A
      perf report: Fix switching to another perf.data file · 7b366142
      Arnaldo Carvalho de Melo 提交于
      In the TUI the 's' hotkey can be used to switch to another perf.data
      file in the current directory, but that got broken in Fixes:
      b01141f4 ("perf annotate: Initialize the priv are in symbol__new()"),
      that would show this once another file was chosen:
      
          ┌─Fatal Error─────────────────────────────────────┐
          │Annotation needs to be init before symbol__init()│
          │                                                 │
          │                                                 │
          │Press any key...                                 │
          └─────────────────────────────────────────────────┘
      
      Fix it by just silently bailing out if symbol__annotation_init() was already
      called, just like is done with symbol__init(), i.e. they are done just once at
      session start, not when switching to a new perf.data file.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: b01141f4 ("perf annotate: Initialize the priv are in symbol__new()")
      Link: https://lkml.kernel.org/n/tip-ogppdtpzfax7y1h6gjdv5s6u@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b366142
  3. 08 3月, 2018 1 次提交
  4. 17 2月, 2018 2 次提交
  5. 27 12月, 2017 1 次提交
  6. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  7. 25 10月, 2017 1 次提交
  8. 22 9月, 2017 1 次提交
    • A
      perf tools: Provide mutex wrappers for pthreads rwlocks · 0a7c74ea
      Arnaldo Carvalho de Melo 提交于
      Andi reported a performance drop in single threaded perf tools such as
      'perf script' due to the growing number of locks being put in place to
      allow for multithreaded tools, so wrap the POSIX threads rwlock routines
      with the names used for such kinds of locks in the Linux kernel and then
      allow for tools to ask for those locks to be used or not.
      
      I.e. a tool may have a multithreaded phase and then switch to single
      threaded, like the upcoming patches for the synthesizing of
      PERF_RECORD_{FORK,MMAP,etc} for pre-existing processes to then switch to
      single threaded mode in 'perf top'.
      
      The init routines will not be conditional, this way starting as single
      threaded to then move to multi threaded mode should be possible.
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170404161739.GH12903@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0a7c74ea
  9. 12 8月, 2017 1 次提交
    • T
      perf record: Fix wrong size in perf_record_mmap for last kernel module · 9ad4652b
      Thomas Richter 提交于
      During work on perf report for s390 I ran into the following issue:
      
      0 0x318 [0x78]: PERF_RECORD_MMAP -1/0:
              [0x3ff804d6990(0xfffffc007fb2966f) @ 0]:
              x /lib/modules/4.12.0perf1+/kernel/drivers/s390/net/qeth_l2.ko
      
      This is a PERF_RECORD_MMAP entry of the perf.data file with an invalid
      module size for qeth_l2.ko (the s390 ethernet device driver).
      
      Even a mainframe does not have 0xfffffc007fb2966f bytes of main memory.
      
      It turned out that this wrong size is created by the perf record
      command.  What happens is this function call sequence from
      __cmd_record():
      
        perf_session__new():
          perf_session__create_kernel_maps():
            machine__create_kernel_maps():
              machine__create_modules():   Creates map for all loaded kernel modules.
                modules__parse():   Reads /proc/modules and extracts module name and
                                    load address (1st and last column)
                  machine__create_module():   Called for every module found in /proc/modules.
                                    Creates a new map for every module found and enters
                                    module name and start address into the map. Since the
                                    module end address is unknown it is set to zero.
      
      This ends up with a kernel module map list sorted by module start
      addresses.  All module end addresses are zero.
      
      Last machine__create_kernel_maps() calls function map_groups__fixup_end().
      This function iterates through the maps and assigns each map entry's
      end address the successor map entry start address. The last entry of the
      map group has no successor, so ~0 is used as end to consume the remaining
      memory.
      
      Later __cmd_record calls function record__synthesize() which in turn calls
      perf_event__synthesize_kernel_mmap() and perf_event__synthesize_modules()
      to create PERF_REPORT_MMAP entries into the perf.data file.
      
      On s390 this results in the last module qeth_l2.ko
      (which has highest start address, see module table:
              [root@s8360047 perf]# cat /proc/modules
              qeth_l2 86016 1 - Live 0x000003ff804d6000
              qeth 266240 1 qeth_l2, Live 0x000003ff80296000
              ccwgroup 24576 1 qeth, Live 0x000003ff80218000
              vmur 36864 0 - Live 0x000003ff80182000
              qdio 143360 2 qeth_l2,qeth, Live 0x000003ff80002000
              [root@s8360047 perf]# )
      to be the last entry and its map has an end address of ~0.
      
      When the PERF_RECORD_MMAP entry is created for kernel module qeth_l2.ko
      its start address and length is written. The length is calculated in line:
          event->mmap.len   = pos->end - pos->start;
      and results in 0xffffffffffffffff - 0x3ff804d6990(*) = 0xfffffc007fb2966f
      
      (*) On s390 the module start address is actually determined by a __weak function
      named arch__fix_module_text_start() in machine__create_module().
      
      I think this improvable. We can use the module size (2nd column of /proc/modules)
      to get each loaded kernel module size and calculate its end address.
      Only for map entries which do not have a valid end address (end is still zero)
      we can use the heuristic we have now, that is use successor start address or ~0.
      Signed-off-by: NThomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Cc: Zvonko Kosic <zvonko.kosic@de.ibm.com>
      LPU-Reference: 20170803134902.47207-2-tmricht@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/n/tip-nmoqij5b5vxx7rq2ckwu8iaj@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9ad4652b
  10. 19 7月, 2017 4 次提交
  11. 09 6月, 2017 1 次提交
  12. 03 5月, 2017 2 次提交
    • P
      perf symbols: Allow user probes on versioned symbols · d8040645
      Paul Clarke 提交于
      Symbol versioning, as in glibc, results in symbols being defined as:
      
        <real symbol>@[@]<version>
      
      (Note that "@@" identifies a default symbol, if the symbol name is
      repeated.)
      
      perf is currently unable to deal with this, and is unable to create user
      probes at such symbols:
      
        --
        $ nm /lib/powerpc64le-linux-gnu/libpthread.so.0 | grep pthread_create
        0000000000008d30 t __pthread_create_2_1
        0000000000008d30 T pthread_create@@GLIBC_2.17
        $ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
        probe-definition(0): pthread_create
        symbol:pthread_create file:(null) line:0 offset:0 return:0 lazy:(null)
        0 arguments
        Open Debuginfo file: /usr/lib/debug/lib/powerpc64le-linux-gnu/libpthread-2.19.so
        Try to find probe point from debuginfo.
        Probe point 'pthread_create' not found.
           Error: Failed to add events. Reason: No such file or directory (Code: -2)
        --
      
      One is not able to specify the fully versioned symbol, either, due to
      syntactic conflicts with other uses of "@" by perf:
      
        --
        $ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create@@GLIBC_2.17
        probe-definition(0): pthread_create@@GLIBC_2.17
        Semantic error :SRC@SRC is not allowed.
        0 arguments
           Error: Command Parse Error. Reason: Invalid argument (Code: -22)
        --
      
      This patch ignores versioning for default symbols, thus allowing probes to be
      created for these symbols:
      
        --
        $ /usr/bin/sudo ./perf probe -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
        Added new event:
           probe_libpthread:pthread_create (on pthread_create in /lib/powerpc64le-linux-gnu/libpthread-2.19.so)
      
        You can now use it in all perf tools, such as:
      
                 perf record -e probe_libpthread:pthread_create -aR sleep 1
      
        $ /usr/bin/sudo ./perf record -e probe_libpthread:pthread_create -aR ./test 2
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.052 MB perf.data (2 samples) ]
        $ /usr/bin/sudo ./perf script
                     test  2915 [000] 19124.260729: probe_libpthread:pthread_create: (3fff99248d38)
                     test  2916 [000] 19124.260962: probe_libpthread:pthread_create: (3fff99248d38)
        $ /usr/bin/sudo ./perf probe --del=probe_libpthread:pthread_create
        Removed event: probe_libpthread:pthread_create
        --
      
      Committer note:
      
      Change the variable storing the result of strlen() to 'int', to fix the build
      on debian:experimental-x-mipsel, fedora:24-x-ARC-uClibc, ubuntu:16.04-x-arm,
      etc:
      
        util/symbol.c: In function 'symbol__match_symbol_name':
        util/symbol.c:422:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
           if (len < versioning - name)
                   ^
      Signed-off-by: NPaul A. Clarke <pc@us.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Link: http://lkml.kernel.org/r/c2b18d9c-17f8-9285-4868-f58b6359ccac@us.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d8040645
    • A
      perf symbols: Accept symbols starting at address 0 · b843f62a
      Arnaldo Carvalho de Melo 提交于
      That is the case of _text on s390, and we have some functions that return an
      address, using address zero to report problems, oops.
      
      This would lead the symbol loading routines to not use "_text" as the reference
      relocation symbol, or the first symbol for the kernel, but use instead
      "_stext", that is at the same address on x86_64 and others, but not on s390:
      
        [acme@localhost perf-4.11.0-rc6]$ head -15 /proc/kallsyms
        0000000000000000 T _text
        0000000000000418 t iplstart
        0000000000000800 T start
        000000000000080a t .base
        000000000000082e t .sk8x8
        0000000000000834 t .gotr
        0000000000000842 t .cmd
        0000000000000846 t .parm
        000000000000084a t .lowcase
        0000000000010000 T startup
        0000000000010010 T startup_kdump
        0000000000010214 t startup_kdump_relocated
        0000000000011000 T startup_continue
        00000000000112a0 T _ehead
        0000000000100000 T _stext
        [acme@localhost perf-4.11.0-rc6]$
      
      Which in turn would make 'perf test vmlinux' to fail because it wouldn't find
      the symbols before "_stext" in kallsyms.
      
      Fix it by using the return value only for errors and storing the
      address, when the symbol is successfully found, in a provided pointer
      arg.
      
      Before this patch:
      
      After:
      
        [acme@localhost perf-4.11.0-rc6]$ tools/perf/perf test -v 1
         1: vmlinux symtab matches kallsyms            :
        --- start ---
        test child forked, pid 40693
        Looking at the vmlinux_path (8 entries long)
        Using /usr/lib/debug/lib/modules/3.10.0-654.el7.s390x/vmlinux for symbols
        ERR : 0: _text not on kallsyms
        ERR : 0x418: iplstart not on kallsyms
        ERR : 0x800: start not on kallsyms
        ERR : 0x80a: .base not on kallsyms
        ERR : 0x82e: .sk8x8 not on kallsyms
        ERR : 0x834: .gotr not on kallsyms
        ERR : 0x842: .cmd not on kallsyms
        ERR : 0x846: .parm not on kallsyms
        ERR : 0x84a: .lowcase not on kallsyms
        ERR : 0x10000: startup not on kallsyms
        ERR : 0x10010: startup_kdump not on kallsyms
        ERR : 0x10214: startup_kdump_relocated not on kallsyms
        ERR : 0x11000: startup_continue not on kallsyms
        ERR : 0x112a0: _ehead not on kallsyms
        <SNIP warnings>
        test child finished with -1
        ---- end ----
        vmlinux symtab matches kallsyms: FAILED!
        [acme@localhost perf-4.11.0-rc6]$
      
      After:
      
        [acme@localhost perf-4.11.0-rc6]$ tools/perf/perf test -v 1
         1: vmlinux symtab matches kallsyms            :
        --- start ---
        test child forked, pid 47160
        <SNIP warnings>
        test child finished with 0
        ---- end ----
        vmlinux symtab matches kallsyms: Ok
        [acme@localhost perf-4.11.0-rc6]$
      Reported-by: NMichael Petlan <mpetlan@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-9x9bwgd3btwdk1u51xie93fz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b843f62a
  13. 20 4月, 2017 3 次提交
  14. 17 3月, 2017 1 次提交
    • D
      perf symbols: Fix symbols__fixup_end heuristic for corner cases · e7ede72a
      Daniel Borkmann 提交于
      The current symbols__fixup_end() heuristic for the last entry in the rb
      tree is suboptimal as it leads to not being able to recognize the symbol
      in the call graph in a couple of corner cases, for example:
      
       i) If the symbol has a start address (f.e. exposed via kallsyms)
          that is at a page boundary, then the roundup(curr->start, 4096)
          for the last entry will result in curr->start == curr->end with
          a symbol length of zero.
      
      ii) If the symbol has a start address that is shortly before a page
          boundary, then also here, curr->end - curr->start will just be
          very few bytes, where it's unrealistic that we could perform a
          match against.
      
      Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so
      that we can catch such corner cases and have a better chance to find
      that specific symbol. It's still just best effort as the real end of the
      symbol is unknown to us (and could even be at a larger offset than the
      current range), but better than the current situation.
      
      Alexei reported that he recently run into case i) with a JITed eBPF
      program (these are all page aligned) as the last symbol which wasn't
      properly shown in the call graph (while other eBPF program symbols in
      the rb tree were displayed correctly). Since this is a generic issue,
      lets try to improve the heuristic a bit.
      Reported-and-Tested-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Fixes: 2e538c4a ("perf tools: Improve kernel/modules symbol lookup")
      Link: http://lkml.kernel.org/r/bb5c80d27743be6f12afc68405f1956a330e1bc9.1489614365.git.daniel@iogearbox.netSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e7ede72a
  15. 08 2月, 2017 1 次提交
    • V
      perf symbols: Take into account symfs setting when reading file build ID · 9b200653
      Victor Kamensky 提交于
      After commit 5baecbcd ("perf symbols: we can now read separate
      debug-info files based on a build ID") and when --symfs option is used
      perf failed to pick up symbols for file with the same name between host
      and sysroot specified by --symfs option.  One can see message like this:
      
        bin/bash with build id 26f0062cb6950d4d1ab0fd9c43eae8b10ca42062 not found, continuing without symbols
      
      It happens because code added by 5baecbcd opens files directly by
      dso->long_name without symbol_conf.symfs consideration, which as result
      picks one from the host. It reads its build ID and later even code finds
      another proper file in directory pointed by --symfs perf ignores it
      because build id mismatches.
      
      Fix is to use __symbol__join_symfs to adjust file name according to
      --symfs setting. If no --symfs passed the operation would noop and picks
      the same host file as before.
      
      Also note in latter tree after 5baecbcd commit additional check for
      '!dso->has_build_id' was added, so to observe error condition 'perf
      record' should run with --no-buildid, so perf.data itself would not have
      build id for target binary in buildid perf section and 'perf report'
      will pass '!dso->has_build_id' condition. Or target binary should not
      have build id, but the same binary on host has build id, again
      '!dso->has_build_id' will pass in this case and incorrect build id could
      be read if --symfs is used.
      Signed-off-by: NVictor Kamensky <kamensky@cisco.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Chris Phlipot <cphlipot0@gmail.com>
      Cc: Dima Kogan <dima@secretsauce.net>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: xe-linux-external@cisco.com
      Fixes: 5baecbcd ("perf symbols: we can now read separate debug-info files based on a build ID")
      Link: http://lkml.kernel.org/r/1486424908-17094-1-git-send-email-kamensky@cisco.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b200653
  16. 20 12月, 2016 1 次提交
    • K
      perf diff: Do not overwrite valid build id · ed6c166c
      Kan Liang 提交于
      Fixes a perf diff regression issue which was introduced by commit
      5baecbcd ("perf symbols: we can now read separate debug-info files
      based on a build ID")
      
      The binary name could be same when perf diff different binaries. Build
      id is used to distinguish between them.
      However, the previous patch assumes the same binary name has same build
      id. So it overwrites the build id according to the binary name,
      regardless of whether the build id is set or not.
      
      Check the has_build_id in dso__load. If the build id is already set, use
      it.
      
      Before the fix:
      
        $ perf diff 1.perf.data 2.perf.data
        # Event 'cycles'
        #
        # Baseline    Delta  Shared Object     Symbol
        # ........  .......  ................  .............................
        #
          99.83%  -99.80%  tchain_edit       [.] f2
           0.12%  +99.81%  tchain_edit       [.] f3
           0.02%   -0.01%  [ixgbe]           [k] ixgbe_read_reg
      
        After the fix:
        $ perf diff 1.perf.data 2.perf.data
        # Event 'cycles'
        #
        # Baseline    Delta  Shared Object     Symbol
        # ........  .......  ................  .............................
        #
          99.83%   +0.10%  tchain_edit       [.] f3
           0.12%   -0.08%  tchain_edit       [.] f2
      Signed-off-by: NKan Liang <kan.liang@intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      CC: Dima Kogan <dima@secretsauce.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: 5baecbcd ("perf symbols: we can now read separate debug-info files based on a build ID")
      Link: http://lkml.kernel.org/r/1481642984-13593-1-git-send-email-kan.liang@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ed6c166c
  17. 30 11月, 2016 1 次提交
    • D
      perf script: Add option to stop printing callchain · 64eff7d9
      David Ahern 提交于
      Allow user to specify list of symbols which cause the dump of callchains
      to stop at that symbol.
      
      Committer notes:
      
      Testing it:
      
        # perf record -ag usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.177 MB perf.data (33 samples) ]
        #
        # # Without it:
        #
        # perf script
        swapper   0 [000]  9693.370039:          1 cycles:ppp:
                        2072ad x86_pmu_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        326978 flush_smp_call_function_queue (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        327413 generic_smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        249b37 smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        a04b2c call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        889427 cpuidle_enter (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        2e534a call_cpuidle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        2e5730 cpu_startup_entry (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        9f5167 rest_init (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                       137ffeb start_kernel ([kernel.vmlinux].init.text)
                       137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
                       137f419 x86_64_start_kernel ([kernel.vmlinux].init.text)
      
        swapper   0 [000]  9693.370044:          1 cycles:ppp:
                        20ca1b intel_pmu_handle_irq (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        205b0c perf_event_nmi_handler (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a14a nmi_handle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a6b3 default_do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a83c do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        a03fb1 end_repeat_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        326978 flush_smp_call_function_queue (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        327413 generic_smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        249b37 smp_call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        a04b2c call_function_single_interrupt (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        889427 cpuidle_enter (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        2e534a call_cpuidle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        2e5730 cpu_startup_entry (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        9f5167 rest_init (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                       137ffeb start_kernel ([kernel.vmlinux].init.text)
                       137f2ca x86_64_start_reservations ([kernel.vmlinux].init.text)
        #
        # # Using it to see just what are the calls from the 'remote_function' function:
        #
        # perf script --stop-bt remote_function
        swapper   0 [000]  9693.370039:          1 cycles:ppp:
                        2072ad x86_pmu_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
      
        swapper   0 [000]  9693.370044:          1 cycles:ppp:
                        20ca1b intel_pmu_handle_irq (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        205b0c perf_event_nmi_handler (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a14a nmi_handle (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a6b3 default_do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        22a83c do_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        a03fb1 end_repeat_nmi (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a29d7 perf_pmu_enable.part.90 (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a713a ctx_resched (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a76c1 __perf_event_enable (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a0390 event_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
                        3a1cff remote_function (/usr/lib/debug/lib/modules/4.8.8-300.fc25.x86_64/vmlinux)
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1480104021-36275-1-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      64eff7d9
  18. 25 11月, 2016 1 次提交
    • W
      perf record: Fix segfault when running with suid and kptr_restrict is 1 · 3dbe46c5
      Wang Nan 提交于
      Before this patch perf panics if kptr_restrict is set to 1 and perf is
      owned by root with suid set:
      
        $ whoami
        wangnan
        $ ls -l ./perf
        -rwsr-xr-x 1 root root 19781908 Sep 21 19:29 /home/wangnan/perf
        $ cat /proc/sys/kernel/kptr_restrict
        1
        $ cat /proc/sys/kernel/perf_event_paranoid
        -1
        $ ./perf record -a
        Segmentation fault (core dumped)
        $
      
      The reason is that perf assumes it is allowed to read kptr from
      /proc/kallsyms when euid is root, but in fact the kernel doesn't allow
      reading kptr when euid and uid do not match with each other:
      
        $ cp /bin/cat .
        $ sudo chown root:root ./cat
        $ sudo chmod u+s ./cat
        $ cat /proc/kallsyms | grep do_fork
        0000000000000000 T _do_fork          <--- kptr is hidden even euid is root
        $ sudo cat /proc/kallsyms | grep do_fork
        ffffffff81080230 T _do_fork
      
      See lib/vsprintf.c for kernel side code.
      
      This patch fixes this problem by checking both uid and euid.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/20161115040617.69788-3-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3dbe46c5
  19. 29 9月, 2016 1 次提交
  20. 05 9月, 2016 2 次提交
  21. 01 9月, 2016 2 次提交
  22. 30 8月, 2016 1 次提交
  23. 28 6月, 2016 1 次提交
    • J
      perf symbols: Use proper dso name for is_regular_file · ed7b630b
      Jiri Olsa 提交于
      Marc reported use of uninitialized memory:
      
      > In commit "40356721 perf symbols: Do not read symbols/data from
      > device files" a check to uninitialzied memory was added. This leads to
      > the following valgrind output:
      >
      >  ==24515== Syscall param stat(file_name) points to uninitialised byte(s)
      >  ==24515==    at 0x75B26D5: _xstat (in /lib/x86_64-linux-gnu/libc-2.22.so)
      >  ==24515==    by 0x4E548D: stat (stat.h:454)
      >  ==24515==    by 0x4E548D: is_regular_file (util.c:687)
      >  ==24515==    by 0x4A5BEE: dso__load (symbol.c:1435)
      >  ==24515==    by 0x4BB1AE: map__load (map.c:289)
      >  ==24515==    by 0x4BB1AE: map__find_symbol (map.c:333)
      >  ==24515==    by 0x4835B3: thread__find_addr_location (event.c:1300)
      >  ==24515==    by 0x4B5342: add_callchain_ip (machine.c:1652)
      >  ==24515==    by 0x4B5342: thread__resolve_callchain_sample (machine.c:1906)
      >  ==24515==    by 0x4B9E7D: thread__resolve_callchain (machine.c:1958)
      >  ==24515==    by 0x441B3E: process_event (builtin-script.c:795)
      >  ==24515==    by 0x441B3E: process_sample_event (builtin-script.c:920)
      >  ==24515==    by 0x4BEE29: perf_evlist__deliver_sample (session.c:1192)
      >  ==24515==    by 0x4BEE29: machines__deliver_event (session.c:1229)
      >  ==24515==    by 0x4BF770: perf_session__deliver_event (session.c:1286)
      >  ==24515==    by 0x4BF770: ordered_events__deliver_event (session.c:114)
      >  ==24515==    by 0x4C1D17: __ordered_events__flush (ordered-events.c:207)
      >  ==24515==    by 0x4C1D17: ordered_events__flush.part.3 (ordered-events.c:274)
      >  ==24515==    by 0x4BF44C: perf_session__process_user_event (session.c:1325)
      >  ==24515==    by 0x4BF44C: perf_session__process_event (session.c:1451)
      >  ==24515==  Address 0x807c6a0 is 0 bytes inside a block of size 4,096 alloc'd
      >  ==24515==    at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      >  ==24515==    by 0x4A5BCB: dso__load (symbol.c:1421)
      >  ==24515==    by 0x4BB1AE: map__load (map.c:289)
      >  ==24515==    by 0x4BB1AE: map__find_symbol (map.c:333)
      >  ==24515==    by 0x4835B3: thread__find_addr_location (event.c:1300)
      >  ==24515==    by 0x4B5342: add_callchain_ip (machine.c:1652)
      >  ==24515==    by 0x4B5342: thread__resolve_callchain_sample (machine.c:1906)
      >  ==24515==    by 0x4B9E7D: thread__resolve_callchain (machine.c:1958)
      >  ==24515==    by 0x441B3E: process_event (builtin-script.c:795)
      >  ==24515==    by 0x441B3E: process_sample_event (builtin-script.c:920)
      >  ==24515==    by 0x4BEE29: perf_evlist__deliver_sample (session.c:1192)
      >  ==24515==    by 0x4BEE29: machines__deliver_event (session.c:1229)
      >  ==24515==    by 0x4BF770: perf_session__deliver_event (session.c:1286)
      >  ==24515==    by 0x4BF770: ordered_events__deliver_event (session.c:114)
      >  ==24515==    by 0x4C1D17: __ordered_events__flush (ordered-events.c:207)
      >  ==24515==    by 0x4C1D17: ordered_events__flush.part.3 (ordered-events.c:274)
      >  ==24515==    by 0x4BF44C: perf_session__process_user_event (session.c:1325)
      >  ==24515==    by 0x4BF44C: perf_session__process_event (session.c:1451)
      >  ==24515==    by 0x4C0EAC: __perf_session__process_events (session.c:1804)
      >  ==24515==    by 0x4C0EAC: perf_session__process_events (session.c:1858)
      
      The reason was a typo that passed global 'name' variable as the
      is_regular_file argument instead dso->long_name.
      Reported-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 40356721 ("perf symbols: Do not read symbols/data from device files")
      Link: http://lkml.kernel.org/r/1466772025-17471-2-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ed7b630b
  24. 23 6月, 2016 1 次提交
  25. 31 5月, 2016 2 次提交