2024-02-06 19:05:24

by Marcelo Tosatti

[permalink] [raw]
Subject: [patch 09/12] AMD MCE: use smp_call_func_single_fail

Convert arch/x86/kernel/cpu/mce/amd.c from smp_call_function_single
to smp_call_func_single_fail, which will fail in case
the target CPU is tagged as block interference CPU.

Signed-off-by: Marcelo Tosatti <[email protected]>

Index: linux-isolation/arch/x86/kernel/cpu/mce/amd.c
===================================================================
--- linux-isolation.orig/arch/x86/kernel/cpu/mce/amd.c
+++ linux-isolation/arch/x86/kernel/cpu/mce/amd.c
@@ -19,6 +19,7 @@
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/string.h>
+#include <linux/sched/isolation.h>

#include <asm/amd_nb.h>
#include <asm/traps.h>
@@ -970,6 +971,7 @@ store_interrupt_enable(struct threshold_
{
struct thresh_restart tr;
unsigned long new;
+ int ret, idx;

if (!b->interrupt_capable)
return -EINVAL;
@@ -982,8 +984,15 @@ store_interrupt_enable(struct threshold_
memset(&tr, 0, sizeof(tr));
tr.b = b;

- if (smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1))
+ idx = block_interf_srcu_read_lock();
+ ret = smp_call_function_single_fail(b->cpu, threshold_restart_bank,
+ &tr, 1);
+ block_interf_srcu_read_unlock(idx);
+ if (ret) {
+ if (ret == -EPERM)
+ return ret;
return -ENODEV;
+ }

return size;
}
@@ -993,6 +1002,7 @@ store_threshold_limit(struct threshold_b
{
struct thresh_restart tr;
unsigned long new;
+ int ret, idx;

if (kstrtoul(buf, 0, &new) < 0)
return -EINVAL;
@@ -1007,8 +1017,14 @@ store_threshold_limit(struct threshold_b
b->threshold_limit = new;
tr.b = b;

- if (smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1))
+ idx = block_interf_srcu_read_lock();
+ ret = smp_call_function_single_fail(b->cpu, threshold_restart_bank, &tr, 1);
+ block_interf_srcu_read_unlock(idx);
+ if (ret) {
+ if (ret == -EPERM)
+ return ret;
return -ENODEV;
+ }

return size;
}