---------- Forwarded message ----------
From: Mike Leach <mike.leach(a)linaro.org>
Date: 2 January 2017 at 22:55
Subject: [PATCH] coresight: etm4x: Fix enabling of cycle accurate tracing
in perf.
To: mathieu.poirier(a)linaro.org
Cc: linux-arm-kernel(a)lists.infradead.org, coresignt(a)lists.linaro.org, Mike
Leach <mike.leach(a)linaro.org>
Using perf record 'cyclacc' option in cs_etm event was not setting up cycle
accurate trace correctly.
Corrects bit set in TRCCONFIGR to enable cycle accurate trace.
Programs TRCCCCTLR with a valid threshold value as required by ETMv4 spec.
Signed-off-by: Mike Leach <mike.leach(a)linaro.org>
---
drivers/hwtracing/coresight/coresight-etm4x.c | 7 +++++--
drivers/hwtracing/coresight/coresight-etm4x.h | 1 +
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c
b/drivers/hwtracing/coresight/coresight-etm4x.c
index 4db8d6a..07be032 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -216,8 +216,11 @@ static int etm4_parse_event_config(struct
etmv4_drvdata *drvdata,
goto out;
/* Go from generic option to ETMv4 specifics */
- if (attr->config & BIT(ETM_OPT_CYCACC))
- config->cfg |= ETMv4_MODE_CYCACC;
+ if (attr->config & BIT(ETM_OPT_CYCACC)) {
+ config->cfg |= BIT(4);
+ /* TRM: Must program this for cycacc to work */
+ config->ccctlr = ETM_CYC_THRESHOLD_DEFAULT;
+ }
if (attr->config & BIT(ETM_OPT_TS))
config->cfg |= ETMv4_MODE_TIMESTAMP;
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h
b/drivers/hwtracing/coresight/coresight-etm4x.h
index ba8d3f8..8a62c6c 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.h
+++ b/drivers/hwtracing/coresight/coresight-etm4x.h
@@ -146,6 +146,7 @@
#define ETM_ARCH_V4 0x40
#define ETMv4_SYNC_MASK 0x1F
#define ETM_CYC_THRESHOLD_MASK 0xFFF
+#define ETM_CYC_THRESHOLD_DEFAULT 256
#define ETMv4_EVENT_MASK 0xFF
#define ETM_CNTR_MAX_VAL 0xFFFF
#define ETM_TRACEID_MASK 0x3f
--
2.7.4
--
Mike Leach
Principal Engineer, ARM Ltd.
Blackburn Design Centre. UK
On 8 December 2016 at 02:04, Chunyan Zhang <zhang.chunyan(a)linaro.org> wrote:
>
> Hi Nicolas,
>
> On 8 December 2016 at 16:07, Nicolas GUION <nicolas.guion(a)st.com> wrote:
>
>> Chunyan,
>>
>> No problem and it offers me the opportunity to inform you that this last
>> months in ST I worked on ARM coresight trace.
>>
>> Several month ago I contacted Mathieu about ARM STM coresight feature.
>> Actually this year we started a new SOC project Accorod5, around A7ss and
>> of course with integration of ARM coresight components. Mathieu described
>> me the status in january, the next steps and especially added me in the
>> group for all patch dedicated to this topic.
>>
>>
>> So I followed the progression of the patch set delivery in official linux
>> stream, and in october I started the integration of this topic in our BSP
>> (based form 4.1)
>>
>> -update the both components (stm_class/coresight) of hwtracing from
>> recent kernel in our old kernel.
>> -integrate the on-going ftrace patch (it was the version 6)
>>
>>
> So happy to know you have been following the progress of this patch
> series, Steven Rostedt has included these for next merge window, it's
> supposed to be merged into 4.10.
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
> <http://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.gitfor-n…>
> for-next
>
>>
>> One difference with the Linaro usage that your team usually describes is
>> the capture way, instead to use the target itself
>> we configure the stm to tpiu directly (skip ETF path) and use an external
>> probe to capture the trace (Lauterbach tool),
>> (to cover a long trace session, get the trace for kernel
>> crash/deadlock...)
>>
>
> As an assignee from Spreadtrum, I believe that Spreadtrum also would need
> this functionality.
>
Hello Nicolas,
First and foremost congratulation on the very good integration work. I
have been adamant on that point many times before and today won't be
different - ST has really good tracing technology and knowledge. You guys
have been working on this for a very long time and the results are there.
Au plaisir,
Mathieu
>
>> Here is a view of the T32 output with 2 masters (Cortex A7 and Cortex
>> M3), and 2 STM client for A7 part (Kernel log and FTRACE)
>>
> That's amazing, but I haven't seen the snapshot you mentioned here :)
>
>
>> this snaphot is not the last version, now the Timestamp are correctly
>> handled and the differentiation between the both A7 CPUs has been deported
>> on STMchannel due to a regression of our SOC
>> (our SOC didn't implement correctly the AHB link between the both A7
>> master to STM, so I used the even channel for A7_0 and odd channel for
>> A7_1, it was more or less the only modification from your patch)
>>
>>
>> Thanks for sharing,
> Chunyan
>
>>
>> *Great Job for all this coresight trace development!*
>>
>>
>> br
>>
>> Nicolas
>>
>>
>>
>> On 12/08/2016 08:30 AM, Chunyan Zhang wrote:
>>
>>
>>
>> On 8 December 2016 at 15:04, Nicolas GUION <nicolas.guion(a)st.com> wrote:
>>
>>> Hi Chunyan,
>>>
>>> Are you sure that you pointed the correct Nicolas, cause I'm really far
>>> to know the Dragonboard 410c board?
>>>
>>
>> Ah, my mistake, thanks for telling me :)
>>
>> Chunyan
>>
>>
>>> I'm working in STMicroelectronics and not usual with other boards than
>>> ST ones.
>>>
>>> br
>>> Nicolas
>>>
>>>
>>> On 12/08/2016 07:24 AM, Chunyan Zhang wrote:
>>>
>>> Hi Nicolas,
>>>
>>> I noticed on 96boards forum, some person reported a similar problem "*Dragonboard
>>> not working after failed linux instalation*" [1] which has been
>>> annoying me recently.
>>>
>>> I posted some details on that page the day before yesterday. Could you
>>> give me some suggestion on how to retrieve my Dragon board?
>>>
>>> Many thanks,
>>> Chunyan
>>>
>>>
>>> [1] http://www.96boards.org/forums/topic/dragonboard-not-working
>>> -after-failed-linux-instalation/#post-18901&gsc.tab=0
>>>
>>>
>>>
>>
>>
>
Hi,
could somebody help me understand why the total size of the
recorded ETM trace differs from run to run?
Is this something in my Juno machine setup, or do you also see this?
The maximum length that has been recorded is about 6MB on my setup.
When I am recording the trace of the same program on intel-pt:
$ perf record -e intel_pt//u ./sort
the amount of captured data is deterministic (around 296MB +/- a few KB.)
Thanks,
Sebastian
sort.c is from https://gcc.gnu.org/wiki/AutoFDO/Tutorial
+ gcc sort.c -o sort -O3
++ seq 1 10
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7779 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.610 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7789 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.545 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7797 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.353 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
5949 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.353 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7807 ms
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 3.287 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7772 ms
[ perf record: Woken up 3 times to write data ]
Warning:
AUX data lost 2 times out of 4!
[ perf record: Captured and wrote 0.126 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7811 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.001 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7784 ms
[ perf record: Woken up 3 times to write data ]
Warning:
AUX data lost 2 times out of 4!
[ perf record: Captured and wrote 0.619 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
7770 ms
[ perf record: Woken up 2 times to write data ]
Warning:
AUX data lost 1 times out of 1!
[ perf record: Captured and wrote 0.002 MB perf.data ]
+ for i in '$(seq 1 10)'
+ /root/etm/OpenCSD/tools/perf/perf record -e cs_etm/(a)20070000.etr/u
--per-thread ./sort
Bubble sorting array of 30000 elements
5934 ms
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.236 MB perf.data ]
Hi Mathieu,
perf/Documentation/intel-pt.txt describes how to make autoFDO work
with Intel-PT recorded traces:
# perf record -e intel_pt//u ./sort
# perf inject -i perf.data -o inj --itrace=i100usl --strip
# create_gcov --binary=./sort --profile=inj --gcov=sort.gcov -gcov_version=1
# gcc -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo
On the ARM side, I was able to get an ETM trace, and I started working
with my colleague Brian Rzycki on the second step that translates the trace
into branch events.
Attached is the current state of the patch that adds functionality
from intel-pt.c
to cs-etm.c. We are still trying to get more than one branch recorded in the
branch stack before emitting an event, and it looks like what we need is to
decode more than a packet at a time in cs-etm-decoder.c like in
cs_etm_decoder__buffer_packet()
Comments on the early version of the patch are welcome.
Thanks,
Sebastian
Changed openCSD library version number from v0.4.2 to v0.5 and pumped
the kernel version to v4.9.
Signed-off-by: Mathieu Poirier <mathieu.poirier(a)linaro.org>
---
HOWTO.md | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/HOWTO.md b/HOWTO.md
index 239a2cd194c3..6f768ed8a72c 100644
--- a/HOWTO.md
+++ b/HOWTO.md
@@ -7,7 +7,7 @@ This HOWTO explains how to use the perf cmd line tools and the openCSD
library to collect and extract program flow traces generated by the
CoreSight IP blocks on a Linux system. The examples have been generated using
an aarch64 Juno-r0 platform. All information is considered accurate and tested
-using library version v0.4.2 and the latest perf branch `perf-opencsd-4.8`
+using library version v0.5 and the latest perf branch `perf-opencsd-4.9`
on the [OpenCSD github repository][1].
@@ -15,8 +15,8 @@ On Target Trace Acquisition - Perf Record
-----------------------------------------
All the enhancement to the Perf tools that support the new `cs_etm` pmu have
not been upstreamed yet. To get the required functionality branch
-`perf-opencsd-4.8` needs to be downloaded to the target system where
-traces are to be collected. This branch is an upstream v4.8 kernel
+`perf-opencsd-4.9` needs to be downloaded to the target system where
+traces are to be collected. This branch is an upstream v4.9 kernel
supplemented with modifications to the CoreSight framework and drivers to be
usable by the Perf core. The remaining out of tree patches are being
upstreamed incrementally.
@@ -261,14 +261,14 @@ the host's (which has nothing to do with the target) architecture:
Off Target Perf Tools Compilation
---------------------------------
As stated above not all the pieces of the solution have been upstreamed. To
-get all the components branch `perf-opencsd-4.8` needs to be
+get all the components branch `perf-opencsd-4.9` needs to be
obtained:
- linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-4.8 https://github.com/Linaro/OpenCSD.git perf-opencsd-4.8
+ linaro@t430:~/linaro/coresight$ git clone -b perf-opencsd-4.9 https://github.com/Linaro/OpenCSD.git perf-opencsd-4.9
...
...
- linaro@t430:~/linaro/coresight$ ls perf-opencsd-4.8/
+ linaro@t430:~/linaro/coresight$ ls perf-opencsd-4.9/
arch certs CREDITS Documentation firmware include ipc Kconfig lib Makefile net REPORTING-BUGS scripts sound usr
block COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README samples security tools virt
@@ -279,12 +279,12 @@ successful, but handling of CoreSight trace data won't be supported.
**See perf-test-scripts below for assistance in creating a build and test enviroment.**
- linaro@t430:~/linaro/coresight$ cd perf-opencsd-4.8
- linaro@t430:~/linaro/coresight/perf-opencsd-4.8$ export CSTRACE_PATH=~/linaro/coresight/my-opencsd/decoder
- linaro@t430:~/linaro/coresight/perf-opencsd-4.8$ make -C tools/perf
+ linaro@t430:~/linaro/coresight$ cd perf-opencsd-4.9
+ linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ export CSTRACE_PATH=~/linaro/coresight/my-opencsd/decoder
+ linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ make -C tools/perf
...
...
- linaro@t430:~/linaro/coresight/perf-opencsd-4.8$ ls -l tools/perf/perf
+ linaro@t430:~/linaro/coresight/perf-opencsd-4.9$ ls -l tools/perf/perf
-rwxrwxr-x 1 linaro linaro 6276360 Mar 3 10:05 tools/perf/perf
@@ -323,7 +323,7 @@ to be sure everything is clean.
linaro@t430:~/linaro/coresight/sept20$ rm -rf ~/.debug
linaro@t430:~/linaro/coresight/sept20$ cp -dpR .debug ~/
linaro@t430:~/linaro/coresight/sept20$ export LD_LIBRARY_PATH=~/linaro/coresight/my-opencsd/decoder/lib/linux64/dbg/
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.8/tools/perf/perf report --stdio
+ linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf report --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
@@ -367,7 +367,7 @@ to be sure everything is clean.
Additional data can be obtained, which contains a dump of the trace packets received using the command
- mjl@ubuntu-vbox:./perf-opencsd-4.8/coresight/tools/perf/perf report --stdio --dump
+ mjl@ubuntu-vbox:./perf-opencsd-4.9/coresight/tools/perf/perf report --stdio --dump
resulting a large amount of data, trace looking like:-
@@ -416,10 +416,10 @@ Trace Decoding with Perf Script
Working with perf scripts needs more command line options but yields
interesting results.
- linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.8/tools/perf/
+ linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.9/tools/perf/
linaro@t430:~/linaro/coresight/sept20$ export SCRIPT_PATH=$EXEC_PATH/scripts/python/
linaro@t430:~/linaro/coresight/sept20$ export XTOOL_PATH=/your/aarch64/toolchain/path/bin/
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.8/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump
+ linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf --exec-path=${EXEC_PATH} script --script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- -d ${XTOOL_PATH}/aarch64-linux-gnu-objdump
7f89f24d80: 910003e0 mov x0, sp
7f89f24d84: 94000d53 bl 7f89f282d0 <free@plt+0x3790>
@@ -451,18 +451,18 @@ Kernel Trace Decoding
When dealing with kernel space traces the vmlinux file has to be communicated
explicitely to perf using the "--vmlinux" command line option:
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.8/tools/perf/perf report --stdio --vmlinux=./vmlinux
+ linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf report --stdio --vmlinux=./vmlinux
...
...
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.8/tools/perf/perf script --vmlinux=./vmlinux
+ linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf script --vmlinux=./vmlinux
When using scripts things get a little more convoluted. Using the same example
an above but for traces but for kernel traces, the command line becomes:
- linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.8/tools/perf/
+ linaro@t430:~/linaro/coresight/sept20$ export EXEC_PATH=/home/linaro/coresight/perf-opencsd-4.9/tools/perf/
linaro@t430:~/linaro/coresight/sept20$ export SCRIPT_PATH=$EXEC_PATH/scripts/python/
linaro@t430:~/linaro/coresight/sept20$ export XTOOL_PATH=/your/aarch64/toolchain/path/bin/
- linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.8/tools/perf/perf --exec-path=${EXEC_PATH} script \
+ linaro@t430:~/linaro/coresight/sept20$ ../perf-opencsd-4.9/tools/perf/perf --exec-path=${EXEC_PATH} script \
--vmlinux=./vmlinux \
--script=python:${SCRIPT_PATH}/cs-trace-disasm.py -- \
-d ${XTOOLS_PATH}/aarch64-linux-gnu-objdump \
--
2.7.4