perf/x86/amd/core: Always clear status for idx
authorBreno Leitao <leitao@debian.org>
Tue, 21 Mar 2023 11:33:38 +0000 (04:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Mar 2023 10:49:13 +0000 (12:49 +0200)
commitab33a8f7649b0324639a336e1081aaea51a4523e
treef9275a21c26785b95a6e232ac483edb72966e7ae
parentadfc7aaa0df91e567f8f01f6066f385328d32e86
perf/x86/amd/core: Always clear status for idx

[ Upstream commit 263f5ecaf7080513efc248ec739b6d9e00f4129f ]

The variable 'status' (which contains the unhandled overflow bits) is
not being properly masked in some cases, displaying the following
warning:

  WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270

This seems to be happening because the loop is being continued before
the status bit being unset, in case x86_perf_event_set_period()
returns 0. This is also causing an inconsistency because the "handled"
counter is incremented, but the status bit is not cleaned.

Move the bit cleaning together above, together when the "handled"
counter is incremented.

Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Sandipan Das <sandipan.das@amd.com>
Link: https://lore.kernel.org/r/20230321113338.1669660-1-leitao@debian.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/events/amd/core.c