Commit Graph

7 Commits

Author SHA1 Message Date
Michael Petlan e641c4eb58 perf scripts python cs-etm: Restore first sample log in verbose mode
JIRA: https://issues.redhat.com/browse/RHEL-29796

upstream
========
commit ae8e4f4048b839c1cb333d9e3d20e634b430139e
Author: James Clark <james.clark@linaro.org>
Date: Tue Jul 23 14:28:58 2024 +0100

description
===========
The linked commit moved the early return on the first sample to before
the verbose log, so move the log earlier too. Now the first sample is
also logged and not skipped.

Fixes: 2d98dbb4c9c5b09c ("perf scripts python arm-cs-trace-disasm.py: Do not ignore disam first sample")
    Reviewed-by: Leo Yan <leo.yan@arm.com>
    Signed-off-by: James Clark <james.clark@linaro.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Benjamin Gray <bgray@linux.ibm.com>
    Cc: coresight@lists.linaro.org
    Cc: gankulkarni@os.amperecomputing.com
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ruidong Tian <tianruidong@linux.alibaba.com>
    Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
    Link: https://lore.kernel.org/r/20240723132858.12747-1-james.clark@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2024-11-18 19:23:33 +01:00
Michael Petlan c5707d9356 perf scripts python arm-cs-trace-disasm.py: Do not ignore disam first sample
JIRA: https://issues.redhat.com/browse/RHEL-25824

upstream
========
commit 2d98dbb4c9c5b09c8d2411581ab17921f872dbd3
Author: Ruidong Tian <tianruidong@linux.alibaba.com>
Date: Thu Dec 14 20:33:04 2023 +0800

description
===========
arm-cs-trace-disasm ignore disam the first branch sample, For example as
follow, the instructions beteween 0x0000ffffae878750 and
0x0000ffffae878754 is lose:

  ARM CoreSight Trace Data Assembler Dump
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000ffffae878750 phys_addr: 0x0000000000000000 ip: 0x0000000000000000 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000000000000000 phys_addr: 0x0000000000000000 ip: 0x0000ffffae878754 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }

Initialize cpu_data earlier to fix it:

  ARM CoreSight Trace Data Assembler Dump
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000000000000000 phys_addr: 0x0000000000000000 ip: 0x0000ffffae878754 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }
        0000000000028740 <ioctl>: (base address is 0x0000ffffae850000)
           28750: b13ffc1f      cmn     x0, #4095
           28754: 54000042      b.hs    0x2875c <ioctl+0x1c>
            test 4003489/4003489 [0000]     26765.151766034  __GI___ioctl+0x14                        /usr/lib64/libc-2.32.so
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000ffffa67535ac phys_addr: 0x0000000000000000 ip: 0x0000000000000000 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }

    Reviewed-by: James Clark <james.clark@arm.com>
    Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Al Grant <al.grant@arm.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
    Cc: Tor Jeremiassen <tor@ti.com>
    Link: https://lore.kernel.org/r/20231214123304.34087-4-tianruidong@linux.alibaba.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2024-04-03 19:37:21 +02:00
Michael Petlan d8db1958c5 perf scripts python arm-cs-trace-disasm.py: Set start vm addr of exectable file to 0
JIRA: https://issues.redhat.com/browse/RHEL-25824

upstream
========
commit c344675ad267040b1794b0b5d85147a5023c548d
Author: Ruidong Tian <tianruidong@linux.alibaba.com>
Date: Thu Dec 14 20:33:03 2023 +0800

description
===========
For exectable ELF file, which e_type is ET_EXEC, dso start address is a
absolute address other than offset. Just set vm_start to zero when dso
start is 0x400000, which means it is a exectable file.

    Reviewed-by: James Clark <james.clark@arm.com>
    Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Al Grant <al.grant@arm.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
    Cc: Tor Jeremiassen <tor@ti.com>
    Link: https://lore.kernel.org/r/20231214123304.34087-3-tianruidong@linux.alibaba.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2024-04-03 19:37:21 +02:00
Michael Petlan 50de9e1d30 perf tools: Address python 3.6 DeprecationWarning for string scapes
JIRA: https://issues.redhat.com/browse/RHEL-25824

