1. 15 2月, 2019 8 次提交
  2. 06 2月, 2019 5 次提交
    • L
      perf cs-etm: Set sample flags for exception return packet · 173e65f6
      Leo Yan 提交于
      When return from exception, we need to distinguish if it's system call
      return or for other type exceptions for setting sample flags.  Due to
      the exception return packet doesn't contain exception number, so we
      cannot decide sample flags based on exception number.
      
      On the other hand, the exception return packet is followed by an
      instruction range packet; this range packet deliveries the start address
      after exception handling, we can check if it is a SVC instruction just
      before the start address.  If there has one SVC instruction is found
      ahead the return address, this means it's an exception return for system
      call; otherwise it is an normal return for other exceptions.
      
      This patch is to set sample flags for exception return packet, firstly
      it simply set sample flags as PERF_IP_FLAG_INTERRUPT for all exception
      returns since at this point it doesn't know what's exactly the exception
      type.  We will defer to decide if it's an exception return for system
      call when the next instruction range packet comes, it checks if there
      has one SVC instruction prior to the start address and if so we will
      change sample flags to PERF_IP_FLAG_SYSCALLRET for system call return.
      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: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190129122842.32041-9-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      173e65f6
    • L
      perf cs-etm: Set sample flags for exception packet · 96dce7f4
      Leo Yan 提交于
      The exception taken and returning are typical flow for instruction jump
      but it needs to be handled with exception packets. This patch is to set
      sample flags for exception packet.
      
      Since the exception packet contains the exception number, according to
      the exception number this patch makes decision for belonging to which
      exception types.
      
      The decoder have defined different exception number for ETMv3 and ETMv4
      separately, hence this patch needs firstly decide the ETM version by
      using the metadata magic number, and this patch adds helper function
      cs_etm__get_magic() for easily getting magic number.
      
      Based on different ETM version, the exception packet contains the
      exception number, according to the exception number this patch makes
      decision for the exception belonging to which exception types.
      
      In this patch, it introduces helper function cs_etm__is_svc_instr(); for
      ETMv4 CS_ETMV4_EXC_CALL covers SVC, SMC and HVC cases in the single
      exception number, thus need to use cs_etm__is_svc_instr() to decide an
      exception taken for system call.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: NRobert Walker <robert.walker@arm.com>
      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: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190129122842.32041-8-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      96dce7f4
    • L
      perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata · 95c6fe97
      Leo Yan 提交于
      If packet processing wants to know the packet is bound with which ETM
      version, it needs to access metadata to decide that based on metadata
      magic number; but we cannot simply to use CPU logic ID number as index
      to access metadata sequential array, especially when system have
      hotplugged off CPUs, the metadata array are only allocated for online
      CPUs but not offline CPUs, so the CPU logic number doesn't match with
      its index in the array.
      
      This patch is to change tuple from traceID-CPU# to traceID-metadata,
      thus it can use the tuple to retrieve metadata pointer according to
      traceID.
      
      For safe accessing metadata fields, this patch provides helper function
      cs_etm__get_cpu() which is used to return CPU number according to
      traceID; cs_etm_decoder__buffer_packet() is the first consumer for this
      helper function.
      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: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190129122842.32041-6-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      95c6fe97
    • L
      perf cs-etm: Set sample flags for trace discontinuity · 465eaaa8
      Leo Yan 提交于
      In the middle of trace stream, it might be interrupted thus the trace
      data is not continuous, the trace stream firstly is ended for previous
      trace block and restarted for next block.
      
      To display related information for showing trace is restarted, this
      patch set sample flags for trace discontinuity:
      
      - If one discontinuity packet is coming, append flag
        PERF_IP_FLAG_TRACE_END to the previous packet to indicate the trace
        has been ended;
      - If one instruction packet is following discontinuity packet, this
        instruction packet is the first one packet to restarting trace.  So
        set flag PERF_IP_FLAG_TRACE_START to discontinuity packet, this flag
        will be used to generate sample when connect with the sequential
        instruction 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: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190129122842.32041-4-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      465eaaa8
    • L
      perf cs-etm: Set sample flags for instruction range packet · 06220bf4
      Leo Yan 提交于
      The perf sample data contains flags to indicate the hardware trace data
      is belonging to which type branch instruction, thus this can be used to
      print out the human readable string.  Arm CoreSight ETM sample data is
      missed to set flags and it is always set to zeros, this results in perf
      tool skips to print string for instruction types.
      
      This patch is to set branch instruction flags for instruction range
      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: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: coresight ml <coresight@lists.linaro.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190129122842.32041-3-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      06220bf4
  3. 18 12月, 2018 7 次提交
    • 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: 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: 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
    • M
      perf cs-etm: Add support for PTMv1.1 decoding · 15a5cd19
      Mathieu Poirier 提交于
      This patch is re-using the mechanic set forth by ETMv3 to add support
      for PTM decoding.  Configuration for both encoding protocol is similar
      but the generated stream itself is very different, hence requiring
      special handling.
      Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1543955944-10042-4-git-send-email-mathieu.poirier@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      15a5cd19
    • M
      perf cs-etm: Add configuration for ETMv3 trace protocol · 78688342
      Mathieu Poirier 提交于
      This patch deals with the proper initialisation of configuration
      parameters for the ETMv3 trace protocol in order to properly handle
      packets generated by tracers following this specification.
      Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1543955944-10042-2-git-send-email-mathieu.poirier@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      78688342
    • R
      perf cs-etm: Support for ARM A32/T32 instruction sets in CoreSight trace · a7ee4d62
      Robert Walker 提交于
      This patch adds support for generating instruction samples from trace of
      AArch32 programs using the A32 and T32 instruction sets.
      
      T32 has variable 2 or 4 byte instruction size, so the conversion between
      addresses and instruction counts requires extra information from the
      trace decoder, requiring version 0.10.0 of OpenCSD.  A check for the
      OpenCSD library version has been added to the feature check for OpenCSD.
      Signed-off-by: NRobert Walker <robert.walker@arm.com>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Tested-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1543839526-30348-1-git-send-email-robert.walker@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a7ee4d62
  4. 31 10月, 2018 1 次提交
    • L
      perf cs-etm: Correct CPU mode for samples · d6c9c05f
      Leo Yan 提交于
      Since commit edeb0c90 ("perf tools: Stop fallbacking to kallsyms for
      vdso symbols lookup"), the kernel address cannot be properly parsed to
      kernel symbol with command 'perf script -k vmlinux'.  The reason is
      CoreSight samples is always to set CPU mode as PERF_RECORD_MISC_USER,
      thus it fails to find corresponding map/dso in below flows:
      
        process_sample_event()
          `-> machine__resolve()
      	  `-> thread__find_map(thread, sample->cpumode, sample->ip, al);
      
      In this flow it needs to pass argument 'sample->cpumode' to tell what's
      the CPU mode, before it always passed PERF_RECORD_MISC_USER but without
      any failure until the commit edeb0c90 ("perf tools: Stop fallbacking
      to kallsyms for vdso symbols lookup") has been merged.  The reason is
      even with the wrong CPU mode the function thread__find_map() firstly
      fails to find map but it will rollback to find kernel map for vdso
      symbols lookup.  In the latest code it has removed the fallback code,
      thus if CPU mode is PERF_RECORD_MISC_USER then it cannot find map
      anymore with kernel address.
      
      This patch is to correct samples CPU mode setting, it creates a new
      helper function cs_etm__cpu_mode() to tell what's the CPU mode based on
      the address with the info from machine structure; this patch has a bit
      extension to check not only kernel and user mode, but also check for
      host/guest and hypervisor mode.  Finally this patch uses the function in
      instruction and branch samples and also apply in cs_etm__mem_access()
      for a minor polishing.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: stable@kernel.org # v4.19
      Link: http://lkml.kernel.org/r/1540883908-17018-1-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d6c9c05f
  5. 25 10月, 2018 1 次提交
  6. 31 7月, 2018 4 次提交
  7. 25 7月, 2018 1 次提交
  8. 11 5月, 2018 2 次提交
  9. 27 4月, 2018 2 次提交
  10. 19 4月, 2018 1 次提交
  11. 17 2月, 2018 3 次提交
  12. 25 1月, 2018 5 次提交