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

Yazen Ghannam posted 9 patches 1 year, 8 months ago
There is a newer version of this series
[PATCH 3/9] x86/mce: Increment MCP count only for timer calls
Posted by Yazen Ghannam 1 year, 8 months ago
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(-)

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
Re: [PATCH 3/9] x86/mce: Increment MCP count only for timer calls
Posted by Borislav Petkov 1 year, 8 months ago
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...

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH 3/9] x86/mce: Increment MCP count only for timer calls
Posted by Yazen Ghannam 1 year, 8 months ago
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
Re: [PATCH 3/9] x86/mce: Increment MCP count only for timer calls
Posted by Borislav Petkov 1 year, 8 months ago
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.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette