[PATCH 3/9] x86/mce: Increment MCP count only for timer calls

From: Yazen Ghannam
Date: Thu May 23 2024 - 11:58:11 EST


MCP count is currently incremented for any call to machine_check_poll().
Therefore, the count includes calls from the timer, boot-time polling,
and interrupt handlers.

Only increment the MCP count when called from the timer so as to avoid
double counting the interrupt handlers.

Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
arch/x86/kernel/cpu/mce/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 287108de210e..70c8df1a766a 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -683,8 +683,6 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
struct mce m;
int i;

- this_cpu_inc(mce_poll_count);
-
mce_gather_info(&m, NULL);

if (flags & MCP_TIMESTAMP)
@@ -1667,8 +1665,10 @@ static void mce_timer_fn(struct timer_list *t)

iv = __this_cpu_read(mce_next_interval);

- if (mce_available(this_cpu_ptr(&cpu_info)))
+ if (mce_available(this_cpu_ptr(&cpu_info))) {
+ this_cpu_inc(mce_poll_count);
mc_poll_banks();
+ }

/*
* Alert userspace if needed. If we logged an MCE, reduce the polling
--
2.34.1