[PATCH v1 1/3] coresight: etm-perf: Correct buffer syncing for snapshot

James Clark james.clark at arm.com
Thu Jun 10 07:54:20 PDT 2021



On 01/06/2021 13:35, Leo Yan wrote:
> Hi James,
> 
> On Tue, Jun 01, 2021 at 12:53:16PM +0300, James Clark wrote:
> 
> [...]
> 
>> Hi Leo,
>>
>> I was testing out snapshot mode (without your patch) and I noticed that it
>> only ever collects from the last CPU. For example on a 4 core system,
>> the CPU ID of the AUX records and the AUXTRACE buffers is always 3.
>>
>> This is with systemwide tracing, and running "stress -m 2 -c 2".
>> Is this something that your patch fixes, or am I doing something wrong, or
>> is it just a coincidence?
> 
> No, I think it's quite likely caused by blow code:
> 
> static unsigned long
> tmc_update_etr_buffer(struct coresight_device *csdev,
>                       struct perf_output_handle *handle,
>                       void *config)
> {
>     unsigned long flags, offset, size = 0;
> 
>     ...
> 
>     /* Don't do anything if another tracer is using this sink */
>     if (atomic_read(csdev->refcnt) != 1) {
>         spin_unlock_irqrestore(&drvdata->spinlock, flags);
>         goto out;
>     }
> 
>     ...
> 
>     return size;
> }
> 
> When using the system wide tracing, it updates the AUX ring buffer
> until the last tracer is stopped.  Thus whis is why it only records
> AUX ring buffer for the last CPU.
> 
> But this makes sense for me, this is because the last CPU is used to
> copy trace data to AUX ring buffer (so the perf event PERF_RECORD_AUX
> occurs on CPU3), but when you decode the trace data, you should can
> see the activities from other CPUs.
> 
> Thanks,
> Leo
> 

I have one more issue around snapshot mode which I'd like to check if it's
related to this patchset.

In "[PATCH v5 0/1] perf cs-etm: Split Coresight decode by aux records",
I added the warning for a missing AUXTRACE buffer as you suggested.
Now this warning gets triggered on the last AUX record when using
snapshot mode. I don't know if you are able to reproduce this.

Thanks
James



More information about the linux-arm-kernel mailing list