1. 19 12月, 2018 21 次提交
  2. 18 12月, 2018 19 次提交
    • A
      perf trace: Allow suppressing the syscall argument names · 9d6dc178
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      9d6dc178
    • A
      perf trace: Allow configuring if the syscall start timestamp should be printed · b036146f
      Arnaldo Carvalho de Melo 提交于
        # 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      b036146f
    • A
      perf trace: Allow configuring default for perf_event_attr.inherit · d32de87e
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      d32de87e
    • A
      perf config: Show the configuration when no arguments are provided · 41e0d040
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      41e0d040
    • A
      perf trace: Allow configuring if the syscall duration should be printed · 42e4a52d
      Arnaldo Carvalho de Melo 提交于
        # 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      42e4a52d
    • A
      perf trace: Allow configuring if zeroed syscall args should be printed · e7c634fc
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      e7c634fc
    • A
      perf trace: Allow specifying a set of events to add in perfconfig · ac96287c
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      ac96287c
    • A
      perf augmented_raw_syscalls: Do not include stdio.h · 4623ce40
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      4623ce40
    • L
      perf cs-etm: Generate branch sample for exception packet · 7100b12c
      Leo Yan 提交于
      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: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      7100b12c
    • L
      perf cs-etm: Treat EO_TRACE element as trace discontinuity · 02e7e250
      Leo Yan 提交于
      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: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      02e7e250
    • L
      perf cs-etm: Treat NO_SYNC element as trace discontinuity · 37bb3716
      Leo Yan 提交于
      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: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      37bb3716
    • L
      perf cs-etm: Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY · 49ccf87b
      Leo Yan 提交于
      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: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      49ccf87b
    • L
      perf cs-etm: Refactor enumeration cs_etm_sample_type · cfc1d427
      Leo Yan 提交于
      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: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      cfc1d427
    • L
      perf cs-etm: Remove unused 'trace_on' in cs_etm_decoder · cee7a6a2
      Leo Yan 提交于
      cs_etm_decoder::trace_on is being assigned when TRACE_ON or NO_SYNC
      element is coming, but it is never used hence it is redundant and can
      be removed.
      
      So let's remove 'trace_on' field from cs_etm_decoder struct.
      Suggested-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      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-4-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cee7a6a2
    • L
      perf cs-etm: Avoid stale branch samples when flush packet · 24fff5eb
      Leo Yan 提交于
      At the end of trace buffer handling, function cs_etm__flush() is invoked
      to flush any remaining branch stack entries.  As a side effect, it also
      generates branch sample, because the 'etmq->packet' doesn't contains any
      new coming packet but point to one stale packet after packets swapping,
      so it wrongly makes synthesize branch samples with stale packet info.
      
      We could review below detailed flow which causes issue:
      
        Packet1: start_addr=0xffff000008b1fbf0 end_addr=0xffff000008b1fbfc
        Packet2: start_addr=0xffff000008b1fb5c end_addr=0xffff000008b1fb6c
      
        step 1: cs_etm__sample():
      	sample: ip=(0xffff000008b1fbfc-4) addr=0xffff000008b1fb5c
      
        step 2: flush packet in cs_etm__run_decoder():
      	cs_etm__run_decoder()
      	  `-> err = cs_etm__flush(etmq, false);
      	sample: ip=(0xffff000008b1fb6c-4) addr=0xffff000008b1fbf0
      
      Packet1 and packet2 are two continuous packets, when packet2 is the new
      coming packet, cs_etm__sample() generates branch sample for these two
      packets and use [packet1::end_addr - 4 => packet2::start_addr] as branch
      jump flow, thus we can see the first generated branch sample in step 1.
      At the end of cs_etm__sample() it swaps packets so 'etm->prev_packet'=
      packet2 and 'etm->packet'=packet1, so far it's okay for branch sample.
      
      If packet2 is the last one packet in trace buffer, even there have no
      any new coming packet, cs_etm__run_decoder() invokes cs_etm__flush() to
      flush branch stack entries as expected, but it also generates branch
      samples by taking 'etm->packet' as a new coming packet, thus the branch
      jump flow is as [packet2::end_addr - 4 =>  packet1::start_addr]; this
      is the second sample which is generated in step 2.  So actually the
      second sample is a stale sample and we should not generate it.
      
      This patch introduces a new function cs_etm__end_block(), at the end of
      trace block this function is invoked to only flush branch stack entries
      and thus can avoid to generate branch sample for stale packet.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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-3-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      24fff5eb
    • L
      perf cs-etm: Correct packets swapping in cs_etm__flush() · 43fd5666
      Leo Yan 提交于
      The structure cs_etm_queue uses 'prev_packet' to point to previous
      packet, this can be used to combine with new coming packet to generate
      samples.
      
      In function cs_etm__flush() it swaps packets only when the flag
      'etm->synth_opts.last_branch' is true, this means that it will not swap
      packets if without option '--itrace=il' to generate last branch entries;
      thus for this case the 'prev_packet' doesn't point to the correct
      previous packet and the stale packet still will be used to generate
      sequential sample.  Thus if dump trace with 'perf script' command we can
      see the incorrect flow with the stale packet's address info.
      
      This patch corrects packets swapping in cs_etm__flush(); except using
      the flag 'etm->synth_opts.last_branch' it also checks the another flag
      'etm->sample_branches', if any flag is true then it swaps packets so can
      save correct content to 'prev_packet'.  Finally this can fix the wrong
      program flow dumping issue.
      
      The patch has a minor refactoring to use 'etm->synth_opts.last_branch'
      instead of 'etmq->etm->synth_opts.last_branch' for condition checking,
      this is consistent with that is done in cs_etm__sample().
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu 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-2-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43fd5666
    • A
      perf trace: Switch to using a struct for the aumented_raw_syscalls syscalls map values · bbab50dd
      Arnaldo Carvalho de Melo 提交于
      We'll start adding more perf-syscall stuff, so lets do this prep step so
      that the next ones are just about adding more fields.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-vac4sn1ns1vj4y07lzj7y4b8@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bbab50dd
    • A
      perf augmented_syscalls: Switch to using a struct for the syscalls map values · 27f2992e
      Arnaldo Carvalho de Melo 提交于
      We'll start adding more perf-syscall stuff, so lets do this prep step so
      that the next ones are just about adding more fields.
      
      Run it with the .c file once to cache the .o file:
      
        # trace --filter-pids 2834,2199 -e openat,augmented_raw_syscalls.c
        LLVM: dumping augmented_raw_syscalls.o
             0.000 ( 0.021 ms): tmux: server/4952 openat(dfd: CWD, filename: /proc/5691/cmdline                         ) = 11
           349.807 ( 0.040 ms): DNS Res~er #39/11082 openat(dfd: CWD, filename: /etc/hosts, flags: CLOEXEC                 ) = 44
          4988.759 ( 0.052 ms): gsd-color/2431 openat(dfd: CWD, filename: /etc/localtime                             ) = 18
          4988.976 ( 0.029 ms): gsd-color/2431 openat(dfd: CWD, filename: /etc/localtime                             ) = 18
        ^C[root@quaco bpf]#
      
      From now on, we can use just the newly built .o file, skipping the
      compilation step for a faster startup:
      
        # trace --filter-pids 2834,2199 -e openat,augmented_raw_syscalls.o
             0.000 ( 0.046 ms): DNS Res~er #39/11088 openat(dfd: CWD, filename: /etc/hosts, flags: CLOEXEC                 ) = 44
          1946.408 ( 0.190 ms): systemd/1 openat(dfd: CWD, filename: /proc/1071/cgroup, flags: CLOEXEC          ) = 20
          1946.792 ( 0.215 ms): systemd/1 openat(dfd: CWD, filename: /proc/954/cgroup, flags: CLOEXEC           ) = 20
        ^C#
      
      Now on to do the same in the builtin-trace.c side of things.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-k8mwu04l8es29rje5loq9vg7@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      27f2992e
    • A
      perf bpf: Move perf_event_output() from stdio.h to bpf.h · 61d00713
      Arnaldo Carvalho de Melo 提交于
      So that we don't always carry that __bpf_output__ map, leaving that to
      the scripts wanting to use that facility.
      
      'perf trace' will be changed to look if that map is present and only
      setup the bpf-output events if so.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-azwys8irxqx9053vpajr0k5h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      61d00713