Introduce stop_machine_fail and stop_machine_cpuslocked_fail,
which check if any online CPU in the system is tagged as
a block interference CPU.
If so, returns an error.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
===================================================================
@@ -113,6 +113,9 @@ static inline void print_stop_info(const
*/
int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus);
+
+int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus);
+
/**
* stop_machine_cpuslocked: freeze the machine on all CPUs and run this function
* @fn: the function to run
@@ -124,6 +127,9 @@ int stop_machine(cpu_stop_fn_t fn, void
*/
int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus);
+
+int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus);
+
/**
* stop_core_cpuslocked: - stop all threads on just one core
* @cpu: any cpu in the targeted core
===================================================================
@@ -22,6 +22,7 @@
#include <linux/atomic.h>
#include <linux/nmi.h>
#include <linux/sched/wake_q.h>
+#include <linux/sched/isolation.h>
/*
* Structure to determine completion condition and record errors. May
@@ -619,6 +620,17 @@ int stop_machine_cpuslocked(cpu_stop_fn_
return stop_cpus(cpu_online_mask, multi_cpu_stop, &msdata);
}
+int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data,
+ const struct cpumask *cpus)
+{
+ block_interf_assert_held();
+
+ if (cpumask_intersects(block_interf_cpumask, cpu_online_mask))
+ return -EPERM;
+
+ return stop_machine_cpuslocked(fn, data, cpus);
+}
+
int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
{
int ret;
@@ -631,6 +643,19 @@ int stop_machine(cpu_stop_fn_t fn, void
}
EXPORT_SYMBOL_GPL(stop_machine);
+int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus)
+{
+ int ret;
+
+ /* No CPUs can come up or down during this. */
+ cpus_read_lock();
+ ret = stop_machine_cpuslocked_fail(fn, data, cpus);
+ cpus_read_unlock();
+ return ret;
+}
+EXPORT_SYMBOL_GPL(stop_machine_fail);
+
+
#ifdef CONFIG_SCHED_SMT
int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data)
{