On 05/26/2020 05:33 PM, Mike Leach wrote:
Hi,
On Tue, 26 May 2020 at 17:21, Suzuki K Poulose suzuki.poulose@arm.com wrote:
On 05/25/2020 04:56 PM, Mathieu Poirier wrote:
On Fri, 22 May 2020 at 09:30, Suzuki K Poulose suzuki.poulose@arm.com wrote:
On 05/08/2020 04:43 PM, Mathieu Poirier wrote:
On Fri, 8 May 2020 at 00:11, Leo Yan <leo.yan@linaro.org mailto:leo.yan@linaro.org> wrote:
Hi Al, Suzuki, On Wed, May 06, 2020 at 10:17:15AM +0100, Suzuki Kuruppassery Poulose wrote: > On 05/05/2020 05:00 PM, Al Grant wrote: > > > > The patch below does the kernel and userspace side but is not complete. > > > > The problem is that userspace perf creates the metadata copy of > > > > TRCCONFIGR based on its request (and fills in the other id registers > > > > by reading sysfs), but the detection of EL2/E2H happens in the kernel > > > > which adjusts TRCCONFIGR, and it's this config which is needed for decode. I > > > see three ways round this: > > > > > > > > - have userspace test to see if the kernel is EL2 (somehow) and adjust > > > > the metadata to mirror what the kernel is doing > > > > > > > > - have the kernel pass the adjusted TRCCONFIGR back so perf can put it > > > > in the metadata > > > > > > > > - have the perf decoder get the thread id from whichever of VMID and > > > > CONTEXTID is available in a PE_CONTEXT element > > > > > > > > Obviously, the last is simplest, but it's a bodge, and means that > > > > OpenCSD will see VMIDs when its TRCCONFIGR says it won't. It's kind of > > > > cleanest to get the real TRCCONFIGR somehow, but how do we do that? > > > > > > We do get TRCCONFIGR in the perf records. We should simply make sure we get > > > the uptodate value (wherever we are getting it from). > > > > The copy in PERF_RECORD_AUXINFO (which is a synthetic record created > > by userspace perf) is, I believe, as I said: > > > > "userspace perf creates the metadata copy of TRCCONFIGR based on > > its request". > > > > So if the kernel modifies it based on information only the kernel knows, > > there's no current way to get the actual value. That was what I was trying > > to address with my suggestions. > > > > Have I missed some place the actual TRCCONFIGR is already being returned > > in other perf records? > > The sysfs is one place where we could expose this and this could be then > consumed by the perf tool while creating the TRCCONFIGR. Since the EL > can't change, this could be a onetime probe activity.
I'm joining this thread on the late and as such don't have all the context. But sysfs is never a good place to export run-time configuration registers as there could be multiple perf sessions active at the same time. This isn't a big issue for N:1 topologies but very real for 1:1.
I don't see how this affected by the sink topology, as this is an ETM configuration.
By sysfs, I mean, not necessarily under /sys/bus/coreight/.../etmN/
but, under :
/sys/bus/event_source/.../cs_etm/
We already expose various different information there. e.g, nr_addr_filters, sinks/
So we could expose something like :
trcconfigr/
and could describe how each of the individual event configs affect the TRCCONFIGR register. So that the perf tool can construct the TRCCONFIGR register from scratch just by looking at the trcconfigr directory.
e.g,
# cd /sys/bus/event_source/devices/cs_etm/ # for f in $(find format -type f); do echo $(basename $f) - $(cat $f); done cycacc - config:12 sinkid - config2:0-31 contextid - config:14 retstack - config:29 timestamp - config:28
$ for f in $(find trcconfigr -type f); do echo $(basename $f) - $(cat $f); done cycacc - 0x10 // Bit 4 timestamp - 0x800 // Bit 11 contextid - 0x8080 // Bit15 | Bit 7 On EL2 kernels - 0x40 // Bit 6 on EL1 kernels retstack - 0x1000 // Bit12
So those are configurations that apply to specific trace sessions. When dealing with concurrent trace sessions there is no way to guarantee the information exported to sysfs applies to the trace session that would read the information.
I think there is a bit of confusion here; The idea is the perf tool will construct the value of the traceconfigr based on the "options" selected by the user, just like it does now for "config1"/"config2"
i.e,
perf record -e cs_etm/cycacc,timestamp/ blah-blah
perf tool will :
map cycacc -> config1 |= BIT(12) and trcconfigr |= BIT($cat /sys/.../trcconfigr/cycacc)
and similarly for all the options. The values under the "trcconfigr" are static and only maps a given attribute to the traceconfig register bit.
Thus, any session can create the TRCCONFIGR accurately based on the events now, by dynamically looking up under the sysfs, rather than "compile time" static assumption of the the ETM model.
So how does this work when I copy the captured data off my target and try to decode offline?
Just like it works now. There is no change in flow for the perf tool. The only difference, how the perf tool would emit the TRCCONFIGR values in the perf.data samples. Instead of assuming that perf_event.attr.config1.CID => TRCCONFIGR[bit6], use the sysfs exported values to figure out the TRCCONFIGR setting.
Suzuki