Re: Questions on HPMs

Greg Favor

On Fri, Oct 29, 2021 at 9:13 AM Beeman Strong <beeman@...> wrote:
You just beat me, I had a mail to the same effect in progress.  For instructions I agree that events, like instret, should be based on the originating PL. 

Exactly.  Even if the after-effect of an instruction is to establish a new execution context for the target or next instruction, the instruction itself is considered as being fetched/decoded/executed in its starting context (privilege mode, translation context, etc.).
Other uarch events, like cycles or stalls, will naturally depend on implementation but ideally would be associated with the originating PL as much as possible.

Agreed.  For some events this would be straightforward; for others it will be fuzzier or not possible.  There are many types of uarch events that are hard or not possible to clearly associate with a causative instruction and hence a PL (or even with just a causative PL for some types of events).
From an implementation perspective, the best approach would seem to be to increment most non-uarch events (like instret) at retire, using the PL at retire.  xRET will require special treatment, to increment events before the PL change.

ARM and its attempt at standardizing arch (and uarch) events explicitly acknowledges that there are ones that cannot be required across all implementations to be non-speculative - and hence ARM allows an implementation to implement either a speculative or non-speculative version of the defined event.


Join { to automatically receive all group messages.