History

perf: Add generic transaction flags

Add a generic qualifier for transaction events, as a new sample type that returns a flag word. This is particularly useful for qualifying aborts: to distinguish aborts which happen due to asynchronous events (like conflicts caused by another CPU) versus instructions that lead to an abort. The tuning strategies are very different for those cases, so it's important to distinguish them easily and early. Since it's inconvenient and inflexible to filter for this in the kernel we report all the events out and allow some post processing in user space. The flags are based on the Intel TSX events, but should be fairly generic and mostly applicable to other HTM architectures too. In addition to various flag words there's also reserved space to report an program supplied abort code. For TSX this is used to distinguish specific classes of aborts, like a lock busy abort when doing lock elision. Flags: Elision and generic transactions (ELISION vs TRANSACTION) (HLE vs RTM on TSX; IBM etc. would likely only use TRANSACTION) Aborts caused by current thread vs aborts caused by others (SYNC vs ASYNC) Retryable transaction (RETRY) Conflicts with other threads (CONFLICT) Transaction write capacity overflow (CAPACITY WRITE) Transaction read capacity overflow (CAPACITY READ) Transactions implicitely aborted can also return an abort code. This can be used to signal specific events to the profiler. A common case is abort on lock busy in a RTM eliding library (code 0xff) To handle this case we include the TSX abort code Common example aborts in TSX would be: - Data conflict with another thread on memory read. Flags: TRANSACTION|ASYNC|CONFLICT - executing a WRMSR in a transaction. Flags: TRANSACTION|SYNC - HLE transaction in user space is too large Flags: ELISION|SYNC|CAPACITY-WRITE The only flag that is somewhat TSX specific is ELISION. This adds the perf core glue needed for reporting the new flag word out.

Andi Kleen committed 13 years ago

Commit fdfbbd01 parent 4cabc3d3 files · +35 −1Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/perf_event.h+24−1
@@ -136,8 +136,9 @@ enum perf_event_sample_format { · 135 unmodified lines
136136 PERF_SAMPLE_WEIGHT = 1U << 14,
137137 PERF_SAMPLE_DATA_SRC = 1U << 15,
138138 PERF_SAMPLE_IDENTIFIER = 1U << 16,
139+ PERF_SAMPLE_TRANSACTION = 1U << 17,
139140
140− PERF_SAMPLE_MAX = 1U << 17, /* non-ABI */
141+ PERF_SAMPLE_MAX = 1U << 18, /* non-ABI */
141142 };
142143
143144 /*
@@ -180,6 +181,28 @@ enum perf_sample_regs_abi { · 36 unmodified lines
180181 PERF_SAMPLE_REGS_ABI_64 = 2,
181182 };
182183
184+/*
185+ * Values for the memory transaction event qualifier, mostly for
186+ * abort events. Multiple bits can be set.
187+ */
188+enum {
189+ PERF_TXN_ELISION = (1 << 0), /* From elision */
190+ PERF_TXN_TRANSACTION = (1 << 1), /* From transaction */
191+ PERF_TXN_SYNC = (1 << 2), /* Instruction is related */
192+ PERF_TXN_ASYNC = (1 << 3), /* Instruction not related */
193+ PERF_TXN_RETRY = (1 << 4), /* Retry possible */
194+ PERF_TXN_CONFLICT = (1 << 5), /* Conflict abort */
195+ PERF_TXN_CAPACITY_WRITE = (1 << 6), /* Capacity write abort */
196+ PERF_TXN_CAPACITY_READ = (1 << 7), /* Capacity read abort */
197+
198+ PERF_TXN_MAX = (1 << 8), /* non-ABI */
199+
200+ /* bits 32..63 are reserved for the abort code */
201+
202+ PERF_TXN_ABORT_MASK = (0xffffffffULL << 32),
203+ PERF_TXN_ABORT_SHIFT = 32,
204+};
205+
183206 /*
184207 * The format of the data returned by read() on a perf event fd,
185208 * as specified by attr.read_format: