Hmm, I was hoping that you would expose all the events as proper perf_events
and get rid of the subevents entirely.
Then userspace could do things like:
// Count number of RX memory reads
$ perf stat -e hisi_pcie0_0/rx_memory_read/
// Count delay cycles
$ perf stat -e hisi_pcie0_0/latency/
// Count both of the above (events must be in the same group)
$ perf stat -g -e hisi_pcie0_0/latency/ -e hisi_pcie0_0/rx_memory_read/
Note that in all three of these cases the hardware will be programmed in
the same way and both HISI_PCIE_CNT and HISI_PCIE_EXT_CNT are allocated!
So for example, doing this (i.e. without the '-g'):
$ perf stat -e hisi_pcie0_0/latency/ -e hisi_pcie0_0/rx_memory_read/
would fail because the first event would allocate both of the counters.
All you need to do is check the counter scheduling constraints when
accepting an event group in the driver. No need for subevents at all.
Does that make sense?
Will
.