upstream
========
commit 280b4e4a9e8009affd8f20ec2d467cb4deb05c1c
Author: Benjamin Gray <bgray@linux.ibm.com>
Date: Tue Sep 12 16:07:59 2023 +1000

description
===========
Python 3.6 introduced a DeprecationWarning for invalid escape sequences.
This is upgraded to a SyntaxWarning in Python 3.12, and will eventually
be a syntax error.

Fix these now to get ahead of it before it's an error.

    Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andrii Nakryiko <andrii@kernel.org>
    Cc: Hartley Sweeten <hsweeten@visionengravers.com>
    Cc: Ian Abbott <abbotti@mev.co.uk>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jan Kiszka <jan.kiszka@siemens.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Kieran Bingham <kbingham@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Mykola Lysenko <mykolal@fb.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Todd E Brandt <todd.e.brandt@linux.intel.com>
    Cc: Tom Rix <trix@redhat.com>
    Cc: linux-doc@vger.kernel.org
    Cc: linux-ia64@vger.kernel.org
    Cc: linux-kselftest@vger.kernel.org
    Cc: linux-pm@vger.kernel.org
    Cc: llvm@lists.linux.dev
    Link: https://lore.kernel.org/r/20230912060801.95533-6-bgray@linux.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2024-04-03 19:37:12 +02:00
Michael Petlan 89d6c3ec5e perf python scripting: Get rid of unused import in arm-cs-trace-disasm
Bugzilla: https://bugzilla.redhat.com/2233483

upstream
========
commit 75782e825377bd2745c0231a0f3483888514acb6
Author: Sourabh Jain <sourabhjain@linux.ibm.com>
Date: Tue Jun 13 22:11:29 2023 +0530

description
===========
The arm-cs-trace-disasm.py script doesn't use the sys library, so remove
the import.

Report by pylint:

  W0611: Unused import sys (unused-import)

    Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
    Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
    Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: John Garry <john.g.garry@oracle.com>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Ravi Bangoria <ravi.bangoria@amd.com>
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: https://lore.kernel.org/linux-perf-users/20230613164145.50488-2-atrajeev@linux.vnet.ibm.com
    Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
    Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2023-09-18 13:03:00 +02:00
Michael Petlan d4e5b9bb0e perf scripts python: Let script to be python2 compliant
Bugzilla: https://bugzilla.redhat.com/2123231

upstream
========
commit b226521923aee7051f4b24df9be5bf07d53f0a2b
Author: Leo Yan <leo.yan@linaro.org>
Date: Mon Jul 25 18:42:20 2022 +0800

description
===========
The mainline kernel can be used for relative old distros, e.g. RHEL 7.
The distro doesn't upgrade from python2 to python3, this causes the
building error that the python script is not python2 compliant.

To fix the building failure, this patch changes from the python f-string
format to traditional string format.

Fixes: 12fdd6c009da0d02 ("perf scripts python: Support Arm CoreSight trace data disassembly")

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2022-09-21 07:23:15 +02:00
Michael Petlan 1c24908360 perf scripts python: Support Arm CoreSight trace data disassembly
Bugzilla: https://bugzilla.redhat.com/2123231

upstream
========
commit 12fdd6c009da0d029ae54cff67242be02ea42a7a
Author: Leo Yan <leo.yan@linaro.org>
Date: Sat May 21 21:04:46 2022 +0800

description
===========
This commit adds python script to parse CoreSight tracing event and
print out source line and disassembly, it generates readable program
execution flow for easier humans inspecting.

The script receives CoreSight tracing packet with below format:

                +------------+------------+------------+
  packet(n):    |    addr    |    ip      |    cpu     |
                +------------+------------+------------+
  packet(n+1):  |    addr    |    ip      |    cpu     |
                +------------+------------+------------+

packet::addr presents the start address of the coming branch sample, and
packet::ip is the last address of the branch smple.  Therefore, a code
section between branches starts from packet(n)::addr and it stops at
packet(n+1)::ip.  As results we combines the two continuous packets to
generate the address range for instructions:

  [ sample(n)::addr .. sample(n+1)::ip ]

The script supports both objdump or llvm-objdump for disassembly with
specifying option '-d'.  If doesn't specify option '-d', the script
simply outputs source lines and symbols.

