1. 21 Dec, 2018 4 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Do not hardcode the size of the tracepoint common_ fields · b9b6a2ea
      Arnaldo Carvalho de Melo authored
      We shouldn't hardcode the size of the tracepoint common_ fields, use the
      offset of the 'id'/'__syscallnr' field in the sys_enter event instead.
      
      This caused the augmented syscalls code to fail on a particular build of a
      PREEMPT_RT_FULL kernel where these extra 'common_migrate_disable' and
      'common_padding' fields were before the syscall id one:
      
        # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format
        name: sys_enter
        ID: 22
        format:
      	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
      	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
      	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
      	field:int common_pid;	offset:4;	size:4;	signed:1;
      	field:unsigned short common_migrate_disable;	offset:8;	size:2;	signed:0;
      	field:unsigned short common_padding;	offset:10;	size:2;	signed:0;
      
      	field:long id;	offset:16;	size:8;	signed:1;
      	field:unsigned long args[6];	offset:24;	size:48;	signed:0;
      
        print fmt: "NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)", REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3], REC->args[4], REC->args[5]
        #
      
      All those 'common_' prefixed fields are zeroed when they hit a BPF tracepoint
      hook, we better just discard those, i.e. somehow pass an offset to the
      BPF program from the start of the ctx and make adjustments in the 'perf trace'
      handlers to adjust the offset of the syscall arg offsets obtained from tracefs.
      
      Till then, fix it the quick way and add this to the augmented_raw_syscalls.c to
      bet it to work in such kernels:
      
        diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c
        index 53c233370fae..1f746f931e13 100644
        --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c
        +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c
        @@ -38,12 +38,14 @@ struct bpf_map SEC("maps") syscalls = {
      
         struct syscall_enter_args {
                unsigned long long common_tp_fields;
        +       long               rt_common_tp_fields;
                long               syscall_nr;
                unsigned long      args[6];
         };
      
         struct syscall_exit_args {
                unsigned long long common_tp_fields;
        +       long               rt_common_tp_fields;
                long               syscall_nr;
                long               ret;
         };
      
      Just to check that this was the case. Fix it properly later, for now remove the
      hardcoding of the offset in the 'perf trace' side and document the situation
      with this patch.
      
      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-2pqavrktqkliu5b9nzouio21@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b9b6a2ea
    • Stanislav Fomichev's avatar
      perf build: Don't unconditionally link the libbfd feature test to -liberty and -lz · 14541b1e
      Stanislav Fomichev authored
      Current libbfd feature test unconditionally links against -liberty and -lz.
      While it's required on some systems (e.g. opensuse), it's completely
      unnecessary on the others, where only -lbdf is sufficient (debian).
      This patch streamlines (and renames) the following feature checks:
      
      feature-libbfd           - only link against -lbfd (debian),
                                 see commit 2cf90407 ("perf tools: Fix bfd
      			   dependency libraries detection")
      feature-libbfd-liberty   - link against -lbfd and -liberty
      feature-libbfd-liberty-z - link against -lbfd, -liberty and -lz (opensuse),
                                 see commit 280e7c48 ("perf tools: fix BFD
      			   detection on opensuse")
      
      (feature-liberty{,-z} were renamed to feature-libbfd-liberty{,z}
      for clarity)
      
      The main motivation is to fix this feature test for bpftool which is
      currently broken on debian (libbfd feature shows OFF, but we still
      unconditionally link against -lbfd and it works).
      
      Tested on debian with only -lbfd installed (without -liberty); I'd
      appreciate if somebody on the other systems can test this new detection
      method.
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/4dfc634cfcfb236883971b5107cf3c28ec8a31be.1542328222.git.sdf@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      14541b1e
    • Arnaldo Carvalho de Melo's avatar
      perf beauty mmap: PROT_WRITE should come before PROT_EXEC · 5ce29d52
      Arnaldo Carvalho de Melo authored
      To match strace output:
      
        # cat mmap.c
        #include <sys/mman.h>
      
        int main(void)
        {
      	  mmap(0, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
      	  return 0;
        }
        # strace -e mmap ./mmap |& grep -v ^+++
        mmap(NULL, 103484, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5bae400000
        mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5bae3fe000
        mmap(NULL, 3889792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5bade40000
        mmap(0x7f5bae1ec000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ac000) = 0x7f5bae1ec000
        mmap(0x7f5bae1f2000, 14976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5bae1f2000
        mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5bae419000
        # trace -e mmap ./mmap |& grep -v ^+++
        mmap(NULL, 103484, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f6646c25000
        mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS) = 0x7f6646c23000
        mmap(NULL, 3889792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f6646665000
        mmap(0x7f6646a11000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ac000) = 0x7f6646a11000
        mmap(0x7f6646a17000, 14976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS) = 0x7f6646a17000
        mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS) = 0x7f6646c3e000
        #
      Reported-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-nt49d6iqle80cw8f529ovaqi@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ce29d52
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Check if the raw_syscalls:sys_{enter,exit} are setup before setting tp filter · f76214f9
      Arnaldo Carvalho de Melo authored
      While updating 'perf trace' on an machine with an old precompiled
      augmented_raw_syscalls.o that didn't setup the syscall map the new 'perf
      trace' codebase notices the augmented_raw_syscalls.o eBPF event, decides
      to use it instead of the old raw_syscalls:sys_{enter,exit} method, but
      then because we don't have the syscall map tries to set the tracepoint
      filter on the sys_{enter,exit} evsels, that are NULL, segfaulting.
      
      Make the code more robust by checking it those tracepoints have
      their respective evsels in place before trying to set the tp filter.
      
      With this we still get everything to work, just not setting up the
      syscall filters, which is better than a segfault. Now to update the
      precompiled augmented_raw_syscalls.o and continue development :-)
      
      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-3ft5rjdl05wgz2pwpx2z8btu@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f76214f9
  2. 20 Dec, 2018 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.21-20181218' of... · 883f4def
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.21-20181218' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      - Implement BPF based syscall filtering in 'perf trace', using BPF maps and
        the augmented_raw_syscalls.c BPF proggie (Arnaldo Carvalho de Melo)
      
      - Allow specifying in .perfconfig a set of events use in 'perf trace' in
        addition to any other specified from the command line. This initially
        will be used to always use the augmented_raw_syscalls.o precompiled
        BPF program for getting pointer contents. (Arnaldo Carvalho de Melo)
      
      - Allow fine grained control about how the syscall output should be
        formatted. This will be used to allow producing the same output produced
        by the 'strace' tool, to then use in regression tests comparing the
        output of 'perf trace' with the one produced from 'strace' (Arnaldo Carvalho de Melo)
      
      - Beautify the renameat2 olddirfd, newdirfd and flags arguments (Arnaldo Carvalho de Melo)
      
      - Beautify arch_prctl 'code' syscall arg (Arnaldo Carvalho de Melo)
      
      - Beautify fadvise64 'advice' syscall arg (Arnaldo Carvalho de Melo)
      
      - Relax checks on perf-PID.map ownership, resulting in symbols in
        executable anonymous maps setup by JITs in things like node.js to
        be resolved in a 'perf top' session run by root without the need
        for --force to be used (Arnaldo Carvalho de Melo)
      
      - Update asm-generic/unistd.h copy (Arnaldo Carvalho de Melo)
      
      - Do not use the first and last symbols when setting up address filters in
        auxtrace, this fails when we don't have a symbol table, filter the entire
        area based on the dso size. (Adrian Hunter)
      
      - Do not use kernel headers to build libsubcmd, we shouldn't use
        anything from outside tools/, fixes the build with the Android NDK (Arnaldo Carvalho de Melo)
      
      - Add several prototypes for systems lacking those, such as open_memstream(),
        sigqueue(), fixing warnings building with Android's bionic libc that were
        preventing the use of -Werror there (Arnaldo Carvalho de Melo)
      
      - Use LDFLAGS in the libtraceevent build commands, allowing developers
        to override its values (Jiri Olsa)
      
      - Link libperf-jvmti.so with LDFLAGS variable, allowing distro
        packages to propagate its settings when building this library (Jiri Olsa)
      
      - cs-etm (ARM CoreSight) fixes: (Leo Yan)
      
        - Correct packets swapping in cs_etm__flush()
        - Avoid stale branch samples when flush packet
        - Remove unused 'trace_on' in cs_etm_decoder
        - Refactor enumeration cs_etm_sample_type
        - Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY
        - Treat NO_SYNC element as trace discontinuity
        - Treat EO_TRACE element as trace discontinuity
        - Generate branch sample for exception packet
      
      - Use shebangs in the 'perf test' shell scripts, making them identifiable as
        shell scripts (Michael Petlan)
      
      - Avoid segfaults caused by negated options in 'perf stat' (Michael Petlan)
      
      - Fix processing of dereferenced args in bprintk events in libtracevent (Steven Rostedt)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      883f4def
  3. 18 Dec, 2018 35 commits
    • Arnaldo Carvalho de Melo's avatar
      tools uapi asm: Update asm-generic/unistd.h copy · 89a09489
      Arnaldo Carvalho de Melo authored
      To get the change in:
      
        b7d624ab ("asm-generic: unistd.h: fixup broken macro include.")
      
      That doesn't imply in any changes in the tools.
      
      This silences the following perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h'
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Guo Ren <ren_guo@c-sky.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-2e7xwm5i2qcc88jp2lyawdyd@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      89a09489
    • Arnaldo Carvalho de Melo's avatar
      perf symbols: Relax checks on perf-PID.map ownership · bc055c54
      Arnaldo Carvalho de Melo authored
      Those are simple enough, and usually not produced by root, instead by
      whatever user is running java, rust, Node.js JIT code that end up
      generating those /tmp/perf-PID.map for resolution of symbols in the
      anonymous executable maps.
      
      Having to use --force to resolve symbols in 'perf top' is a distraction,
      as recently I experienced when node.js symbols were not being resolved
      by 'perf top'.
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Hítalo Silva <hitalos@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/n/tip-tk2jgo2v4v2yjuj28axbpppo@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc055c54
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Wire up the fadvise 'advice' table generator · 42337cb7
      Arnaldo Carvalho de Melo authored
      That ends up generating this:
      
        $ cat /tmp/build/perf/trace/beauty/generated/fadvise_advice_array.c
        static const char *fadvise_advices[] = {
      	[0] = "NORMAL",
      	[1] = "RANDOM",
      	[2] = "SEQUENTIAL",
      	[3] = "WILLNEED",
      	[4] = "DONTNEED",
      	[5] = "NOREUSE",
        };
      $
      
      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-zwbslubagram8a8zdc003u8h@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42337cb7
    • Arnaldo Carvalho de Melo's avatar
      perf beauty: Add generator for fadvise64's 'advice' arg constants · 069c1c6c
      Arnaldo Carvalho de Melo authored
        $ tools/perf/trace/beauty/fadvise.sh
        static const char *fadvise_advices[] = {
      	[0] = "NORMAL",
      	[1] = "RANDOM",
      	[2] = "SEQUENTIAL",
      	[3] = "WILLNEED",
      	[4] = "DONTNEED",
      	[5] = "NOREUSE",
        };
        $
      
      This has a hack wrt the s390 difference.
      
      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-tb7jguv01u8p570piq13eioh@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      069c1c6c
    • Arnaldo Carvalho de Melo's avatar
      tools headers uapi: Grab a copy of fadvise.h · f9cdd63e
      Arnaldo Carvalho de Melo authored
      Will be used to generate the string table for fadvise64's 'advice'
      argument.
      
      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-muswpnft8q9krktv052yrgsc@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f9cdd63e
    • Arnaldo Carvalho de Melo's avatar
      perf beauty mmap: Print mmap's 'offset' arg in hexadecimal · a6631340
      Arnaldo Carvalho de Melo authored
      Also to make it match 'strace' output, for regression testing.
      
      Both now produce this option, when 'perf trace' uses a .perfconfig
      asking for the strace like output:
      
        mmap(0x7faf66e6a000, 1363968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7faf66e6a000
      
      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-27qhouo1kaac2iyl85nfnsf5@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a6631340
    • Arnaldo Carvalho de Melo's avatar
      perf beauty mmap: Print PROT_READ before PROT_EXEC to match strace output · 1355e09a
      Arnaldo Carvalho de Melo authored
      Helps with comparing 'strace' and 'perf trace' output, for mutual
      regression testing.
      
      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-va0qe95xbhep5hy52aq5qe0v@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1355e09a
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Beautify arch_prctl()'s arguments · fb7068e7
      Arnaldo Carvalho de Melo authored
      This actually so far, AFAIK is available only in x86, so the code was
      put in place with x86 prefixes, in arches where it is not available it
      will just not be called, so no further mechanisms are needed at this
      time.
      
      Later, when other arches wire this up, we'll just look at the uname
      (live sessions) or perf_env data in the perf.data header to auto-wire
      the right beautifier.
      
      With this the output is the same as produced by 'strace' when used with
      the following ~/.perfconfig:
      
        # cat ~/.perfconfig
        [llvm]
      	dump-obj = true
        [trace]
      	  add_events = /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
      	  show_zeros = yes
      	  show_duration = no
      	  no_inherit = yes
      	  show_timestamp = no
      	  show_arg_names = no
      	  args_alignment = -40
      	  show_prefix = yes
        #
      
      And, on fedora 29, since the string tables are generated from the kernel
      sources, we don't know about 0x3001, just like strace:
      
        --- /tmp/strace 2018-12-17 11:22:08.707586721 -0300
        +++ /tmp/trace  2018-12-18 11:11:32.037512729 -0300
        @@ -1,49 +1,49 @@
        -arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc8a92dc80) = -1 EINVAL (Invalid argument)
        +arch_prctl(0x3001 /* ARCH_??? */, 0x7ffe4eb93ae0) = -1 EINVAL (Invalid argument)
        -arch_prctl(ARCH_SET_FS, 0x7faf6700f540) = 0
        +arch_prctl(ARCH_SET_FS, 0x7fb507364540) = 0
      
      And that seems to be related to the CET/Shadow Stack feature, that
      userland in Fedora 29 (glibc 2.28) are querying the kernel about, that
      0x3001 seems to be ARCH_CET_STATUS, I'll check the situation and test
      with a fedora 29 kernel to see if the other codes are used.
      
      A diff that ignores the different pointers for different runs needs to
      be put in place in the upcoming regression tests comparing 'perf trace's
      output to strace's.
      
      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-73a9prs8ktkrt97trtdmdjs8@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fb7068e7
    • Arnaldo Carvalho de Melo's avatar
      perf trace: When showing string prefixes show prefix + ??? for unknown entries · 9614b8d6
      Arnaldo Carvalho de Melo authored
      To match 'strace' output, like in:
      
        arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc8a92dc80) = -1 EINVAL (Invalid argument)
      
      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-kx59j2dk5l1x04ou57mt99ck@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9614b8d6
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Move strarrays to beauty.h for further reuse · 1f2d085e
      Arnaldo Carvalho de Melo authored
      We'll use it in the upcoming arch_prctl() 'code' arg beautifier.
      
      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-6e4tj2fjen8qa73gy4u49vav@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f2d085e
    • Arnaldo Carvalho de Melo's avatar
      perf beauty: Wire up the x86_arch prctl code table generator · 40714e8b
      Arnaldo Carvalho de Melo authored
        $ cat /tmp/build/perf/trace/beauty/generated/x86_arch_prctl_code_array.c
        #define x86_arch_prctl_codes_1_offset 0x1001
        static const char *x86_arch_prctl_codes_1[] = {
      	[0x1001 - 0x1001]= "SET_GS",
      	[0x1002 - 0x1001]= "SET_FS",
      	[0x1003 - 0x1001]= "GET_FS",
      	[0x1004 - 0x1001]= "GET_GS",
      	[0x1011 - 0x1001]= "GET_CPUID",
      	[0x1012 - 0x1001]= "SET_CPUID",
        };
      
        #define x86_arch_prctl_codes_2_offset 0x2001
        static const char *x86_arch_prctl_codes_2[] = {
      	[0x2001 - 0x2001]= "MAP_VDSO_X32",
      	[0x2002 - 0x2001]= "MAP_VDSO_32",
      	[0x2003 - 0x2001]= "MAP_VDSO_64",
        };
        $
      
      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-3r9blij6n8wdlsyd5dujx86r@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      40714e8b
    • Arnaldo Carvalho de Melo's avatar
      perf beauty: Add a string table generator for x86's 'arch_prctl' codes · ff4cb769
      Arnaldo Carvalho de Melo authored
        $ tools/perf/trace/beauty/x86_arch_prctl.sh
        #define x86_arch_prctl_codes_1_offset 0x1001
        static const char *x86_arch_prctl_codes_1[] = {
      	[0x1001 - 0x1001]= "SET_GS",
      	[0x1002 - 0x1001]= "SET_FS",
      	[0x1003 - 0x1001]= "GET_FS",
      	[0x1004 - 0x1001]= "GET_GS",
      	[0x1011 - 0x1001]= "GET_CPUID",
      	[0x1012 - 0x1001]= "SET_CPUID",
        };
      
        #define x86_arch_prctl_codes_2_offset 0x2001
        static const char *x86_arch_prctl_codes_2[] = {
      	[0x2001 - 0x2001]= "MAP_VDSO_X32",
      	[0x2002 - 0x2001]= "MAP_VDSO_32",
      	[0x2003 - 0x2001]= "MAP_VDSO_64",
        };
        $
      
      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-w0fux1psivphhx6rve8kn3vq@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ff4cb769
    • Arnaldo Carvalho de Melo's avatar
      tools include arch: Grab a copy of x86's prctl.h · c22e2683
      Arnaldo Carvalho de Melo authored
      We need it to generate the tables for the 'code' arch_prctl's syscall
      argument.
      
      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-vu890pi18fpd4eyz61cazckj@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c22e2683
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Show NULL when syscall pointer args are 0 · ce05539f
      Arnaldo Carvalho de Melo authored
      Matching strace's output format. The 'format' file for the syscall
      tracepoints have an indication if the arg is a pointer, with some
      exceptions like 'mmap' that has its first arg as an 'unsigned long', so
      use a heuristic using the argument name, i.e. if it contains the 'addr'
      substring, format it with the pointer formatter.
      
      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-ddghemr8qrm6i0sb8awznbze@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce05539f
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Enclose the errno strings with () · 2c83dfae
      Arnaldo Carvalho de Melo authored
      To match strace, now both emit the same line for calls like:
      
       access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
      
      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-krxl6klsqc9qyktoaxyih942@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2c83dfae
    • Arnaldo Carvalho de Melo's avatar
      perf augmented_raw_syscalls: Copy 'access' arg as well · c48ee107
      Arnaldo Carvalho de Melo authored
      This will all come from userspace, but to test the changes to make 'perf
      trace' output similar to strace's, do this one more now manually.
      
      To update the precompiled augmented_raw_syscalls.o binary I just run:
      
        # perf record -e ~acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.c sleep 1
        LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.022 MB perf.data ]
        #
      
      Because to have augmented_raw_syscalls to be always used and a fast
      startup and remove the need to have the llvm toolchain installed, I'm
      using:
      
        # perf config | grep add_events
        trace.add_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        #
      
      So when doing changes to augmented_raw_syscals.c one needs to rebuild
      the .o file.
      
      This will be done automagically later, i.e. have a 'make' behaviour of
      recompiling when the .c gets changed.
      
      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-lw3i2atyq8549fpqwmszn3qp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c48ee107
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Add alignment spaces after the closing parens · 4b8a240e
      Arnaldo Carvalho de Melo authored
      To use strace's style, helping in comparing the output of 'perf trace'
      with the one from 'strace', to help in upcoming regression tests.
      
      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-mw6peotz4n84rga0fk78buff@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b8a240e
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Print O_RDONLY when (flags & O_ACCMODE) == 0 · 601d66d4
      Arnaldo Carvalho de Melo authored
      And there are more flags, to match strace's output.
      
       openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
      
      Also to help with regression tests.
      
      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-ofovpmvdli3bwch30936xn7t@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      601d66d4
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow asking for not suppressing common string prefixes · c65c83ff
      Arnaldo Carvalho de Melo authored
      So far we've been suppressing common stuff such as "MAP_" in the mmap
      flags, showing "SHARED" instead of "MAP_SHARED", allow for those
      prefixes (and a few suffixes) to be shown:
      
        # trace -e *map,open*,*seek sleep 1
        openat("/etc/ld.so.cache", CLOEXEC) = 3
        mmap(0, 109093, READ, PRIVATE, 3, 0) = 0x7ff61c695000
        openat("/lib64/libc.so.6", CLOEXEC) = 3
        lseek(3, 792, SET) = 792
        mmap(0, 8192, READ|WRITE, PRIVATE|ANONYMOUS) = 0x7ff61c693000
        lseek(3, 792, SET) = 792
        lseek(3, 864, SET) = 864
        mmap(0, 1857568, READ, PRIVATE|DENYWRITE, 3, 0) = 0x7ff61c4cd000
        mmap(0x7ff61c4ef000, 1363968, EXEC|READ, PRIVATE|FIXED|DENYWRITE, 3, 139264) = 0x7ff61c4ef000
        mmap(0x7ff61c63c000, 311296, READ, PRIVATE|FIXED|DENYWRITE, 3, 1503232) = 0x7ff61c63c000
        mmap(0x7ff61c689000, 24576, READ|WRITE, PRIVATE|FIXED|DENYWRITE, 3, 1814528) = 0x7ff61c689000
        mmap(0x7ff61c68f000, 14368, READ|WRITE, PRIVATE|FIXED|ANONYMOUS) = 0x7ff61c68f000
        munmap(0x7ff61c695000, 109093) = 0
        openat("/usr/lib/locale/locale-archive", CLOEXEC) = 3
        mmap(0, 217749968, READ, PRIVATE, 3, 0) = 0x7ff60f523000
        #
        # vim ~/.perfconfig
        #
        # perf config
        llvm.dump-obj=true
        trace.add_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        trace.show_zeros=yes
        trace.show_duration=no
        trace.no_inherit=yes
        trace.show_timestamp=no
        trace.show_arg_names=no
        trace.args_alignment=0
        trace.string_quote="
        trace.show_prefix=yes
        #
        #
        # trace -e *map,open*,*seek sleep 1
        openat(AT_FDCWD, "/etc/ld.so.cache", O_CLOEXEC) = 3
        mmap(0, 109093, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f7ebbe59000
        openat(AT_FDCWD, "/lib64/libc.so.6", O_CLOEXEC) = 3
        lseek(3, 792, SEEK_SET) = 792
        mmap(0, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS) = 0x7f7ebbe57000
        lseek(3, 792, SEEK_SET) = 792
        lseek(3, 864, SEEK_SET) = 864
        mmap(0, 1857568, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f7ebbc91000
        mmap(0x7f7ebbcb3000, 1363968, PROT_EXEC|PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 139264) = 0x7f7ebbcb3000
        mmap(0x7f7ebbe00000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 1503232) = 0x7f7ebbe00000
        mmap(0x7f7ebbe4d000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 1814528) = 0x7f7ebbe4d000
        mmap(0x7f7ebbe53000, 14368, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS) = 0x7f7ebbe53000
        munmap(0x7f7ebbe59000, 109093) = 0
        openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_CLOEXEC) = 3
        mmap(0, 217749968, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f7eaece7000
        #
      
      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-mtn1i4rjowjl72trtnbmvjd4@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c65c83ff
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Add a prefix member to the strarray class · 2e3d7fac
      Arnaldo Carvalho de Melo authored
      So that the user, in an upcoming patch, can select printing it to get
      the full string as used in the source code, not one with a common prefix
      chopped off so as to make the output more compact.
      
      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-zypczc88gzbmeqx7b372s138@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2e3d7fac
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Enclose strings with double quotes · 721f5326
      Arnaldo Carvalho de Melo authored
      To match 'strace' output, helping with upcoming regression tests
      comparing both outputs.
      
      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-jab52t1dcuh6vlztqle9g7u9@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      721f5326
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Make the alignment of the syscall args be configurable · 9ed45d59
      Arnaldo Carvalho de Melo authored
      Since the start 'perf trace' aligns the parens enclosing the list of
      syscall args to align the syscall results, allow this to be
      configurable, keeping the default of 70. Using:
      
        # perf config
        llvm.dump-obj=true
        trace.add_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        trace.show_zeros=yes
        trace.show_duration=no
        trace.no_inherit=yes
        trace.show_timestamp=no
        trace.show_arg_names=no
        trace.args_alignment=0
        # trace -e open*,close,*sleep sleep 1
        openat(CWD, /etc/ld.so.cache, CLOEXEC) = 3
        close(3) = 0
        openat(CWD, /lib64/libc.so.6, CLOEXEC) = 3
        close(3) = 0
        openat(CWD, /usr/lib/locale/locale-archive, CLOEXEC) = 3
        close(3) = 0
        nanosleep(0x7ffc00de66f0, 0) = 0
        close(1) = 0
        close(2) = 0
        #
      
      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-r8cbhoz1lr5npq9tutpvoigr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9ed45d59
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow suppressing the syscall argument names · 9d6dc178
      Arnaldo Carvalho de Melo authored
      To show just the values:
      
      Default:
      
        # trace -e open*,close,*sleep sleep 1
        openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC           ) = 3
        close(fd: 3                                                           ) = 0
        openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC           ) = 3
        close(fd: 3                                                           ) = 0
        openat(dfd: CWD, filename: /usr/lib/locale/locale-archive, flags: CLOEXEC) = 3
        close(fd: 3                                                           ) = 0
        nanosleep(rqtp: 0x7ffc0c4ea0d0, rmtp: 0                               ) = 0
        close(fd: 1                                                           ) = 0
        close(fd: 2                                                           ) = 0
        #
      
      Remove it:
      
        # perf config trace.show_arg_names=no
        # trace -e open*,close,*sleep sleep 1
        openat(CWD, /etc/ld.so.cache, CLOEXEC                                 ) = 3
        close(3                                                               ) = 0
        openat(CWD, /lib64/libc.so.6, CLOEXEC                                 ) = 3
        close(3                                                               ) = 0
        openat(CWD, /usr/lib/locale/locale-archive, CLOEXEC                   ) = 3
        close(3                                                               ) = 0
        nanosleep(0x7ffced3a8c40, 0                                           ) = 0
        close(1                                                               ) = 0
        close(2                                                               ) = 0
        #
      
      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-ta9tbdwgodpw719sr2bjm8eb@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d6dc178
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow configuring if the syscall start timestamp should be printed · b036146f
      Arnaldo Carvalho de Melo authored
        # trace -e open*,close,*sleep sleep 1
           0.000 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC           ) = 3
           0.016 close(fd: 3                                                           ) = 0
           0.024 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC           ) = 3
           0.074 close(fd: 3                                                           ) = 0
           0.235 openat(dfd: CWD, filename: /usr/lib/locale/locale-archive, flags: CLOEXEC) = 3
           0.251 close(fd: 3                                                           ) = 0
           0.285 nanosleep(rqtp: 0x7ffd68e6d620, rmtp: 0                               ) = 0
        1000.386 close(fd: 1                                                           ) = 0
        1000.395 close(fd: 2                                                           ) = 0
        #
      
        # perf config trace.show_timestamp=no
        # trace -e open*,close,*sleep sleep 1
        openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC           ) = 3
        close(fd: 3                                                           ) = 0
        openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC           ) = 3
        close(fd: 3                                                           ) = 0
        openat(dfd: CWD, filename: , flags: CLOEXEC                           ) = 3
        close(fd: 3                                                           ) = 0
        nanosleep(rqtp: 0x7fffa79c38e0, rmtp: 0                               ) = 0
        close(fd: 1                                                           ) = 0
        close(fd: 2                                                           ) = 0
        #
      
      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-mjjnicy48367jah6ls4k0nk8@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b036146f
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow configuring default for perf_event_attr.inherit · d32de87e
      Arnaldo Carvalho de Melo authored
      I.f. if children should inherit the parent perf_event configuration,
      i.e. if we should trace children as well or just the parent.
      
      The default is to follow children, to disable this and have a behaviour
      similar to strace, set this config option or use the --no_inherit 'perf
      trace' option.
      
      E.g.:
      
      Default:
      
        # perf config trace.no_inherit
        # trace -e clone,*sleep time sleep 1
           0.000 time/21107 clone(clone_flags: CHILD_CLEARTID|CHILD_SETTID|0x11, newsp: 0, child_tidptr: 0x7f7b8f9ae810) = 21108 (time)
               ? time/21108  ... [continued]: clone()
           0.691 sleep/21108 nanosleep(rqtp: 0x7ffed01d0540, rmtp: 0                               ) = 0
        0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 1988maxresident)k
        0inputs+0outputs (0major+76minor)pagefaults 0swaps
        #
      
      Disable it:
      
        # trace -e clone,*sleep time sleep 1
           0.000 clone(clone_flags: CHILD_CLEARTID|CHILD_SETTID|0x11, newsp: 0, child_tidptr: 0x7ff41e100810) = 21414 (time)
        0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 1964maxresident)k
        0inputs+0outputs (0major+76minor)pagefaults 0swaps
        #
      
      Notice that since there is just one thread, the "comm/TID" column is
      suppressed.
      
      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-thd8s16pagyza71ufi5vjlan@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d32de87e
    • Arnaldo Carvalho de Melo's avatar
      perf config: Show the configuration when no arguments are provided · 41e0d040
      Arnaldo Carvalho de Melo authored
      More convenient thah having to recall what letter is about
      showing/listing/dumping the configuration, i.e. no arguments means
      -l/--list:
      
        # perf config
        llvm.dump-obj=true
        trace.default_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        trace.show_zeros=yes
        trace.show_duration=no
        # perf config -l
        llvm.dump-obj=true
        trace.default_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        trace.show_zeros=yes
        trace.show_duration=no
        # perf config -h
      
         Usage: perf config [<file-option>] [options] [section.name[=value] ...]
      
            -l, --list            show current config variables
                --system          use system config file
                --user            use user config file
      
        #
      
      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: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-z2n63avz6tliqb5gmu4l1dti@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      41e0d040
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow configuring if the syscall duration should be printed · 42e4a52d
      Arnaldo Carvalho de Melo authored
        # perf config trace.show_duration=no
        # perf config -l | grep trace
        trace.default_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        trace.show_zeros=true
        trace.show_duration=no
        # trace -e *sleep sleep 1
           0.000 sleep/8729 nanosleep(rqtp: 0x7ffcb0b4c940, rmtp: 0) = 0
        # perf config trace.show_duration=yes
        # trace -e *sleep sleep 1
           0.000 (1000.212 ms): sleep/8735 nanosleep(rqtp: 0x7ffca15fa770, rmtp: 0) = 0
        #
      
      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-2c7h1m8fhzb9puxtj9nlevi8@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42e4a52d
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow configuring if zeroed syscall args should be printed · e7c634fc
      Arnaldo Carvalho de Melo authored
      The default so far, since we show argument names followed by its values,
      was to make the output more compact by suppressing most zeroed args.
      
      Make this configurable so that users can choose what best suit their
      needs.
      
      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-q0gxws02ygodh94o0hzim5xd@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e7c634fc
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow specifying a set of events to add in perfconfig · ac96287c
      Arnaldo Carvalho de Melo authored
      To add augmented_raw_syscalls to the events speficied by the user, or be
      the only one if no events were specified by the user, one can add this
      to perfconfig:
      
        # cat ~/.perfconfig
        [trace]
      	  add_events = /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        #
      
      I.e. pre-compile the augmented_raw_syscalls.c BPF program and make it
      always load, this way:
      
        # perf trace -e open* cat /etc/passwd > /dev/null
           0.000 ( 0.013 ms): cat/31557 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC) = 3
           0.035 ( 0.007 ms): cat/31557 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC) = 3
           0.353 ( 0.009 ms): cat/31557 openat(dfd: CWD, filename: /usr/lib/locale/locale-archive, flags: CLOEXEC) = 3
           0.424 ( 0.006 ms): cat/31557 openat(dfd: CWD, filename: /etc/passwd) = 3
        #
      
      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-0lgj7vh64hg3ce44gsmvj7ud@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ac96287c
    • Arnaldo Carvalho de Melo's avatar
      perf augmented_raw_syscalls: Do not include stdio.h · 4623ce40
      Arnaldo Carvalho de Melo authored
      We're not using that puts() thing, and thus we don't need to define the
      __bpf_stdout__ map, reducing the setup time.
      
      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-3452xgatncpil7v22minkwbo@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4623ce40
    • Leo Yan's avatar
      perf cs-etm: Generate branch sample for exception packet · 7100b12c
      Leo Yan authored
      The exception packet appears as one element with 'elem_type' ==
      OCSD_GEN_TRC_ELEM_EXCEPTION or OCSD_GEN_TRC_ELEM_EXCEPTION_RET, which is
      present for exception entry and exit respectively.  The decoder sets the
      packet fields 'packet->exc' and 'packet->exc_ret' to indicate the
      exception packets; but exception packets don't have a dedicated sample
      type and shares the same sample type CS_ETM_RANGE with normal
      instruction packets.
      
      As a result, the exception packets are taken as normal instruction
      packets and this introduces confusion in mixing different packet types.
      Furthermore, these instruction range packets will be processed for
      branch samples only when 'packet->last_instr_taken_branch' is true,
      otherwise they will be omitted, this can introduce a mess for exception
      and exception returning due to not having the complete address range
      info for context switching.
      
      To process exception packets properly, this patch introduces two new
      sample types: CS_ETM_EXCEPTION and CS_ETM_EXCEPTION_RET; these two types
      of packets will be handled by cs_etm__exception().  The function
      cs_etm__exception() forces setting the previous CS_ETM_RANGE packet flag
      'prev_packet->last_instr_taken_branch' to true, this matches well with
      the program flow when the exception is trapped from user space to kernel
      space, no matter if the most recent flow has branch taken or not; this
      is also safe for returning to user space after exception handling.
      
      After exception packets have their own sample type, the packet fields
      'packet->exc' and 'packet->exc_ret' aren't needed anymore, so remove
      them.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1544513908-16805-9-git-send-email-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7100b12c
    • Leo Yan's avatar
      perf cs-etm: Treat EO_TRACE element as trace discontinuity · 02e7e250
      Leo Yan authored
      If the decoder outputs an EO_TRACE element, it means the end of the
      trace buffer; this is a discontinuity and in this case the end of trace
      data needs to be saved.
      
      This patch generates a CS_ETM_DISCONTINUITY packet for the EO_TRACE
      element hereby flushing the end of trace data in cs-etm.c.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1544513908-16805-8-git-send-email-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      02e7e250
    • Leo Yan's avatar
      perf cs-etm: Treat NO_SYNC element as trace discontinuity · 37bb3716
      Leo Yan authored
      The CoreSight tracer driver might insert barrier packets between
      different buffers, thus the decoder can spot the boundaries based on the
      barrier packet; it is possible for the decoder to hit a barrier packet
      and emit a NO_SYNC element, then the decoder will find a periodic
      synchronisation point inside that next trace block that starts the trace
      again but does not have the TRACE_ON element as indicator - usually
      because this trace block has wrapped the buffer so we have lost the
      original point when the trace was enabled.
      
      In the first case it causes the insertion of a OCSD_GEN_TRC_ELEM_NO_SYNC
      in the middle of the tracing stream, but as we were not handling the
      NO_SYNC element properly this ends up making users miss the
      discontinuity indications.
      
      Though OCSD_GEN_TRC_ELEM_NO_SYNC is different from CS_ETM_TRACE_ON when
      output from the decoder, both indicate that the trace data is
      discontinuous; this patch treats OCSD_GEN_TRC_ELEM_NO_SYNC as a trace
      discontinuity and generates a CS_ETM_DISCONTINUITY packet for it, so
      cs-etm can handle the discontinuity for this case, finally it saves the
      last trace data for the previous trace block and restart samples for the
      new block.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1544513908-16805-7-git-send-email-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      37bb3716
    • Leo Yan's avatar
      perf cs-etm: Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY · 49ccf87b
      Leo Yan authored
      TRACE_ON element is used at the beginning of trace, it also can be
      appeared in the middle of trace data to indicate discontinuity; for
      example, it's possible to see multiple TRACE_ON elements in the trace
      stream if the trace is being limited by address range filtering.
      
      Furthermore, except TRACE_ON element is for discontinuity, NO_SYNC and
      EO_TRACE also can be used to indicate discontinuity, though they are
      used for different scenarios for which the trace is interrupted.
      
      This patch renames sample type CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY,
      firstly the new name describes more closely the purpose of the packet;
      secondly this is a preparation for other output elements which also
      cause the trace discontinuity thus they can share the same one packet
      type.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1544513908-16805-6-git-send-email-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      49ccf87b
    • Leo Yan's avatar
      perf cs-etm: Refactor enumeration cs_etm_sample_type · cfc1d427
      Leo Yan authored
      The values in enumeration cs_etm_sample_type are defined with setting
      bit N for each packet type, this is not suggested in the usual case.
      
      This patch refactor cs_etm_sample_type by converting from bit shifting
      values to continuous numbers.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1544513908-16805-5-git-send-email-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cfc1d427