1. 30 9月, 2020 1 次提交
    • A
      perf trace beauty: Add script to autogenerate mremap's flags args string/id table · 9012e3dd
      Arnaldo Carvalho de Melo 提交于
      It'll also conditionally generate the defines, so that if we don't have
      those when building a new tool tarball in an older systems, we get
      those, and we need them sometimes in the actual scnprintf routine, such
      as when checking if a flags means we have an extra arg, like with
      MREMAP_FIXED.
      
        $ tools/perf/trace/beauty/mremap_flags.sh
        static const char *mremap_flags[] = {
        	[ilog2(1) + 1] = "MAYMOVE",
        #ifndef MREMAP_MAYMOVE
        #define MREMAP_MAYMOVE 1
        #endif
        	[ilog2(2) + 1] = "FIXED",
        #ifndef MREMAP_FIXED
        #define MREMAP_FIXED 2
        #endif
        	[ilog2(4) + 1] = "DONTUNMAP",
        #ifndef MREMAP_DONTUNMAP
        #define MREMAP_DONTUNMAP 4
        #endif
        };
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9012e3dd
  2. 05 9月, 2020 2 次提交
  3. 14 8月, 2020 1 次提交
    • F
      perf build-ids: Fall back to debuginfod query if debuginfo not found · c7a14fdc
      Frank Ch. Eigler 提交于
      During a perf-record, use the -ldebuginfod API to query a debuginfod
      server, should the debug data not be found in the usual system
      locations.  If successful, the usual $HOME/.debug dir is populated.
      
      Tested with:
      
        $ find .
        .
        ./ctags-debuginfo-5.8-26.fc31.x86_64.rpm
        ./usr
        ./usr/lib
        ./usr/lib/debug
        ./usr/lib/debug/.build-id
        ./usr/lib/debug/.build-id/ca
        ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d
        ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d.debug
        ./usr/lib/debug/usr
        ./usr/lib/debug/usr/bin
        ./usr/lib/debug/usr/bin/ctags-5.8-26.fc31.x86_64.debug
      
        $ debuginfod  -F .
        ...
      
        $ rm -rf ~/.debug/ ; mkdir ~/.debug
      
        $ perf record make tags
          BUILD:   Doing 'make -j8' parallel build
          GEN      tags
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.107 MB perf.data (1483 samples) ]
      
        $ find ~/.debug | grep ctags
        /home/jolsa/.debug/usr/bin/ctags
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes
      
        $ rm -rf ~/.debug/ ; mkdir ~/.debug
      
        $ DEBUGINFOD_URLS=http://localhost:8002 perf record make tags
          BUILD:   Doing 'make -j8' parallel build
          GEN      tags
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.108 MB perf.data (1531 samples) ]
      
        $ find ~/.debug | grep ctag
        /home/jolsa/.debug/usr/bin/ctags
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/debug
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes
      
      Note the 'debug' file is created in the last run.
      
      Note that currently the debuginfo data are downloaded only on record path,
      we still need add this support to perf build-id/report.. and test ;-)
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NFrank Ch. Eigler <fche@redhat.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c7a14fdc
  4. 12 8月, 2020 1 次提交
    • A
      perf trace beauty: Use the autogenerated protocol family table · f3cf7fa9
      Arnaldo Carvalho de Melo 提交于
      That helps us not to lose new protocol families when they are
      introduced, replacing that hardcoded, dated family->string table.
      
      To recap what this allows us to do:
      
        # perf trace -e syscalls:sys_enter_socket/max-stack=10/ --filter=family==INET --max-events=1
           0.000 fetchmail/41097 syscalls:sys_enter_socket(family: INET, type: DGRAM|CLOEXEC|NONBLOCK, protocol: IP)
                                             __GI___socket (inlined)
                                             reopen (/usr/lib64/libresolv-2.31.so)
                                             send_dg (/usr/lib64/libresolv-2.31.so)
                                             __res_context_send (/usr/lib64/libresolv-2.31.so)
                                             __GI___res_context_query (inlined)
                                             __GI___res_context_search (inlined)
                                             _nss_dns_gethostbyname4_r (/usr/lib64/libnss_dns-2.31.so)
                                             gaih_inet.constprop.0 (/usr/lib64/libc-2.31.so)
                                             __GI_getaddrinfo (inlined)
                                             [0x15cb2] (/usr/bin/fetchmail)
        #
      
      More work is still needed to allow for the more natura strace-like
      syscall name usage instead of the trace event name:
      
        # perf trace -e socket/max-stack=10,family==INET/ --max-events=1
      
      I.e. to allow for modifiers to follow the syscall name and for logical
      expressions to be accepted as filters to use with that syscall, be it as
      trace event filters or BPF based ones.
      
      Using -v we can see how the trace event filter is built:
      
        # perf trace -v -e syscalls:sys_enter_socket/call-graph=dwarf/ --filter=family==INET --max-events=2
        <SNIP>
        New filter for syscalls:sys_enter_socket: (family==0x2) && (common_pid != 41384 && common_pid != 2836)
        <SNIP>
      
        $ tools/perf/trace/beauty/socket.sh | grep -w 2
      	[2] = "INET",
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3cf7fa9
  5. 30 5月, 2020 2 次提交
    • S
      perf tools: Add optional support for libpfm4 · 70943490
      Stephane Eranian 提交于
      This patch links perf with the libpfm4 library if it is available and
      LIBPFM4 is passed to the build. The libpfm4 library contains hardware
      event tables for all processors supported by perf_events. It is a helper
      library that helps convert from a symbolic event name to the event
      encoding required by the underlying kernel interface. This library is
      open-source and available from: http://perfmon2.sf.net.
      
      With this patch, it is possible to specify full hardware events by name.
      Hardware filters are also supported. Events must be specified via the
      --pfm-events and not -e option. Both options are active at the same time
      and it is possible to mix and match:
      
        $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....
      
      One needs to explicitely ask for its inclusion by using the LIBPFM4 make
      command line option, ie its opt-in rather than opt-out of feature
      detection and build support.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70943490
    • A
      perf build: Allow explicitely disabling the NO_SYSCALL_TABLE variable · 43de3869
      Arnaldo Carvalho de Melo 提交于
      This is useful to see if, on x86, the legacy libaudit still works, as it
      is used in architectures that don't have the SYSCALL_TABLE logic and we
      want to have it tested in 'make -C tools/perf/ build-test'.
      
      E.g.:
      
      Without having audit-libs-devel installed:
      
        $ make NO_SYSCALL_TABLE=1 O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
        <SNIP>
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ OFF ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        Makefile.config:664: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
        <SNIP>
      
      After installing it:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ time make NO_SYSCALL_TABLE=1 O=/tmp/build/perf  -C tools/perf install-bin ; perf test python
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
          HOSTCC   /tmp/build/perf/fixdep.o
          HOSTLD   /tmp/build/perf/fixdep-in.o
          LINK     /tmp/build/perf/fixdep
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.h' differs from latest version at 'tools/lib/bpf/hashmap.h'
        diff -u tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.c' differs from latest version at 'tools/lib/bpf/hashmap.c'
        diff -u tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
      
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        $ ldd ~/bin/perf | grep audit
        	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fc18978e000)
        $
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200529155552.463-3-acme@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43de3869
  6. 28 5月, 2020 1 次提交
  7. 06 5月, 2020 1 次提交
    • I
      perf doc: Pass ASCIIDOC_EXTRA as an argument · 4b198449
      Ian Rogers 提交于
      commit e9cfa47e ("perf doc: allow ASCIIDOC_EXTRA to be an argument")
      allowed ASCIIDOC_EXTRA to be passed as an option to the Documentation
      Makefile. This change passes ASCIIDOC_EXTRA, set by detected features or
      command line options, prior to doing a Documentation build. This is
      necessary to allow conditional compilation, based on configuration
      variables, in asciidoc code.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.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>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200429231443.207201-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4b198449
  8. 26 3月, 2020 1 次提交
  9. 24 3月, 2020 1 次提交
  10. 06 1月, 2020 1 次提交
  11. 26 11月, 2019 1 次提交
    • J
      perf tools: Allow to link with libbpf dynamicaly · 7b65e203
      Jiri Olsa 提交于
      Currently we support only static linking with kernel's libbpf
      (tools/lib/bpf). This patch adds libbpf package detection and support to
      link perf with it dynamically.
      
      The libbpf package status is displayed with:
      
        $ make VF=1
        Auto-detecting system features:
        ...
        ...                        libbpf: [ on  ]
      
      It's not checked by default, because it's quite new.  Once it's on most
      distros we can switch it on.
      
      For the same reason it's not added to the test-all check.
      
      Perf does not need advanced version of libbpf, so we can check just for
      the base bpf_object__open function.
      
      Adding new compile variable to detect libbpf package and link bpf
      dynamically:
      
        $ make LIBBPF_DYNAMIC=1
          ...
          LINK     perf
        $ ldd perf | grep bpf
          libbpf.so.0 => /lib64/libbpf.so.0 (0x00007f46818bc000)
      
      If libbpf is not installed, build stops with:
      
        Makefile.config:486: *** Error: No libbpf devel library found,\
        please install libbpf-devel.  Stop.
      
      Committer testing:
      
        $ make LIBBPF_DYNAMIC=1 -C tools/perf O=/tmp/build/perf
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
        Makefile.config:493: *** Error: No libbpf devel library found, please install libbpf-devel.  Stop.
        make[1]: *** [Makefile.perf:225: sub-make] Error 2
        make: *** [Makefile:70: all] Error 2
        make: Leaving directory '/home/acme/git/perf/tools/perf'
        $
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Toke Høiland-Jørgensen <toke@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jesper Dangaard Brouer <brouer@redhat.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20191126121253.28253-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b65e203
  12. 16 10月, 2019 1 次提交
    • A
      libbeauty: Hook up the x86 irq_vectors table generator · f19a85c6
      Arnaldo Carvalho de Melo 提交于
      I.e. after running:
      
        $ make -C tools/perf O=/tmp/build/perf
      
      We end up with:
      
        $ cat /tmp/build/perf/trace/beauty/generated/x86_arch_irq_vectors_array.c
        static const char *x86_irq_vectors[] = {
        	[0x02] = "NMI",
        	[0x12] = "MCE",
        	[0x20] = "IRQ_MOVE_CLEANUP",
        	[0x80] = "IA32_SYSCALL",
        	[0xec] = "LOCAL_TIMER",
        	[0xed] = "HYPERV_STIMER0",
        	[0xee] = "HYPERV_REENLIGHTENMENT",
        	[0xef] = "MANAGED_IRQ_SHUTDOWN",
        	[0xf0] = "POSTED_INTR_NESTED",
        	[0xf1] = "POSTED_INTR_WAKEUP",
        	[0xf2] = "POSTED_INTR",
        	[0xf3] = "HYPERVISOR_CALLBACK",
        	[0xf4] = "DEFERRED_ERROR",
        	[0xf6] = "IRQ_WORK",
        	[0xf7] = "X86_PLATFORM_IPI",
        	[0xf8] = "REBOOT",
        	[0xf9] = "THRESHOLD_APIC",
        	[0xfa] = "THERMAL_APIC",
        	[0xfb] = "CALL_FUNCTION_SINGLE",
        	[0xfc] = "CALL_FUNCTION",
        	[0xfd] = "RESCHEDULE",
        	[0xfe] = "ERROR_APIC",
        	[0xff] = "SPURIOUS_APIC",
        };
        $
      
      Now its just a matter of using it, associating it to tracepoint arguments named
      'vector', all of which can be correctly used with this table, for int args.
      
      At some point we should move tools/perf/trace/beauty to tools/beauty/,
      so that it can be used more generally and even made available externally
      like libbpf, libperf, libtraceevent, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-0p2df4kq1afrxbck4e4ct34r@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f19a85c6
  13. 15 10月, 2019 1 次提交
    • J
      perf tools: Allow to build with -ltcmalloc · bb91a073
      Jiri Olsa 提交于
      By using "make TCMALLOC=1" you can enable perf to be build for usage
      with libtcmalloc.so (gperftools).
      
      Get heap profile (tools/perf directory):
      
        $ <install gperftools>
        $ make TCMALLOC=1 DEBUG=1
        $ HEAPPROFILE=/tmp/heapprof ./perf ...
        $ pprof ./perf /tmp/heapprof.000*
        (pprof) top
        Total: 2335.5 MB
          1735.1  74.3%  74.3%   1735.1  74.3% memdup
           402.0  17.2%  91.5%    402.0  17.2% zalloc
           140.2   6.0%  97.5%    145.8   6.2% map__new
            33.6   1.4%  98.9%     33.6   1.4% symbol__new
            12.4   0.5%  99.5%     12.4   0.5% alloc_event
             6.2   0.3%  99.7%      6.2   0.3% nsinfo__new
             5.5   0.2% 100.0%      5.5   0.2% nsinfo__copy
             0.3   0.0% 100.0%      0.3   0.0% dso__new
             0.1   0.0% 100.0%      0.1   0.0% do_read_string
             0.0   0.0% 100.0%      0.0   0.0% __GI__IO_file_doallocate
      
      See callstack:
        $ pprof --pdf ./perf /tmp/heapprof.00* > callstack.pdf
        $ pprof --web ./perf /tmp/heapprof.00*
      
      Committer testing:
      
      Install gperftools, on fedora:
      
        # dnf install gperftools-devel
      
      Then build:
      
       $ make TCMALLOC=1 DEBUG=1 -C tools/perf O=/tmp/build/perf install-bin
      
      Verify that it linked against the right library:
      
        $ ldd ~/bin/perf | grep tcma
      	libtcmalloc.so.4 => /lib64/libtcmalloc.so.4 (0x00007fb2953a7000)
        $
      
      Run 'perf trace' system wide for 1 minute:
      
        # HEAPPROFILE=/tmp/heapprof perf trace -a sleep 1m
        <SNIP>
         59985.524 ( 0.006 ms): Web Content/20354 recvmsg(fd: 9<socket:[1762817]>, msg: 0x7ffee5fdafb0) = -1 EAGAIN (Resource temporarily unavailable)
         59985.536 ( 0.005 ms): Web Content/20354 recvmsg(fd: 9<socket:[1762817]>, msg: 0x7ffee5fdafc0) = -1 EAGAIN (Resource temporarily unavailable)
         59981.956 (10.143 ms): SCTP timer/21716  ... [continued]: select())                            = 0 (Timeout)
         59985.549 (         ): Web Content/20354 poll(ufds: 0x7f1df38af180, nfds: 3, timeout_msecs: 4294967295) ...
             0.926 (59999.481 ms): sleep/29764  ... [continued]: nanosleep())                           = 0
         59992.133 (         ): SCTP timer/21716 select(tvp: 0x7ff5bf7fee80)                            ...
         60000.477 ( 0.009 ms): sleep/29764 close(fd: 1)                                                = 0
         60000.493 ( 0.005 ms): sleep/29764 close(fd: 2)                                                = 0
         60000.514 (         ): sleep/29764 exit_group()                                                = ?
        Dumping heap profile to /tmp/heapprof.0001.heap (Exiting, 3 MB in use)
      [root@quaco ~]#
      
      Install pprof:
      
        # dnf install pprof
      
      And run it:
      
        # pprof ~/bin/perf /tmp/heapprof.0001.heap
        Using local file /root/bin/perf.
        Using local file /tmp/heapprof.0001.heap.
        Welcome to pprof!  For help, type 'help'.
        (pprof) top
        Total: 4.0 MB
             1.7  42.0%  42.0%      2.2  54.1% map__new
             0.9  23.3%  65.3%      0.9  23.3% zalloc
             0.5  11.4%  76.7%      0.5  11.4% dso__new
             0.2   5.6%  82.3%      0.3   8.5% trace__sys_enter
             0.2   4.9%  87.2%      0.2   4.9% __GI___strdup
             0.2   3.8%  91.0%      0.2   3.8% new_term
             0.1   2.2%  93.2%      0.4  10.1% __perf_pmu__new_alias
             0.0   1.0%  94.3%      0.0   1.2% event_read_fields
             0.0   0.8%  95.1%      0.0   0.8% nsinfo__new
             0.0   0.7%  95.8%      0.1   3.2% trace__read_syscall_info
        (pprof)
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      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: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191013151427.11941-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bb91a073
  14. 11 10月, 2019 1 次提交
  15. 09 10月, 2019 1 次提交
    • A
      perf beauty: Hook up the x86 MSR table generator · fd218347
      Arnaldo Carvalho de Melo 提交于
      This way we generate the source with the table for later use by plugins,
      etc.
      
      I.e. after running:
      
        $ make -C tools/perf O=/tmp/build/perf
      
      We end up with:
      
        $ head /tmp/build/perf/trace/beauty/generated/x86_arch_MSRs_array.c
        static const char *x86_MSRs[] = {
        	[0x00000000] = "IA32_P5_MC_ADDR",
        	[0x00000001] = "IA32_P5_MC_TYPE",
        	[0x00000010] = "IA32_TSC",
        	[0x00000017] = "IA32_PLATFORM_ID",
        	[0x0000001b] = "IA32_APICBASE",
        	[0x00000020] = "KNC_PERFCTR0",
        	[0x00000021] = "KNC_PERFCTR1",
        	[0x00000028] = "KNC_EVNTSEL0",
        	[0x00000029] = "KNC_EVNTSEL1",
        $
      
      Now its just a matter of using it, first in a libtracevent plugin.
      
      At some point we should move tools/perf/trace/beauty to tools/beauty/,
      so that it can be used more generally and even made available externally
      like libbpf, libperf, libtraevent, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b3rmutg4igcohx6kpo67qh4j@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fd218347
  16. 25 9月, 2019 1 次提交
  17. 10 9月, 2019 1 次提交
  18. 13 8月, 2019 1 次提交
    • I
      tools build: Add capability-related feature detection · 74d5f3d0
      Igor Lubashev 提交于
      Add utilities to help checking capabilities of the running procss.  Make
      perf link with libcap, if it is available. If no libcap-dev[el], assume
      no capabilities.
      
      Committer testing:
      
        $ make O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
      
        Auto-detecting system features:
        <SNIP>
        ...                        libbfd: [ on  ]
        ...                        libcap: [ OFF ]
        ...                        libelf: [ on  ]
        <SNIP>
        Makefile.config:833: No libcap found, disables capability support, please install libcap-devel/libcap-dev
        <SNIP>
        $ grep libcap /tmp/build/perf/FEATURE-DUMP
        feature-libcap=0
        $ cat /tmp/build/perf/feature/test-libcap.make.output
        test-libcap.c:2:10: fatal error: sys/capability.h: No such file or directory
            2 | #include <sys/capability.h>
              |          ^~~~~~~~~~~~~~~~~~
        compilation terminated.
        $
      
      Now install libcap-devel and try again:
      
        $ make O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
        Warning: Kernel ABI header at 'tools/include/linux/bits.h' differs from latest version at 'include/linux/bits.h'
        diff -u tools/include/linux/bits.h include/linux/bits.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
        Auto-detecting system features:
        <SNIP>
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        <SNIP>>
          CC       /tmp/build/perf/jvmti/libjvmti.o
        <SNIP>>
        $ grep libcap /tmp/build/perf/FEATURE-DUMP
        feature-libcap=1
        $ cat /tmp/build/perf/feature/test-libcap.make.output
        $ ldd /tmp/build/perf/feature/test-libcap.make.bin
        ldd: /tmp/build/perf/feature/test-libcap.make.bin: No such file or directory
        $ ldd /tmp/build/perf/feature/test-libcap.bin
        	linux-vdso.so.1 (0x00007ffc35bfe000)
        	libcap.so.2 => /lib64/libcap.so.2 (0x00007ff9c62ff000)
        	libc.so.6 => /lib64/libc.so.6 (0x00007ff9c6139000)
        	/lib64/ld-linux-x86-64.so.2 (0x00007ff9c6326000)
        $
      Signed-off-by: NIgor Lubashev <ilubashe@akamai.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      [ split from a larger patch ]
      Link: http://lkml.kernel.org/r/8a1e76cf5c7c9796d0d4d240fbaa85305298aafa.1565188228.git.ilubashe@akamai.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      74d5f3d0
  19. 30 7月, 2019 2 次提交
    • J
      libperf: Add libperf to the python.so build · a429dcb8
      Jiri Olsa 提交于
      Link libperf.a with python.so.
      
      Committer testing:
      
      Continues to work:
      
        # perf test python
        18: 'import perf' in python                               : Ok
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-26-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a429dcb8
    • J
      libperf: Make libperf.a part of the perf build · 31435049
      Jiri Olsa 提交于
      Add an empty libperf.a under tools/perf/lib and link it with perf.
      
      It can also be built separately with:
      
        $ cd tools/perf/lib && make
          CC       core.o
          LD       libperf-in.o
          AR       libperf.a
          LINK     libperf.so
      
      Committer testing:
      
        $ make O=/tmp/build/perf -C tools/perf/lib/
        make: Entering directory '/home/acme/git/perf/tools/perf/lib'
          LINK     /tmp/build/perf/libperf.so
        make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
        $ ls -la /tmp/build/perf/libperf.so
        -rwxrwxr-x. 1 acme acme 16232 Jul 22 15:30 /tmp/build/perf/libperf.so
        $ file /tmp/build/perf/libperf.so
        /tmp/build/perf/libperf.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a51d227d871b381ddb686dcf94145c4dd908221, not stripped
        $ git status tools/perf
        On branch perf/core
        nothing to commit, working tree clean
        $
        $ ls -lart tools/perf/lib/
        total 16
        drwxrwxr-x. 16 acme acme 4096 Jul 22 15:29 ..
        -rw-rw-r--.  1 acme acme 1633 Jul 22 15:29 Makefile
        -rw-rw-r--.  1 acme acme    0 Jul 22 15:29 core.c
        -rw-rw-r--.  1 acme acme   20 Jul 22 15:29 Build
        drwxrwxr-x.  2 acme acme 4096 Jul 22 15:29 .
        $
      
      Committer notes:
      
      Need to add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
      -I$(srctree)/tools/include/uapi to tools/perf/lib/Makefile's INCLUDE
      variable to pick up the latest versions of kernel headers, even in older
      systems, this is in line with what is in tools/lib/bpf/Makefile.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-24-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      31435049
  20. 29 5月, 2019 5 次提交
    • A
      perf trace: Beautify 'sync_file_range' arguments · a9a187a7
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced sync_file_range
      flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e sync_file_range
      
      As root and see all sync_file_range syscalls with its args beautified.
      
        Doing a syscall strace like session looking for this syscall, then run
        postgresql's initdb command:
      
        # perf trace -e sync_file_range
        <SNIP>
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(7</var/lib/pgsql/data/base/1/2682>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(7</var/lib/pgsql/data/base/1/2682>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(4</var/lib/pgsql/data>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(4</var/lib/pgsql/data>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        ^C
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-8tqy34xhpg8gwnaiv74xy93w@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9a187a7
    • A
      perf trace: Beautify 'fsmount' arguments · f6af0956
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced fsmount
      attr_flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fsmount
      
      As root and see all fsmount syscalls with its args beautified.
      
        # cat sys_fsmount.c
        #define _GNU_SOURCE        /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
      
        #define __NR_fsmount 432
      
        #define MOUNT_ATTR_RDONLY	 0x00000001 /* Mount read-only */
        #define MOUNT_ATTR_NOSUID	 0x00000002 /* Ignore suid and sgid bits */
        #define MOUNT_ATTR_NODEV	 0x00000004 /* Disallow access to device special files */
        #define MOUNT_ATTR_NOEXEC	 0x00000008 /* Disallow program execution */
        #define MOUNT_ATTR__ATIME	 0x00000070 /* Setting on how atime should be updated */
        #define MOUNT_ATTR_RELATIME	 0x00000000 /* - Update atime relative to mtime/ctime. */
        #define MOUNT_ATTR_NOATIME	 0x00000010 /* - Do not update access times. */
        #define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
        #define MOUNT_ATTR_NODIRATIME	 0x00000080 /* Do not update directory access times */
      
        static inline int sys_fsmount(int fs_fd, int flags, int attr_flags)
        {
        	syscall(__NR_fsmount, fs_fd, flags, attr_flags);
        }
      
        int main(int argc, char *argv[])
        {
        	int attr_flags = 0, fs_fd = 0;
      
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_RDONLY;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOSUID;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NODEV;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOEXEC;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOATIME;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_STRICTATIME;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NODIRATIME;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	return 0;
        }
        #
        # perf trace -e fsmount ./sys_fsmount
        fsmount(0, 0, MOUNT_ATTR_RELATIME)      = -1 EINVAL (Invalid argument)
        fsmount(1, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
        fsmount(2, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
        fsmount(3, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
        fsmount(4, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
        fsmount(5, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME) = -1 EBADF (Bad file descriptor)
        fsmount(6, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME) = -1 EINVAL (Invalid argument)
        fsmount(7, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME) = -1 EINVAL (Invalid argument)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-w71uge0sfo6ns9uclhwtthca@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6af0956
    • A
      perf trace: Beautify 'fsconfig' arguments · dcc6fd64
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced fsconfig cmd
      table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fsconfig
      
      As root and see all fsconfig syscalls with its args beautified, more
      work needed to look at the command and according to it handle the 'key',
      'value' and 'aux' args, using the 'fcntl' and 'futex' beautifiers as a
      starting point to see how to suppress sets of these last three args that
      may not be used by the 'cmd' arg, etc.
      
        # cat sys_fsconfig.c
        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
        #include <fcntl.h>
      
        #define __NR_fsconfig 431
      
        enum fsconfig_command {
        	FSCONFIG_SET_FLAG	= 0,	/* Set parameter, supplying no value */
        	FSCONFIG_SET_STRING	= 1,	/* Set parameter, supplying a string value */
        	FSCONFIG_SET_BINARY	= 2,	/* Set parameter, supplying a binary blob value */
        	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */
        	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */
        	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */
        	FSCONFIG_CMD_CREATE	= 6,	/* Invoke superblock creation */
        	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */
        };
      
        static inline int sys_fsconfig(int fd, int cmd, const char *key, const void *value, int aux)
        {
        	syscall(__NR_fsconfig, fd, cmd, key, value, aux);
        }
      
        int main(int argc, char *argv[])
        {
        	int fd = 0, aux = 0;
      
        	open("/foo", 0);
        	sys_fsconfig(fd++, FSCONFIG_SET_FLAG,	     "/foo1", "/bar1", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_STRING,	     "/foo2", "/bar2", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_BINARY,	     "/foo3", "/bar3", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_PATH,	     "/foo4", "/bar4", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_PATH_EMPTY,  "/foo5", "/bar5", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_FD,	     "/foo6", "/bar6", aux++);
        	sys_fsconfig(fd++, FSCONFIG_CMD_CREATE,	     "/foo7", "/bar7", aux++);
        	sys_fsconfig(fd++, FSCONFIG_CMD_RECONFIGURE, "/foo8", "/bar8", aux++);
        	return 0;
        }
        # trace -e fsconfig ./sys_fsconfig
        fsconfig(0, FSCONFIG_SET_FLAG, 0x40201b, 0x402015, 0) = -1 EINVAL (Invalid argument)
        fsconfig(1, FSCONFIG_SET_STRING, 0x402027, 0x402021, 1) = -1 EINVAL (Invalid argument)
        fsconfig(2, FSCONFIG_SET_BINARY, 0x402033, 0x40202d, 2) = -1 EINVAL (Invalid argument)
        fsconfig(3, FSCONFIG_SET_PATH, 0x40203f, 0x402039, 3) = -1 EBADF (Bad file descriptor)
        fsconfig(4, FSCONFIG_SET_PATH_EMPTY, 0x40204b, 0x402045, 4) = -1 EBADF (Bad file descriptor)
        fsconfig(5, FSCONFIG_SET_FD, 0x402057, 0x402051, 5) = -1 EINVAL (Invalid argument)
        fsconfig(6, FSCONFIG_CMD_CREATE, 0x402063, 0x40205d, 6) = -1 EINVAL (Invalid argument)
        fsconfig(7, FSCONFIG_CMD_RECONFIGURE, 0x40206f, 0x402069, 7) = -1 EINVAL (Invalid argument)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-fb04b76cm59zfuv1wzu40uxy@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dcc6fd64
    • A
      perf trace: Beautify 'fspick' arguments · 693bd394
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first 2 args (dfd, path) and wire up
      the recently introduced fspick flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fspick
      
      As root and see all move_mount syscalls with its args beautified, either
      using the vfs_getname perf probe method or using the
      augmented_raw_syscalls.c eBPF helper to get the pathnames, the other
      args should work in all cases, i.e. all that is needed can be obtained
      directly from the raw_syscalls:sys_enter tracepoint args.
      
        # cat sys_fspick.c
        #define _GNU_SOURCE        /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
        #include <fcntl.h>
      
        #define __NR_fspick 433
      
        #define FSPICK_CLOEXEC          0x00000001
        #define FSPICK_SYMLINK_NOFOLLOW 0x00000002
        #define FSPICK_NO_AUTOMOUNT     0x00000004
        #define FSPICK_EMPTY_PATH       0x00000008
      
        static inline int sys_fspick(int fd, const char *path, int flags)
        {
        	syscall(__NR_fspick, fd, path, flags);
        }
      
        int main(int argc, char *argv[])
        {
        	int flags = 0, fd = 0;
      
        	open("/foo", 0);
        	sys_fspick(fd++, "/foo1", flags);
        	flags |= FSPICK_CLOEXEC;
        	sys_fspick(fd++, "/foo2", flags);
        	flags |= FSPICK_SYMLINK_NOFOLLOW;
        	sys_fspick(fd++, "/foo3", flags);
        	flags |= FSPICK_NO_AUTOMOUNT;
        	sys_fspick(fd++, "/foo4", flags);
        	flags |= FSPICK_EMPTY_PATH;
        	return sys_fspick(fd++, "/foo5", flags);
        }
        # perf trace -e fspick ./sys_fspick
        LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        fspick(0, "/foo1", 0)                   = -1 ENOENT (No such file or directory)
        fspick(1, "/foo2", FSPICK_CLOEXEC)      = -1 ENOENT (No such file or directory)
        fspick(2, "/foo3", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
        fspick(3, "/foo4", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT) = -1 ENOENT (No such file or directory)
        fspick(4, "/foo5", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT|FSPICK_EMPTY_PATH) = -1 ENOENT (No such file or directory)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-erau5xjtt8wvgnhvdbchstuk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      693bd394
    • A
      perf trace: Beautify 'move_mount' arguments · 566e3022
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first 4 args (to/from fds, pathnames)
      and wire up the recently introduced move_mount flags table generator.
      
      Now it should be possible to just use:
      
            perf trace -e move_mount
      
      As root and see all move_mount syscalls with its args beautified, except
      for the filenames, that need work in the augmented_raw_syscalls.c eBPF
      helper to pass more than one, see comment in the
      augmented_raw_syscalls.c source code, the other args should work in all
      cases, i.e. all that is needed can be obtained directly from the
      raw_syscalls:sys_enter tracepoint args.
      
      Running without the strace "skin" (.perfconfig setting output formatting
      switches to look like strace output + BPF to collect strings, as we
      still need to support collecting multiple string args for the same
      syscall, like with move_mount):
      
        # cat sys_move_mount.c
        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
      
        #define __NR_move_mount 429
      
        #define MOVE_MOUNT_F_SYMLINKS		0x00000001 /* Follow symlinks on from path */
        #define MOVE_MOUNT_F_AUTOMOUNTS		0x00000002 /* Follow automounts on from path */
        #define MOVE_MOUNT_F_EMPTY_PATH		0x00000004 /* Empty from path permitted */
        #define MOVE_MOUNT_T_SYMLINKS		0x00000010 /* Follow symlinks on to path */
        #define MOVE_MOUNT_T_AUTOMOUNTS		0x00000020 /* Follow automounts on to path */
        #define MOVE_MOUNT_T_EMPTY_PATH		0x00000040 /* Empty to path permitted */
      
        static inline int sys_move_mount(int from_fd, const char *from_pathname,
        				 int to_fd, const char *to_pathname,
        				 int flags)
        {
        	  syscall(__NR_move_mount, from_fd, from_pathname, to_fd, to_pathname, flags);
        }
      
        int main(int argc, char *argv[])
        {
        	  int flags = 0, from_fd = 0, to_fd = 100;
      
        	  sys_move_mount(from_fd++, "/foo", to_fd++, "bar", flags);
        	  flags |= MOVE_MOUNT_F_SYMLINKS;
        	  sys_move_mount(from_fd++, "/foo1", to_fd++, "bar1", flags);
                flags |= MOVE_MOUNT_F_AUTOMOUNTS;
        	  sys_move_mount(from_fd++, "/foo2", to_fd++, "bar2", flags);
                flags |= MOVE_MOUNT_F_EMPTY_PATH;
        	  sys_move_mount(from_fd++, "/foo3", to_fd++, "bar3", flags);
                flags |= MOVE_MOUNT_T_SYMLINKS;
        	  sys_move_mount(from_fd++, "/foo4", to_fd++, "bar4", flags);
                flags |= MOVE_MOUNT_T_AUTOMOUNTS;
        	  sys_move_mount(from_fd++, "/foo5", to_fd++, "bar5", flags);
                flags |= MOVE_MOUNT_T_EMPTY_PATH;
        	  return sys_move_mount(from_fd++, "/foo6", to_fd++, "bar6", flags);
        }
        # mv ~/.perfconfig  ~/.perfconfig.OFF
        # perf trace -e move_mount ./sys_move_mount
             0.000 ( 0.009 ms): sys_move_mount/28971 move_mount(from_pathname: 0x402010, to_dfd: 100, to_pathname: 0x402015) = -1 ENOENT (No such file or directory)
             0.011 ( 0.003 ms): sys_move_mount/28971 move_mount(from_dfd: 1, from_pathname: 0x40201e, to_dfd: 101, to_pathname: 0x402019, flags: F_SYMLINKS) = -1 ENOENT (No such file or directory)
             0.016 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 2, from_pathname: 0x402029, to_dfd: 102, to_pathname: 0x402024, flags: F_SYMLINKS|F_AUTOMOUNTS) = -1 ENOENT (No such file or directory)
             0.020 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 3, from_pathname: 0x402034, to_dfd: 103, to_pathname: 0x40202f, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH) = -1 ENOENT (No such file or directory)
             0.023 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 4, from_pathname: 0x40203f, to_dfd: 104, to_pathname: 0x40203a, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS) = -1 ENOENT (No such file or directory)
             0.027 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 5, from_pathname: 0x40204a, to_dfd: 105, to_pathname: 0x402045, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS) = -1 ENOENT (No such file or directory)
             0.031 ( 0.017 ms): sys_move_mount/28971 move_mount(from_dfd: 6, from_pathname: 0x402055, to_dfd: 106, to_pathname: 0x402050, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS|T_EMPTY_PATH) = -1 ENOENT (No such file or directory)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-83rim8g4k0s4gieieh5nnlck@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      566e3022
  21. 21 5月, 2019 1 次提交
  22. 02 4月, 2019 1 次提交
  23. 29 3月, 2019 1 次提交
    • A
      tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h · be709d48
      Arnaldo Carvalho de Melo 提交于
      To deal with the move of some defines from asm-generic/mmap-common.h to
      linux/mman.h done in:
      
        746c9398 ("arch: move common mmap flags to linux/mman.h")
      
      The generated mmap_flags array stays the same:
      
        $ tools/perf/trace/beauty/mmap_flags.sh
        static const char *mmap_flags[] = {
      	[ilog2(0x40) + 1] = "32BIT",
      	[ilog2(0x01) + 1] = "SHARED",
      	[ilog2(0x02) + 1] = "PRIVATE",
      	[ilog2(0x10) + 1] = "FIXED",
      	[ilog2(0x20) + 1] = "ANONYMOUS",
      	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
      	[ilog2(0x0100) + 1] = "GROWSDOWN",
      	[ilog2(0x0800) + 1] = "DENYWRITE",
      	[ilog2(0x1000) + 1] = "EXECUTABLE",
      	[ilog2(0x2000) + 1] = "LOCKED",
      	[ilog2(0x4000) + 1] = "NORESERVE",
      	[ilog2(0x8000) + 1] = "POPULATE",
      	[ilog2(0x10000) + 1] = "NONBLOCK",
      	[ilog2(0x20000) + 1] = "STACK",
      	[ilog2(0x40000) + 1] = "HUGETLB",
      	[ilog2(0x80000) + 1] = "SYNC",
        };
        $
      
      And to have the system's sys/mman.h find the definition of MAP_SHARED
      and MAP_PRIVATE, make sure they are defined in the tools/ mman-common.h
      in a way that keeps it the same as the kernel's, need for keeping the
      Android's NDK cross build working.
      
      This silences these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h'
        diff -u tools/include/uapi/asm-generic/mman-common.h include/uapi/asm-generic/mman-common.h
        Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h' differs from latest version at 'include/uapi/linux/mman.h'
        diff -u tools/include/uapi/linux/mman.h include/uapi/linux/mman.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-h80ycpc6pedg9s5z2rwpy6ws@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      be709d48
  24. 15 2月, 2019 3 次提交
    • J
      perf tools: Rename LIB_FILE to LIBPERF_A · 6368942a
      Jiri Olsa 提交于
      Simple rename, no functional change.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6368942a
    • J
      perf tools: Compile perf with libperf-in.o instead of libperf.a · d0bfbeda
      Jiri Olsa 提交于
      There's no need for perf build to use libperf.a,
      we can use directly libperf-in.o.
      
      The libperf.a stays as a target if needed:
      
        $ make libperf.a
        ...
          CC       util/pmu.o
          CC       util/pmu-flex.o
          LD       util/libperf-in.o
          LD       libperf-in.o
          AR       libperf.a
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d0bfbeda
    • A
      perf coresight: Do not test for libopencsd by default · 1c3b28fd
      Arnaldo Carvalho de Melo 提交于
      Since it is not yet that generally available, avoid testing for the
      presence of libcoresight in the fast path test-all.bin feature test.
      
        # dnf search opencsd
        No matches found.
        # dnf search OpenCSD
        No matches found.
        # cat /etc/fedora-release
        Fedora release 29 (Twenty Nine)
        #
      
      I.e. right now, in my system test-all.bin is failing all the time since
      Fedora29 doesn't have libopencsd available:
      
        $ cat /tmp/build/perf/feature/test-all.make.output
        In file included from test-all.c:174:
        test-libopencsd.c:2:10: fatal error: opencsd/c_api/opencsd_c_api.h: No such file or directory
         #include <opencsd/c_api/opencsd_c_api.h>
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
      
      See:
      
        6ab2b762 ("perf build: Disable libbabeltrace check by default")
      
      For the rationale, as soon as libopencsd becomes more generally packaged
      and available, we do the same thing we did with babeltrace, enabling it
      by default, as done in:
      
        24787afb ("perf tools: Enable LIBBABELTRACE by default")
      
      For now, to explicitely ask for opencsd, make sure you have it installed
      and use:
      
         make -C tools/perf CORESIGHT=1
      
      The feature test output will be there as an empty file:
      
        $ ls -la /tmp/build/perf/feature/test-libopencsd.make.output
      
      Because the binary used for the feature check was successfully built:
      
        $ ls -la /tmp/build/perf/feature/test-libopencsd.bin
        -rwxrwxr-x. 1 acme acme 18336 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.bin
        $ ldd /tmp/build/perf/feature/test-libopencsd.bin
      	linux-vdso.so.1 (0x00007fffe18cc000)
      	libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fb8e67f6000)
      	libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fb8e676f000)
      	libc.so.6 => /lib64/libc.so.6 (0x00007fb8e65a9000)
      	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fb8e6411000)
      	libm.so.6 => /lib64/libm.so.6 (0x00007fb8e628d000)
      	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fb8e6272000)
      	/lib64/ld-linux-x86-64.so.2 (0x00007fb8e6828000)
        $
      
      And the resulting perf binary will be linked with it:
      
        -rw-rw-r--. 1 acme acme 0 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.make.output
        $ ldd ~/bin/perf | grep opencsd
      	libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fd43097f000)
      	libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fd4308f8000)
        $
      
      To make sure this gets built before pushing things upstream I have a
      ubuntu:19.04-x-arm64 container that has:
      
        [root@quaco x-arm64]# grep CORESIGHT Dockerfile
        ENV EXTRA_MAKE_ARGS=CORESIGHT=1
        [root@quaco x-arm64]#
      
      So that I always build with libopencsd before pushing things upstream.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Link: https://lkml.kernel.org/n/tip-20vyy39jw9jgrijesi30fgox@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1c3b28fd
  25. 25 1月, 2019 1 次提交
  26. 09 1月, 2019 1 次提交
  27. 04 1月, 2019 1 次提交
  28. 29 12月, 2018 1 次提交
    • A
      perf trace: Wire up ioctl's USBDEBFS_ cmd table generator · 86cf4c65
      Arnaldo Carvalho de Melo 提交于
      That ends up generating this:
      
        [acme@quaco perf]$ cat /tmp/build/perf/trace/beauty/generated/ioctl/usbdevfs_ioctl_array.c
        static const char *usbdevfs_ioctl_cmds[] = {
      	[0] = "CONTROL",
      	[10] = "SUBMITURB",
      	[11] = "DISCARDURB",
      	[12] = "REAPURB",
      	[13] = "REAPURBNDELAY",
      	[14] = "DISCSIGNAL",
      	[15] = "CLAIMINTERFACE",
      	[16] = "RELEASEINTERFACE",
      	[17] = "CONNECTINFO",
      	[18] = "IOCTL",
      	[19] = "HUB_PORTINFO",
      	[2] = "BULK",
      	[20] = "RESET",
      	[21] = "CLEAR_HALT",
      	[22] = "DISCONNECT",
      	[23] = "CONNECT",
      	[24] = "CLAIM_PORT",
      	[25] = "RELEASE_PORT",
      	[26] = "GET_CAPABILITIES",
      	[27] = "DISCONNECT_CLAIM",
      	[28] = "ALLOC_STREAMS",
      	[29] = "FREE_STREAMS",
      	[3] = "RESETEP",
      	[30] = "DROP_PRIVILEGES",
      	[31] = "GET_SPEED",
      	[4] = "SETINTERFACE",
      	[5] = "SETCONFIGURATION",
      	[8] = "GETDRIVER",
        };
      
        #if 0
        static const char *usbdevfs_ioctl_32_cmds[] = {
      	[0] = "CONTROL32",
      	[10] = "SUBMITURB32",
      	[12] = "REAPURB32",
      	[13] = "REAPURBNDELAY32",
      	[14] = "DISCSIGNAL32",
      	[18] = "IOCTL32",
      	[2] = "BULK32",
        };
        #endif
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-hkam6lt1g806l0p4b7buif3n@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      86cf4c65
  29. 19 12月, 2018 2 次提交
  30. 18 12月, 2018 1 次提交