diff mbox series

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

Message ID 20240523155641.2805411-4-yazen.ghannam@amd.com (mailing list archive)
State New, archived
Headers show
Series AMD MCA interrupts rework | expand

Commit Message

Yazen Ghannam May 23, 2024, 3:56 p.m. UTC
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@amd.com>
---
 arch/x86/kernel/cpu/mce/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Borislav Petkov May 24, 2024, 2:53 p.m. UTC | #1
On Thu, May 23, 2024 at 10:56:35AM -0500, Yazen Ghannam wrote:
> 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.

Well, but, every time the function is called, we did poll the banks.
Sure, the count is part of /proc/interrupts but we did poll the banks in
those other cases too. So I think showing an accurate poll number is
actually representing the truth, no matter where it is shown...
Yazen Ghannam June 3, 2024, 2:22 p.m. UTC | #2
On 5/24/24 10:53 AM, Borislav Petkov wrote:
> On Thu, May 23, 2024 at 10:56:35AM -0500, Yazen Ghannam wrote:
>> 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.
> 
> Well, but, every time the function is called, we did poll the banks.
> Sure, the count is part of /proc/interrupts but we did poll the banks in
> those other cases too. So I think showing an accurate poll number is
> actually representing the truth, no matter where it is shown...
> 

Okay, fair enough.

In this case, should we also increment the count in __mc_scan_banks()?

Thanks,
Yazen
Borislav Petkov June 3, 2024, 3:24 p.m. UTC | #3
On Mon, Jun 03, 2024 at 10:22:22AM -0400, Yazen Ghannam wrote:
> In this case, should we also increment the count in __mc_scan_banks()?

Well, that's called only in do_machine_check() and latter's not polling
the banks but called as a result of a #MC exception raised.
diff mbox series

Patch

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