[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240206185709.902281455@redhat.com>
Date: Tue, 06 Feb 2024 15:49:14 -0300
From: Marcelo Tosatti <mtosatti@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: Daniel Bristot de Oliveira <bristot@...nel.org>,
Juri Lelli <juri.lelli@...hat.com>,
Valentin Schneider <vschneid@...hat.com>,
Frederic Weisbecker <frederic@...nel.org>,
Leonardo Bras <leobras@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Marcelo Tosatti <mtosatti@...hat.com>
Subject: [patch 03/12] Introduce _fail variants of stop_machine functions
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@...hat.com>
Index: linux-isolation/include/linux/stop_machine.h
===================================================================
--- linux-isolation.orig/include/linux/stop_machine.h
+++ linux-isolation/include/linux/stop_machine.h
@@ -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
Index: linux-isolation/kernel/stop_machine.c
===================================================================
--- linux-isolation.orig/kernel/stop_machine.c
+++ linux-isolation/kernel/stop_machine.c
@@ -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)
{
Powered by blists - more mailing lists