Skip to content
Snippets Groups Projects
  1. Jul 21, 2020
  2. May 05, 2020
    • Ian Rogers's avatar
      libsymbols kallsyms: Parse using io api · 53df2b93
      Ian Rogers authored
      
      'perf record' will call kallsyms__parse 4 times during startup and
      process megabytes of data. This changes kallsyms__parse to use the io
      library rather than fgets to improve performance of the user code by
      over 8%.
      
      Before:
      
        Running 'internals/kallsyms-parse' benchmark:
        Average kallsyms__parse took: 103.988 ms (+- 0.203 ms)
      
      After:
      
        Running 'internals/kallsyms-parse' benchmark:
        Average kallsyms__parse took: 95.571 ms (+- 0.006 ms)
      
      For a workload like:
      
        $ perf record /bin/true
        Run under 'perf record -e cycles:u -g' the time goes from:
        Before
        30.10%     1.67%  perf     perf                [.] kallsyms__parse
        After
        25.55%    20.04%  perf     perf                [.] kallsyms__parse
      
      So a little under 5% of the start-up time is removed. A lot of what
      remains is on the kernel side, but caching kallsyms within perf would at
      least impact memory footprint.
      
      Committer notes:
      
      The internal/kallsyms-parse bench is run using:
      
        [root@five ~]# perf bench internals kallsyms-parse
        # Running 'internals/kallsyms-parse' benchmark:
          Average kallsyms__parse took: 80.381 ms (+- 0.115 ms)
        [root@five ~]#
      
      And this pre-existing test uses these routines to parse kallsyms and
      then compare with the info obtained from the matching ELF symtab:
      
        [root@five ~]# perf test vmlinux
         1: vmlinux symtab matches kallsyms                       : Ok
        [root@five ~]#
      
      Also we can't remove hex2u64() in this patch as this breaks the build:
      
        /usr/bin/ld: /tmp/build/perf/perf-in.o: in function `modules__parse':
        /home/acme/git/perf/tools/perf/util/symbol.c:607: undefined reference to `hex2u64'
        /usr/bin/ld: /home/acme/git/perf/tools/perf/util/symbol.c:607: undefined reference to `hex2u64'
        /usr/bin/ld: /tmp/build/perf/perf-in.o: in function `dso__load_perf_map':
        /home/acme/git/perf/tools/perf/util/symbol.c:1477: undefined reference to `hex2u64'
        /usr/bin/ld: /home/acme/git/perf/tools/perf/util/symbol.c:1483: undefined reference to `hex2u64'
        collect2: error: ld returned 1 exit status
      
      Leave it there, move it in the next patch.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/20200501221315.54715-3-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      53df2b93
  3. Apr 30, 2020
  4. Apr 16, 2020
    • Stephane Eranian's avatar
      tools api fs: Make xxx__mountpoint() more scalable · c6fddb28
      Stephane Eranian authored
      
      The xxx_mountpoint() interface provided by fs.c finds mount points for
      common pseudo filesystems. The first time xxx_mountpoint() is invoked,
      it scans the mount table (/proc/mounts) looking for a match. If found,
      it is cached. The price to scan /proc/mounts is paid once if the mount
      is found.
      
      When the mount point is not found, subsequent calls to xxx_mountpoint()
      scan /proc/mounts over and over again.  There is no caching.
      
      This causes a scaling issue in perf record with hugeltbfs__mountpoint().
      The function is called for each process found in
      synthesize__mmap_events().  If the machine has thousands of processes
      and if the /proc/mounts has many entries this could cause major overhead
      in perf record. We have observed multi-second slowdowns on some
      configurations.
      
      As an example on a laptop:
      
      Before:
      
        $ sudo umount /dev/hugepages
        $ strace -e trace=openat -o /tmp/tt perf record -a ls
        $ fgrep mounts /tmp/tt
        285
      
      After:
      
        $ sudo umount /dev/hugepages
        $ strace -e trace=openat -o /tmp/tt perf record -a ls
        $ fgrep mounts /tmp/tt
        1
      
      One could argue that the non-caching in case the moint point is not
      found is intentional. That way subsequent calls may discover a moint
      point if the sysadmin mounts the filesystem. But the same argument could
      be made against caching the mount point. It could be unmounted causing
      errors.  It all depends on the intent of the interface. This patch
      assumes it is expected to scan /proc/mounts once. The patch documents
      the caching behavior in the fs.h header file.
      
      An alternative would be to just fix perf record. But it would solve the
      problem with hugetlbs__mountpoint() but there could be similar issues
      (possibly down the line) with other xxx_mountpoint() calls in perf or
      other tools.
      
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrey Zhizhikin <andrey.z@gmail.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lore.kernel.org/lkml/20200402154357.107873-3-irogers@google.com
      
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c6fddb28
  5. Mar 04, 2020
  6. Jan 06, 2020
  7. Oct 18, 2019
  8. Jun 05, 2019
  9. Oct 16, 2018
    • Jiri Olsa's avatar
      perf tools: Fix tracing_path_mount proper path · c458a620
      Jiri Olsa authored
      If there's no tracefs (RHEL7) support the tracing_path_mount
      returns debugfs path which results in following fail:
      
        # perf probe sys_write
        kprobe_events file does not exist - please rebuild kernel with CONFIG_KPROBE_EVENTS.
        Error: Failed to add events.
      
      In tracing_path_debugfs_mount function we need to return the
      'tracing' path instead of just the mount to make it work:
      
        # perf probe sys_write
        Added new event:
          probe:sys_write      (on sys_write)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:sys_write -aR sleep 1
      
      Adding the 'return tracing_path;' also to tracing_path_tracefs_mount
      function just for consistency with tracing_path_debugfs_mount.
      
      Upstream keeps working, because it has the tracefs support.
      
      Link: http://lkml.kernel.org/n/tip-yiwkzexq9fk1ey1xg3gnjlw4@git.kernel.org
      
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Fixes: 23773ca1 ("perf tools: Make perf aware of tracefs")
      Link: http://lkml.kernel.org/r/20181016114818.3595-1-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c458a620
  10. Jun 15, 2018
  11. May 17, 2018
  12. May 16, 2018
  13. Feb 16, 2018
  14. Nov 02, 2017
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      
      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: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  15. Sep 12, 2017
  16. Aug 28, 2017
  17. Jun 21, 2017
  18. Mar 17, 2017
  19. Feb 14, 2017
  20. Feb 08, 2017
    • Ravi Bangoria's avatar
      perf sdt: Show proper hint when event not yet in place via 'perf probe' · 27cf5706
      Ravi Bangoria authored
      
      All events from 'perf list', except SDT events, can be directly recorded
      with 'perf record'. But, the flow is little different for SDT events.
      
      Probe points for SDT event needs to be created using 'perf probe' before
      recording it using 'perf record'.
      
      Perf shows misleading hint when a user tries to record SDT event without
      first creating a probe point. Show proper hint there.
      
      Before patch:
      
        $ perf record -a -e sdt_glib:idle__add
          event syntax error: 'sdt_glib:idle__add'
                               \___ unknown tracepoint
      
          Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
          Hint:  Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
          ...
      
      After patch:
      
        $ perf record -a -e sdt_glib:idle__add
          event syntax error: 'sdt_glib:idle__add'
                               \___ unknown tracepoint
      
          Error: File /sys/kernel/debug/tracing/events/sdt_glib/idle__add not found.
          Hint:  SDT event cannot be directly recorded on.
                 Please first use 'perf probe sdt_glib:idle__add' before recording it.
          ...
      
        $ perf probe sdt_glib:idle__add
          Added new event:
            sdt_glib:idle__add   (on %idle__add in /usr/lib64/libglib-2.0.so.0.5000.2)
      
          You can now use it in all perf tools, such as:
      
              perf record -e sdt_glib:idle__add -aR sleep 1
      
        $ perf record -a -e sdt_glib:idle__add
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.175 MB perf.data ]
      
      Suggested-and-Acked-by: default avatarIngo Molnar <mingo@redhat.com>
      Signed-off-by: default avatarRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170203102642.17258-1-ravi.bangoria@linux.vnet.ibm.com
      
      
      [ s/Please use/Please first use/ and break the Hint line in two ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      27cf5706
  21. Jan 31, 2017
  22. Dec 11, 2016
  23. Sep 08, 2016
  24. Jul 27, 2016
  25. Jul 15, 2016
  26. Jul 12, 2016
  27. Jul 04, 2016
  28. Jun 03, 2016
  29. May 30, 2016
  30. Apr 26, 2016
  31. Mar 18, 2016
  32. Feb 16, 2016
Loading