transactionscpuinteltransactional-memoryintel-tsx

How to know Intel TSX is currently used by other process?


Is there a way to know if a transaction is being processed using Intel TSX from another process/program?

Say, if I want to monitor the behavior of Intel TSX from an application. Is it possible to do so?


Solution

  • TSX transactions are very short, and don't have any sign that's visible to other CPUs. It's basically all internal to the CPU core, with the effect being how / when / what it responds to MESI requests to share cache lines. The timing effects are probably indistinguishable from ordinary contention.

    Over a somewhat longer timescale, another process could use HW performance counter (e.g. via Linux perf_event_open) to track TSX activity, such as rtm_retired.start and rtm_retired.commit to count the number of transactions started and committed. (There are similar events for HLE, but HLE unfortunately seems to be gone due to microcode updates and not even optionally enableable.)

    Most of the perf events for TSX are about aborts and things that might cause aborts, since that's something you'd want to look for when profiling an application you already know uses TSX.