CoreSight doesn't allocate thread structure for unknown_thread in etm
auxtrace, so unknown_thread is NULL pointer. If the perf data doesn't
contain valid tid and then cs_etm__mem_access() uses unknown_thread
instead as thread handler, this results in segmentation fault when
thread__find_addr_map() accesses thread handler.
This commit creates new thread data which is used by unknown_thread, so
CoreSight tracing can roll back to use unknown_thread if perf data
doesn't include valid thread info. This commit also releases thread
data for initialization failure case and for normal auxtrace free flow.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
Acked-by: Mathieu Poirier <mathieu.poirier(a)linaro.org>
---
tools/perf/util/cs-etm.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 6533b1a..69f21de 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -239,6 +239,7 @@ static void cs_etm__free(struct perf_session *session)
for (i = 0; i < aux->num_cpu; i++)
zfree(&aux->metadata[i]);
+ thread__zput(aux->unknown_thread);
zfree(&aux->metadata);
zfree(&aux);
}
@@ -1355,6 +1356,23 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
etm->auxtrace.free = cs_etm__free;
session->auxtrace = &etm->auxtrace;
+ etm->unknown_thread = thread__new(999999999, 999999999);
+ if (!etm->unknown_thread)
+ goto err_free_queues;
+
+ /*
+ * Initialize list node so that at thread__zput() we can avoid
+ * segmentation fault at list_del_init().
+ */
+ INIT_LIST_HEAD(&etm->unknown_thread->node);
+
+ err = thread__set_comm(etm->unknown_thread, "unknown", 0);
+ if (err)
+ goto err_delete_thread;
+
+ if (thread__init_map_groups(etm->unknown_thread, etm->machine))
+ goto err_delete_thread;
+
if (dump_trace) {
cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu);
return 0;
@@ -1369,16 +1387,18 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
err = cs_etm__synth_events(etm, session);
if (err)
- goto err_free_queues;
+ goto err_delete_thread;
err = auxtrace_queues__process_index(&etm->queues, session);
if (err)
- goto err_free_queues;
+ goto err_delete_thread;
etm->data_queued = etm->queues.populated;
return 0;
+err_delete_thread:
+ thread__zput(etm->unknown_thread);
err_free_queues:
auxtrace_queues__free(&etm->queues);
session->auxtrace = NULL;
--
2.7.4
CoreSight doesn't allocate thread structure for unknown_thread in etm
auxtrace, so unknown_thread is NULL pointer. If the perf data doesn't
contain valid tid and then cs_etm__mem_access() uses unknown_thread
instead as thread handler, this results in segmentation fault when
thread__find_addr_map() accesses thread handler.
This commit creates new thread data which is used by unknown_thread, so
CoreSight tracing can roll back to use unknown_thread if perf data
doesn't include valid thread info. This commit also releases thread
data for initialization failure case and for normal auxtrace free flow.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
tools/perf/util/cs-etm.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 6533b1a..417302c 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -239,6 +239,7 @@ static void cs_etm__free(struct perf_session *session)
for (i = 0; i < aux->num_cpu; i++)
zfree(&aux->metadata[i]);
+ thread__zput(aux->unknown_thread);
zfree(&aux->metadata);
zfree(&aux);
}
@@ -266,6 +267,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u64 address,
if (!thread) {
if (cpumode != PERF_RECORD_MISC_KERNEL)
return -EINVAL;
+
thread = etmq->etm->unknown_thread;
}
@@ -1355,6 +1357,23 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
etm->auxtrace.free = cs_etm__free;
session->auxtrace = &etm->auxtrace;
+ etm->unknown_thread = thread__new(999999999, 999999999);
+ if (!etm->unknown_thread)
+ goto err_free_queues;
+
+ /*
+ * Initialize list node so that at thread__zput() we can avoid
+ * segmentation fault at list_del_init().
+ */
+ INIT_LIST_HEAD(&etm->unknown_thread->node);
+
+ err = thread__set_comm(etm->unknown_thread, "unknown", 0);
+ if (err)
+ goto err_delete_thread;
+
+ if (thread__init_map_groups(etm->unknown_thread, etm->machine))
+ goto err_delete_thread;
+
if (dump_trace) {
cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu);
return 0;
@@ -1369,16 +1388,18 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
err = cs_etm__synth_events(etm, session);
if (err)
- goto err_free_queues;
+ goto err_delete_thread;
err = auxtrace_queues__process_index(&etm->queues, session);
if (err)
- goto err_free_queues;
+ goto err_delete_thread;
etm->data_queued = etm->queues.populated;
return 0;
+err_delete_thread:
+ thread__zput(etm->unknown_thread);
err_free_queues:
auxtrace_queues__free(&etm->queues);
session->auxtrace = NULL;
--
2.7.4
On 27 April 2018 at 12:24, Robert Walker <Robert.Walker(a)arm.com> wrote:
> Hi,
>
>
>
> Strobing the ETM to reduce the amount of trace data when collecting profiles
> for AutoFDO seems to be working and providing useful optimizations. We’re
> currently working with some proof of concept patches (attached for
> reference) that add parameters to sysfs to configure the strobe period –
> before running perf record, the user must write to these parameters for each
> ETM. This isn’t suitable for production use as it has to be done for each
> ETM and the values persist after the trace session. To get this into
> upstream, we need to have this done by the perf record tool.
>
>
>
> I understand there is work planned to enable more complex ETM configurations
> (such as strobing) from perf, possibly using a file to load register values
> from. Is this still the case, and if so, when is it likely to be done?
Hi Robert,
I am currently working on supporting CPU-wide trace scenarios where I
can start seeing the end of the tunnel. After that my plan was to add
support for ETMv3.x/PTM trace decoding followed by support for N:N
source/sink topology. Part of the latter is to introduce a way to
enable more complex ETM configuration using a configuration file. In
fact I already stumbled on how I want to do that and have a (very)
small prototype that works.
So that is what I had in mind... But it doesn't mean I can't be talked
into changing my priorities. In fact I will gladly do so if we, as a
group, decide it is more important to introduce support for complex
configuration before ETMv3.x/PTM decoding. I personally don't have a
preference, it is simply a matter of deciding what we want to do.
I have CC'ed the coresight mailing list in order to reach a broader
audience. Please speak up if you really have an issue (along with the
rational) with supporting ETM complex configurations before
ETMv3.x/PTM decoding.
Best regards,
Mathieu
>
>
>
> Thanks
>
>
>
> Rob
>
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
Hi,
Any updates to below emails,.?
Regards
Chris
From: Chris Samuel [mailto:chris.samuel@lead-marketings.com]
Sent: Thursday, April 05, 2018 10:40 AM
To: 'coresight(a)lists.linaro.org'
Subject: RE: IBM lotus-accounts
Hi,
Any updates to below emails,.?
Awaiting your kind response for regarding my previous email. If it makes
sense to talk, please let me know how your calendar looks.
I would appreciate if you could pass along my details to the appropriate
person if you don't handle this.
Do you have any other requirement kindly let me know your exact target
industry and target audience and target location, we will provide the exact
cost and counts with many more ....
Regards,
Chris
From: Chris Samuel [mailto:chris.samuel@lead-marketings.com]
Sent: Tuesday, April 03, 2018 3:40 PM
To: 'coresight(a)lists.linaro.org'
Subject: IBM lotus-accounts
Hi,
A quick check to see if you would you be interested to acquire updated
Slack, IBM Lotus Domino, IBM Lotus Notes, LogMeIn, Microsoft SharePoint,
Accounts with verified email and phone numbers.
kindly let me know your exact target industry and target audience and target
location, we will provide the exact database counts with cost and many
more....
Appreciate your time and look forward to your response.
Best Regards,
Chris,
Marketing Executive,
If you do not want to receive from us then reply back "Unsubscribe" as a
Subject Line.
Hello,
I hope you're doing well!
I am following up with you on the below since I have not heard back from
you. Please let me know if you would like to get more information on the
same.
Looking forward to hearing from you.
Warm Regards,
Rick Forster
From: Rick Forster [mailto:rick.forster@attendeeinfo.com]
Sent: 24 April 2018 09:23
To: 'coresight(a)lists.linaro.org'
Subject: California Dental Association - Spring - CDA 2018 Attendees list
Hello,
I hope you are the right person to discuss about California Dental
Association - Spring - CDA May 2018 Attendees Info?
California Dental Association - Spring - CDA 2018 Attendees list of 18,900
contacts with complete contact details and verified email addresses info
will be provided for unlimited usage.
Interested? Email me back, I'd love to provide more information.
Thank you.
Regards,
Rick Foster
Demand Generation Executive.
If you do not wish to receive future
emails from us, please reply as "opt-out"
Hello,
I hope you are the right person to discuss about California Dental
Association - Spring - CDA May 2018 Attendees Info?
California Dental Association - Spring - CDA 2018 Attendees list of 18,900
contacts with complete contact details and verified email addresses info
will be provided for unlimited usage.
Interested? Email me back, I'd love to provide more information.
Thank you.
Regards,
Rick Foster
Demand Generation Executive.
If you do not wish to receive future
emails from us, please reply as "opt-out"
Hi all,
I have been using CoreSight PTM component on Zynq for more than two
years. I started out by programming a simple library to program these
components on a “bare-metal” system (without OS). Then, I moved on Linux
and Mathieu Poirier (I can’t thank him enough) helped me a lot during
this phase. So far, I have been tracing small portions of my
applications and the amount of trace generated was not that important. I
was getting the expected trace i.e. for each branch (direct or
indirect), I was getting a branch address packet in my trace. Now, I
started tracing the whole .text section of binaries and I am not
understanding the obtained trace.
Here is how I configure Linux kernel driver (Kernel v4.9):
cd /sys/bus/coresight/devices/f889c000.ptm0
echo 1 > addr_idx
echo 0 > addr_acctype
echo 0 > addr_idx
echo 0 > addr_acctype
echo 20 > mode
echo 100e0 104b4 > addr_range # These two addresses represent the
beginning and end of .text section
Then, I enable the trace sink component (either ETB or TPIU) and trace
source (PTM) component.
cd /sys/bus/coresight/devices/
echo 1 > f8801000.etb/enable_sink
echo 1 > f889c000.ptm0/enable_source
Then, I run my application and stop tracing.
./application.elf
./disable # simply writes 0 to each enabled component (source and sink)
Then, I recover the trace using dd.
When I trace small portions of my application, the obtained trace gives
the right behavior. I check it manually by looking at objdump of the binary.
However, when I trace the whole .text section of the application, the
amount of obtained trace is very small (even smaller than if I trace
only main function of the application) which is quite strange for me.
Basically, the obtained trace is going through libc functions that call
the main function and it stops while it is in libc. I don’t understand
why I am getting this strange behavior. Do you have any ideas about what
I am doing wrong.
I have attached a binary source code that I am trying to trace.
Thank you for your help and time.
Best regards,
Muhammad
PS: Sorry, I formatted my previous mail in markdown rather than HTML. This should be more readable than the previous mail.