[08/12] arm64 kernel/topology: use smp_call_function_single_fail

Message ID 20240206185710.037579553@redhat.com
State New
Headers
Series cpu isolation: infra to block interference to select CPUs |

Commit Message

Marcelo Tosatti Feb. 6, 2024, 6:49 p.m. UTC
  Convert cpu_read_constcnt 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 <mtosatti@redhat.com>
  

Patch

Index: linux-isolation/arch/arm64/kernel/topology.c
===================================================================
--- linux-isolation.orig/arch/arm64/kernel/topology.c
+++ linux-isolation/arch/arm64/kernel/topology.c
@@ -17,6 +17,7 @@ 
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 #include <linux/percpu.h>
+#include <linux/sched/isolation.h>
 
 #include <asm/cpu.h>
 #include <asm/cputype.h>
@@ -280,6 +281,8 @@  static void cpu_read_constcnt(void *val)
 static inline
 int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val)
 {
+	int ret, idx;
+
 	/*
 	 * Abort call on counterless CPU or when interrupts are
 	 * disabled - can lead to deadlock in smp sync call.
@@ -290,7 +293,11 @@  int counters_read_on_cpu(int cpu, smp_ca
 	if (WARN_ON_ONCE(irqs_disabled()))
 		return -EPERM;
 
-	smp_call_function_single(cpu, func, val, 1);
+	idx = block_interf_srcu_read_lock();
+	ret = smp_call_function_single_fail(cpu, func, val, 1);
+	block_interf_srcu_read_unlock(idx);
+	if (ret)
+		return ret;
 
 	return 0;
 }