Below shows usages with llvm-objdump or objdump to output disassembly.

  # perf script -s scripts/python/arm-cs-trace-disasm.py -- -d llvm-objdump-11 -k ./vmlinux
  ARM CoreSight Trace Data Assembler Dump
  	ffff800008eb3198 <etm4_enable_hw>:
  	ffff800008eb3310: c0 38 00 35  	cbnz	w0, 0xffff800008eb3a28 <etm4_enable_hw+0x890>
  	ffff800008eb3314: 9f 3f 03 d5  	dsb	sy
  	ffff800008eb3318: df 3f 03 d5  	isb
  	ffff800008eb331c: f5 5b 42 a9  	ldp	x21, x22, [sp, #32]
  	ffff800008eb3320: fb 73 45 a9  	ldp	x27, x28, [sp, #80]
  	ffff800008eb3324: e0 82 40 39  	ldrb	w0, [x23, #32]
  	ffff800008eb3328: 60 00 00 34  	cbz	w0, 0xffff800008eb3334 <etm4_enable_hw+0x19c>
  	ffff800008eb332c: e0 03 19 aa  	mov	x0, x25
  	ffff800008eb3330: 8c fe ff 97  	bl	0xffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>
              main  6728/6728  [0004]         0.000000000  etm4_enable_hw+0x198                    [kernel.kallsyms]
  	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>:
  	ffff800008eb2d60: 1f 20 03 d5  	nop
  	ffff800008eb2d64: 1f 20 03 d5  	nop
  	ffff800008eb2d68: 3f 23 03 d5  	hint	#25
  	ffff800008eb2d6c: 00 00 40 f9  	ldr	x0, [x0]
  	ffff800008eb2d70: 9f 3f 03 d5  	dsb	sy
  	ffff800008eb2d74: 00 c0 3e 91  	add	x0, x0, #4016
  	ffff800008eb2d78: 1f 00 00 b9  	str	wzr, [x0]
  	ffff800008eb2d7c: bf 23 03 d5  	hint	#29
  	ffff800008eb2d80: c0 03 5f d6  	ret
              main  6728/6728  [0004]         0.000000000  etm4_cs_lock.isra.0.part.0+0x20

  # perf script -s scripts/python/arm-cs-trace-disasm.py -- -d objdump -k ./vmlinux
  ARM CoreSight Trace Data Assembler Dump
  	ffff800008eb3310 <etm4_enable_hw+0x178>:
  	ffff800008eb3310:	350038c0 	cbnz	w0, ffff800008eb3a28 <etm4_enable_hw+0x890>
  	ffff800008eb3314:	d5033f9f 	dsb	sy
  	ffff800008eb3318:	d5033fdf 	isb
  	ffff800008eb331c:	a9425bf5 	ldp	x21, x22, [sp, #32]
  	ffff800008eb3320:	a94573fb 	ldp	x27, x28, [sp, #80]
  	ffff800008eb3324:	394082e0 	ldrb	w0, [x23, #32]
  	ffff800008eb3328:	34000060 	cbz	w0, ffff800008eb3334 <etm4_enable_hw+0x19c>
  	ffff800008eb332c:	aa1903e0 	mov	x0, x25
  	ffff800008eb3330:	97fffe8c 	bl	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>
              main  6728/6728  [0004]         0.000000000  etm4_enable_hw+0x198                    [kernel.kallsyms]
  	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>:
  	ffff800008eb2d60:	d503201f 	nop
  	ffff800008eb2d64:	d503201f 	nop
  	ffff800008eb2d68:	d503233f 	paciasp
  	ffff800008eb2d6c:	f9400000 	ldr	x0, [x0]
  	ffff800008eb2d70:	d5033f9f 	dsb	sy
  	ffff800008eb2d74:	913ec000 	add	x0, x0, #0xfb0
  	ffff800008eb2d78:	b900001f 	str	wzr, [x0]
  	ffff800008eb2d7c:	d50323bf 	autiasp
  	ffff800008eb2d80:	d65f03c0 	ret
              main  6728/6728  [0004]         0.000000000  etm4_cs_lock.isra.0.part.0+0x20

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
2022-09-21 07:23:11 +02:00