[PATCH] perf/x86/amd: Avoid double-decrementing n_pair on failed transactions
From: Zhao Gongyi
Date: Mon Nov 09 2026 - 06:22:35 EST
On a failed PERF_PMU_TXN_ADD commit, x86_schedule_events() releases
constraints for newly added pair events. The AMD put callback decrements
n_pair, and x86_pmu_cancel_txn() then subtracts n_txn_pair for the same
events. This undercounts active pairs and overstates the GP counter budget
for later scheduling.
Leave transaction rollback to x86_pmu_cancel_txn(). Keep the AMD
decrement for constraint releases outside transactions.
Fixes: 871a93b0aad6 ("perf/x86: Fix n_pair for cancelled txn")
Signed-off-by: Zhao Gongyi <zhaogongyi@xxxxxxxxxxxxx>
---
arch/x86/events/amd/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 49b6b8fce..3363cfd3b 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -1251,7 +1251,8 @@ static void amd_put_event_constraints_f17h(struct cpu_hw_events *cpuc,
{
struct hw_perf_event *hwc = &event->hw;
- if (is_counter_pair(hwc))
+ if (is_counter_pair(hwc) &&
+ !(cpuc->txn_flags & PERF_PMU_TXN_ADD))
--cpuc->n_pair;
}
base-commit: f5a78ecccd98a04c47cea1cd63c2a2fdce8a4b48
--
2.39.5 (Apple Git-154)