Skip to content

Commit de20037

Browse files
leitaoPeter Zijlstra
authored andcommitted
perf/x86/amd: Warn only on new bits set
Warning at every leaking bits can cause a flood of message, triggering various stall-warning mechanisms to fire, including CSD locks, which makes the machine to be unusable. Track the bits that are being leaked, and only warn when a new bit is set. That said, this patch will help with the following issues: 1) It will tell us which bits are being set, so, it is easy to communicate it back to vendor, and to do a root-cause analyzes. 2) It avoid the machine to be unusable, because, worst case scenario, the user gets less than 60 WARNs (one per unhandled bit). Suggested-by: Paul E. McKenney <[email protected]> Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Sandipan Das <[email protected]> Reviewed-by: Paul E. McKenney <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6c74ca7 commit de20037

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/x86/events/amd/core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,11 +943,12 @@ static int amd_pmu_v2_snapshot_branch_stack(struct perf_branch_entry *entries, u
943943
static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
944944
{
945945
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
946+
static atomic64_t status_warned = ATOMIC64_INIT(0);
947+
u64 reserved, status, mask, new_bits, prev_bits;
946948
struct perf_sample_data data;
947949
struct hw_perf_event *hwc;
948950
struct perf_event *event;
949951
int handled = 0, idx;
950-
u64 reserved, status, mask;
951952
bool pmu_enabled;
952953

953954
/*
@@ -1012,7 +1013,12 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
10121013
* the corresponding PMCs are expected to be inactive according to the
10131014
* active_mask
10141015
*/
1015-
WARN_ON(status > 0);
1016+
if (status > 0) {
1017+
prev_bits = atomic64_fetch_or(status, &status_warned);
1018+
// A new bit was set for the very first time.
1019+
new_bits = status & ~prev_bits;
1020+
WARN(new_bits, "New overflows for inactive PMCs: %llx\n", new_bits);
1021+
}
10161022

10171023
/* Clear overflow and freeze bits */
10181024
amd_pmu_ack_global_status(~status);

0 commit comments

Comments
 (0)