On 09/16/2020 10:58 AM, Al Grant wrote:
Option 1: Trace Config exposed matching the format name:
$ pwd /sys/bus/event_source/devices/cs_etm
$ ls trace_config/ contextid cycacc retstack timestamp cs_etm# for f in $(find trace_config -type f) do echo $(basename $f) : $(cat $f) done
timestamp : 0x800 contextid : 0x40 cycacc : 0x10 retstack : 0x1000
Disadvantages : It is really tricky for the perf tool figure out the name of the "config" option from the event->attr.config bits. As the parsing of the format is not exported elsewhere (or I didn't look deep enough)
I don't like this. TRCCONFIG is a dynamic register whose value at any given time is specific to a perf session. Having it exposed in sysfs means that sysfs
Right, we are not exposing the TRCCONFIG for the *current session* (irrespective of what is running). This is a way for the perf tool to compute the TRCCONFIGR for a given event. The tool will consult the exposed files to construct the TRCCONFIGR (see the code below for e.g,). None of the values exposed are complete TRCCONFIGR values anyways.
now exposes data about any number of perf sessions, just so that each instance of "perf record" can read data about its own session - and hopefully read the right data at the right time. It might work but it's not very clean.
Option 2: Trace Config exposed as the "bit" positions.
$ ls trace_config/ 12 14 28 29
$ for f in $(find . -type f) do echo $(basename $f) : $(cat $f) done
28 : 0x800 14 : 0x40 12 : 0x10
29 : 0x1000
Advantage: The perf tool can iterate over the event->attr.config bits and do something like:
trconfigr = 0
for_each_set_bit(i, event->attr.config) trconfigr |= sysfs_read_trace_config(i)
where:
sysfs_read_trace_config(int i) { char path[MAX_LEN]; FILE *fp; unsigned long trcfg = 0;
sprintf(path, "%s/%d", $TRACE_CONFIG_PATH, i); fp = fopen(path, "r"); if (fp) fscanf(fp, "%lx", &trcfg); return trcfg; }
That is how this is going to be consumed. Again, the values exposed are not the ETM current configuration.
Suzuki