On Wed, 8 Aug 2018 at 01:59, Tomasz Nowicki <tnowicki(a)caviumnetworks.com> wrote:
>
> Hi Mathieu,
>
> It's been a while but I am back to Coresight.
>
> Let me remind my setup and the issue I am struggling with now.
>
> Kernel baseline:
> https://github.com/Linaro/perf-opencsd (perf-opencsd-v4.16)
> OpenCSD:
> https://github.com/Linaro/OpenCSD.git (master)
>
> The simplest Coresight components path I used as a start point:
> ETMv4.1 -> TDR -> FUNNEL -> ETF
>
> As I mentioned TDR is built by Cavium and it was added to aggregate 128
> inputs into one output rather than cascading funnels. TDR has its own
> driver just to keep path connected in Linux Coresight framework.
>
> Here is how I catch some trace data:
> sudo perf record -C 0 -e cs_etm/@etf0/ --per-thread test_app
The above command line tells perf to trace everything that is
happening on CPU0 for as long as "test_app" is executing. In this
case the "--per-thread" option is ignored. This is called a CPU-wide
trace scenario and is currently not supported for CS (I am currently
working on it).
If you want to make sure "test_app" executes on CPU0 and that you
trace just that you will need to use the "taskset" utility:
sudo perf record -e cs_etm/@etf0/ --per-thread taskset 0x1 test_app
An alternative to the above would be to CPU-hotplug out CPU128-255
while you are testing.
Let's start with that before going further.
Thanks,
Mathieu
>
> I need to use -C because my machines has 2 nodes, 32 cores (128 threads)
> each and each node has different ETF. So I have to specify which CPU is
> the source and for specified ETF sink (EFT0 can be a sink for
> CPU0-CPU127, ETF1 can be a sink for CPU128-CPU255). Otherwise Linux
> cannot find path for ETMs related to CPU128-CPU255 if I specify ETF0 as
> a sink.
>
> Overall, I can see some data using:
> # sudo perf report --stdio --dump
> [...]
> . ... CoreSight ETM Trace data: size 16384 bytes
> Frame deformatter: Found 4 FSYNCS
> ID:12 RESET operation on trace decode path
> Idx:108; ID:12; I_NOT_SYNC : I Stream not synchronised
> Idx:455; ID:12; I_ASYNC : Alignment Synchronisation.
> Idx:468; ID:12; I_TRACE_INFO : Trace Info.; INFO=0x0
> Idx:470; ID:12; I_TRACE_ON : Trace On.
> Idx:471; ID:12; I_CTXT : Context Packet.; Ctxt: AArch64,EL0, NS;
> Idx:473; ID:12; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
> Addr=0x0000AAABE0B09584;
> Idx:483; ID:12; I_ATOM_F1 : Atom format 1.; N
> Idx:484; ID:12; I_TIMESTAMP : Timestamp.; Updated val =
> 0x1b6a5d937cc1
> Idx:492; ID:12; I_ATOM_F3 : Atom format 3.; NNE
> Idx:493; ID:12; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
> Addr=0x0000AAABE0B0D210;
> Idx:504; ID:12; I_ATOM_F3 : Atom format 3.; NEE
> Idx:505; ID:12; I_ATOM_F3 : Atom format 3.; NEN
> Idx:506; ID:12; I_ATOM_F6 : Atom format 6.; EEEN
> Idx:507; ID:12; I_ATOM_F3 : Atom format 3.; NNE
> Idx:508; ID:12; I_ATOM_F1 : Atom format 1.; N
> Idx:509; ID:12; I_ATOM_F3 : Atom format 3.; NNN
> Idx:510; ID:12; I_ATOM_F3 : Atom format 3.; EEN
> Idx:512; ID:12; I_ATOM_F1 : Atom format 1.; E
> [...]
>
> However, I still see errors while using:
> # sudo perf report --stdio
> 0x1e8 [0x60]: failed to process type: 1
> Error:
> failed to process sample
> # To display the perf.data header info, please use
> --header/--header-only options.
>
> The reason is that cs_etm__process_event() is failing on:
> if (!etm->timeless_decoding)
> return -EINVAL;
>
> and etm->timeless_decoding is setup in cs_etm__is_timeless_decoding().
> For some events time bit set and so far I failed to figure out what is
> going on. Have you met similar issue so far? Any pointers or hints are
> very appreciated.
>
> One more comment below.
>
> On 10.01.2018 21:10, Mathieu Poirier wrote:
> > On 10 January 2018 at 06:57, Tomasz Nowicki <tnowicki(a)caviumnetworks.com> wrote:
> >> Hello Mathieu,
> >>
> >> Thank you for your response. Please see comments below.
> >>
> >> On 08.01.2018 17:53, Mathieu Poirier wrote:
> >>>
> >>> Good day Tomasz,
> >>>
> >>>
> >>> On 5 January 2018 at 05:51, tn <Tomasz.Nowicki(a)caviumnetworks.com> wrote:
> >>>>
> >>>> Hi Mathieu,
> >>>>
> >>>> I am bringing up Coresight functiproject zeroonality on ThunderX2. While
> >>>> ramping up I
> >>>> come across your Connect session:
> >>>>
> >>>> which I found very helpful.
> >>>
> >>>
> >>> Perfect - a few things have changed since then, see below.
> >>>
> >>>>
> >>>> During my research I had to create new Coresight component driver for
> >>>> Linux,
> >>>> here is the story. For ThunderX2, we aggregate data trace from all 128
> >>>> ETMs
> >>>> into one funnel inport using so called TDR (Trace Data Ring) component.
> >>>> This
> >>>> should be transparent to software and does not require configuration at
> >>>> all.
> >>>> However, Linux Coresight framework requires components to be connected
> >>>> each
> >>>> other so we cannot leave funnel and ETMs disconnected in DT. I decided to
> >>>> create pure software component i.e. TDR which is meant to connect chain
> >>>> only, no actions on registers.
> >>>
> >>>
> >>> Is this TDR an ARM IP or built in-house by Cavium?
> >>
> >>
> >> This is Cavium specific component which I am going to upstream once I test
> >> the whole functionality.
> >>
> >> And I suppose it
> >>>
> >>> was added there to aggregate 128 input into one output rather than
> >>> cascading funnels?
> >>
> >>
> >> Correct.
> >>
> >>>>
> >>>> Now I am able to enable ETF sink and path from ETM via TDR via FUNNEL up
> >>>> to
> >>>> ETF and gather some data. To be sure things work properly I want to
> >>>> decode
> >>>> data using Linaro OpenCSD library following instructions from here:
> >>>>
> >>>> https://community.arm.com/tools/b/blog/posts/do-a-coresight-trace-on-linux-…
> >>>
> >>>
> >>> Thanks for pointing this out, I didn't know about it.
> >>>
> >>>> but still got error while doing 'perf report' step. Kernel perf tool
> >>>> support
> >>>> for OpenCSD is out of tree for now so I may miss some patches.
> >>>
> >>>
> >>> Can you get me a pastebin of the errors you're getting?
> >>
> >>
> >> Sure, see:
> >> https://pastebin.com/6YDq8KfC
> >> As you see there is not much info about error cause.
> >>
> >>>
> >>>>
> >>>> Here is my setup:
> >>>> https://github.com/Linaro/perf-opencsd/commits/upstream-v1 (+ ThunderX2
> >>>> specific patches)
> >>>
> >>>
> >>> Oh boy... I wasn't expecting people to use that but I suppose it is
> >>> the right thing to do. Keep going with that code.
> >>>
> >>>> https://github.com/Linaro/OpenCSD/commits/master
> >>>
> >>>
> >>> This, in combination with the upstream-v1 branch should work properly.
> >>> That's how I test things on my Juno and Dragon board.
> >>>
> >>>>
> >>>> # echo 1 > etf0/enable_sink
> >>>> # perf record -C 0 -e cs_etm// sleep 2
> >>>
> >>>
> >>> Ok, that won't work as the -C option is currently not supported (I am
> >>> working on it). I also suggest to make sure you have the very latest
> >>> TIP [1] on branch [2] and to carefully read the README.md. We
> >>> recently updated the instructions to fit the newest development.
> >>> Lastly we have deprecated enabling the sink from the sysFS interface -
> >>> it can still work but no guarantees are provided. It is better to
> >>> specify the sink as part of the perf record command line, as shown in
> >>> the most recent HOWTO.md.
> >>
> >>
> >> I am able to specify sink as part of the perf record command line only for
> >> Linux Perf master branch:
> >> https://github.com/Linaro/perf-opencsd/commits/master
> >>
> >> For upstream-v1 branch I am getting:
> >> $ perf record -vvv -e cs_etm/@etf0/ --per-thread uname
> >> Using CPUID 0x00000000420f5160
> >> perf: util/evsel.c:783: apply_config_terms: Assertion `!(1)' failed.
> >> Aborted (core dumped)
> >
> >
> > Ok, I've uploaded upstream-v2. With that branch everything works fine
> > on my side, no changes needed. I added a fix for a regression in the
> > perf tip tree and the code required to use the ETR from the perf
> > interface.
> >
> > One thing about the above: "@etf0". Is this really the name you gave
> > to the device in the DT? Look under /sys/bus/coresight/devices/ for
> > an etf entry. What is listed there should is the name of the ETF as
> > it is known to the system.
>
> Indeed, the name is different but for perf command clarity I use shortcut.
>
> Thanks,
> Tomasz
+CoreSight ML and Mathieu
---------- Forwarded message ----------
From: Mike Leach <mike.leach(a)linaro.org>
Date: 3 September 2018 at 17:39
Subject: Re: Failed for ETM decoding with db410c snapshot mode
To: Leo Yan <leo.yan(a)linaro.org>
HI Leo,
Short summary - there is a problem with the trace collected - not the
decoder. See below for details
On 3 September 2018 at 08:06, <leo.yan(a)linaro.org> wrote:
> Hi Mike, Mathieu,
>
> [ + CoreSight ML ]
>
> When I work on the CoreSight + perf tool and used crash extension
> program to extract the tracing data from perf aux buffer, finally I
> can get the trace data for about 1.6MB from ETF sink from DB410c board.
>
> To verify the extracted trace data, I used 'snapshot' mode under
> OpenCSD code base, you could see the tar file for this [1]. After
> you download this file, you could place it under OpenCSD folder:
>
> $ cp db410c_snapshot_kdump.tgz my_opencsd/decoder/tests/snapshots
> $ cd my_opencsd/decoder/tests/snapshots
> $ tar zxvf db410c_snapshot_kdump.tgz
> $ cd db410c_snapshot_kdump
>
> $ ../../bin/builddir/trc_pkt_lister
This will print raw trace packets as it finds them without attempting
any sort of interpretation.
> $ ../../bin/builddir/trc_pkt_lister -decode
This will try to decode the raw trace packets into a sequence of
instructions executed (alongside the raw packets)
This is where the packets are being flagged as incorrect.
>
> If I use the command 'trc_pkt_lister' without any extra options, it
> can print out trace packets successfully; but if I add the extra
> option '-decode' it uses 'decode all' mode and it reports the errors as:
>
> 483710 Idx:53086; ID:10; [0xf8 ]; I_ATOM_F3 : Atom format 3.; NNN
> 483711 Idx:53086; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffff000008abc9f0 )
> 483712 Idx:53088; ID:10; [0xdb ]; I_ATOM_F2 : Atom format 2.; EE
> 483713 Idx:53194; ID:10; [0x6b 0x8c 0x08 0xfa 0xdc 0x95 0x5c ]; I_COND_RES_F1 : Conditional Result, format 1.
This is a conditional result trace packet - however as far as I am
aware the trace unit on an A53 (i.e. DB410 core) cannot produce these.
Additionally in the entire file I see 2 I_COND packets and 1
I_NUM_DS_MKR - a data synchronisation marker packet.
Now Data sync can only ever occur if data trace is supported and
enabled. Data trace is architecturally prohibited for A class v8 cores
(and unimplemented on most A class v7 cores).
If there were tracing of conditional elements occurring, and it were
enabled, then the packets should match up - a cond instruction should
match with one cond result element.
But in the end - event without these inconsistencies - the TRACE_INFO
element at the top of the listing tells me that conditional
instruction trace is disabled.
Thus you are seeing what I believe is the effect of concatenating
trace data buffers together (you mention you have 1.6MB of data from
the ETF - which is not that large), without inserting barrier packets
in between.
The decoder cannot spot the boundaries, and will carry on and be out
of sync so can mis-read trace packet payload data as header data which
will throw off the decode process.
When I look at the raw byte data I am seeing this at the top of the listing:-
Frame Data; Index 0; ID_DATA[????]; ff
Frame Data; Index 0; ID_DATA[0x7f]; 7f ff 7f ff 7f ff
This does not look valid at all to me.
> 483714 DCD_ETMV4_0016 : 0x0018 (OCSD_ERR_BAD_DECODE_PKT) [Reserved or unknown packet in decoder.]; Unsupported packet type.Trace Packet Lister : Data Path fatal error
> 483715 0x0018 (OCSD_ERR_BAD_DECODE_PKT) [Reserved or unknown packet in decoder.]; Unsupported packet type.Trace Packet Lister : Trace buffer done, processed 53216 bytes.
>
> You also could check detailed log trc_pkt_lister.ppl in the shared
> tar packet; After searched for the OpenCSD code and found this error is
> due it cannot support some types of packets [2].
>
> So want to check what's the best for this issue; seems to me we need
> to fix this so it can support well to complete the decoding?
>
The reason we have not implemented support for these packets, is that
we have never seen an implementation that generates them.
regards
Mike
> Thanks in advance for suggestion.
> Leo Yan
>
> [1] http://people.linaro.org/~leo.yan/opencsd_db410c/db410c_snapshot_kdump.tgz
> [2] https://github.com/Linaro/OpenCSD/blob/master/decoder/source/etmv4/trc_pkt_…
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Greetings,
I'm trying to enable the Coresight ETMv4 trace from kernel mode. I saw
there is no documentation on how to do this, except using the sysfs user
mode interface and perf.
To overcome this i looked a little bit in the coresight.h header file, and
came to these APIs:
> extern int coresight_enable(struct coresight_device *csdev);
>
> extern void coresight_disable(struct coresight_device *csdev);
And the sysfs implementation uses these APIs when enabing/disabling the
trace code, so i thought this could suit my needs. The next problem was
actually getting the coresight devices data structures, which aren't
exported and are actually provided internally to perf and sysfs. So i
exported the coresight bus type:
struct bus_type coresight_bustype = {
>
> .name = "coresight",
>
> };
>
> EXPORT_SYMBOL(coresight_bustype);
And enumerated the bus and just looked for the
type CORESIGHT_DEV_TYPE_SOURCE, since the only source on my board is ETMv4,
there isn't any conflicts so i should get only ETMv4s.
This worked, and indeed i collected a coresight device for every CPU, and
enabled the trace successfully while being in *non-atomic context*.
The problem is, i must enable the trace in *atomic context synchronously *on
the current thread's CPU(i can't issue a work-queue to enable the trace for
me). So.. i got many BUG() errors because of non-atomic API usage, for
example, the allocation of the TMC-ETR buffer:
> dma_alloc_coherent(drvdata->dev, etr_buf->size,
> &flat_buf->daddr, *GFP_KERNEL*);
So my questions are:
1) Is there a more documented way of enabling coresight from kernel mode? i
believe i achieved this using cheats.
2) I see there is no exported kernel API to config the coresight trace
attributes(for example, filter EL0). I can only do so from sysfs.. am i
missing something?
3) Are there any plans to make the Coresight infrastructure atomic-context
friendly?
If there are, is the development in progress? if not.. how would you
suggest tackling the issues i've described in this message?
Thank you!
Hi,
I have followed procedure to integrate libopenCSD in perf tool in target ARM. (based on kernel 4.18rc1)
I’ve seen in documentation that perf record need parameters cs_etm/(a)xxxxx.etr/u …<mailto:cs_etm/@xxxxx.etr/u%20…>
I would like to know if ETR device is mandatory to use coresight trace with perf ?
In my architecture, I’ve :
1 .funnel
1 .tpiu
2 .etm
1 .etf
1 .stm
1 replicator but no ETR ☹
If possible without ETR, do you have examples of perf record cmd usage ?
I’ve configured my coresight register as followed :
echo 1 > /sys/bus/coresight/devices/xxxx.stm/hwevent_select
echo 2 > /sys/bus/coresight/devices/xxxx.stm/hwevent_extmux_select
// Need to track IRQ up of UART
echo 0x200000 > /sys/bus/coresight/devices/xxxx.stm/hwevent_enable
echo 1 > /sys/bus/coresight/devices/yyyy.etf/enable_sink
echo 1 > /sys/bus/coresight/devices/xxxx.stm/enable_source
Which perf record cmd I must enter to catch my STM event ?
Thanks for your help.
Christophe.
Hi Mike, Mathieu,
[ + CoreSight ML ]
When I work on the CoreSight + perf tool and used crash extension
program to extract the tracing data from perf aux buffer, finally I
can get the trace data for about 1.6MB from ETF sink from DB410c board.
To verify the extracted trace data, I used 'snapshot' mode under
OpenCSD code base, you could see the tar file for this [1]. After
you download this file, you could place it under OpenCSD folder:
$ cp db410c_snapshot_kdump.tgz my_opencsd/decoder/tests/snapshots
$ cd my_opencsd/decoder/tests/snapshots
$ tar zxvf db410c_snapshot_kdump.tgz
$ cd db410c_snapshot_kdump
$ ../../bin/builddir/trc_pkt_lister
$ ../../bin/builddir/trc_pkt_lister -decode
If I use the command 'trc_pkt_lister' without any extra options, it
can print out trace packets successfully; but if I add the extra
option '-decode' it uses 'decode all' mode and it reports the errors as:
483710 Idx:53086; ID:10; [0xf8 ]; I_ATOM_F3 : Atom format 3.; NNN
483711 Idx:53086; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0xffff000008abc9f0 )
483712 Idx:53088; ID:10; [0xdb ]; I_ATOM_F2 : Atom format 2.; EE
483713 Idx:53194; ID:10; [0x6b 0x8c 0x08 0xfa 0xdc 0x95 0x5c ]; I_COND_RES_F1 : Conditional Result, format 1.
483714 DCD_ETMV4_0016 : 0x0018 (OCSD_ERR_BAD_DECODE_PKT) [Reserved or unknown packet in decoder.]; Unsupported packet type.Trace Packet Lister : Data Path fatal error
483715 0x0018 (OCSD_ERR_BAD_DECODE_PKT) [Reserved or unknown packet in decoder.]; Unsupported packet type.Trace Packet Lister : Trace buffer done, processed 53216 bytes.
You also could check detailed log trc_pkt_lister.ppl in the shared
tar packet; After searched for the OpenCSD code and found this error is
due it cannot support some types of packets [2].
So want to check what's the best for this issue; seems to me we need
to fix this so it can support well to complete the decoding?
Thanks in advance for suggestion.
Leo Yan
[1] http://people.linaro.org/~leo.yan/opencsd_db410c/db410c_snapshot_kdump.tgz
[2] https://github.com/Linaro/OpenCSD/blob/master/decoder/source/etmv4/trc_pkt_…
Good day Leo,
Please meet my new friend Christophe. He is from ST-Micro and is
currently working on integrating the CS framework in their next
platform. I would be grateful if you could share with him the
instructions you have used to get STM doing on the dragon board and
how you got the snapshot decoder to decode the traces.
Christophe is also looking to get a trace snapshot that is known to be
working properly to test in his environment.
Many thanks,
Mathieu