|
| 1 | +# yaml-language-server: $schema=../../schemas/ext_schema.json |
| 2 | + |
| 3 | +$schema: "ext_schema.json#" |
| 4 | +kind: extension |
| 5 | +name: Smctr |
| 6 | +long_name: Control Transfer Records |
| 7 | +description: | |
| 8 | + A method for recording control flow transfer history is valuable not only for performance |
| 9 | + profiling but also for debugging. |
| 10 | + Control flow transfers refer to jump instructions (including function calls and returns), taken |
| 11 | + branch instructions, traps, and trap returns. |
| 12 | + Profiling tools, such as Linux perf, collect control transfer history when sampling software |
| 13 | + execution, thereby enabling tools, like AutoFDO, to identify hot paths for optimization. |
| 14 | +
|
| 15 | + Control flow trace capabilities offer very deep transfer history, but the volume of data produced |
| 16 | + can result in significant performance overheads due to memory bandwidth consumption, buffer |
| 17 | + management, and decoder overhead. |
| 18 | + The Control Transfer Records (CTR) extension provides a method to record a limited history in |
| 19 | + register-accessible internal chip storage, with the intent of dramatically reducing the |
| 20 | + performance overhead and complexity of collecting transfer history. |
| 21 | +
|
| 22 | + CTR defines a circular (FIFO) buffer. Each buffer entry holds a record for a single recorded |
| 23 | + control flow transfer. |
| 24 | + The number of records that can be held in the buffer depends upon both the implementation (the |
| 25 | + maximum supported depth) and the CTR configuration (the software selected depth). |
| 26 | +
|
| 27 | + Only qualified transfers are recorded. |
| 28 | + Qualified transfers are those that meet the filtering criteria, which include the privilege mode |
| 29 | + and the transfer type. |
| 30 | +
|
| 31 | + Recorded transfers are inserted at the write pointer, which is then incremented, while older |
| 32 | + recorded transfers may be overwritten once the buffer is full. |
| 33 | + Or the user can enable RAS (Return Address Stack) emulation mode, where only function calls are |
| 34 | + recorded, and function returns pop the last call record. |
| 35 | + The source PC, target PC, and some optional metadata (transfer type, elapsed cycles) are stored |
| 36 | + for each recorded transfer. |
| 37 | +
|
| 38 | + The CTR buffer is accessible through an indirect CSR interface, such that software can specify |
| 39 | + which logical entry in the buffer it wishes to read or write. |
| 40 | + Logical entry 0 always corresponds to the youngest recorded transfer, followed by entry 1 as the |
| 41 | + next youngest, and so on. |
| 42 | +type: privileged |
| 43 | +versions: |
| 44 | + - version: "1.0.0" |
| 45 | + state: ratified |
| 46 | + ratification_date: 2024-11 |
| 47 | + implies: |
| 48 | + - if: S |
| 49 | + then: |
| 50 | + name: Ssctr |
| 51 | + version: "1.0.0" |
0 commit comments