[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211104145713.4419-2-laoar.shao@gmail.com>
Date: Thu, 4 Nov 2021 14:57:10 +0000
From: Yafang Shao <laoar.shao@...il.com>
To: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com,
rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
bristot@...hat.com
Cc: linux-kernel@...r.kernel.org, Yafang Shao <laoar.shao@...il.com>,
Valentin Schneider <valentin.schneider@....com>
Subject: [RFC PATCH 1/4] stop_machine: Move cpu_stop_done into stop_machine.h
Move struct cpu_stop_done into the stop_machine.h, then it can be resued
by the functions outside of stop_maichine.c.
Signed-off-by: Yafang Shao <laoar.shao@...il.com>
Cc: Valentin Schneider <valentin.schneider@....com>
Cc: Vincent Guittot <vincent.guittot@...aro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@....com>
---
include/linux/stop_machine.h | 12 ++++++++++++
kernel/stop_machine.c | 14 ++------------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 46fb3ebdd16e..b1234cb6ab70 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -20,6 +20,15 @@
typedef int (*cpu_stop_fn_t)(void *arg);
#ifdef CONFIG_SMP
+/*
+ * Structure to determine completion condition and record errors. May
+ * be shared by works on different cpus.
+ */
+struct cpu_stop_done {
+ atomic_t nr_todo; /* nr left to execute */
+ int ret; /* collected return value */
+ struct completion completion; /* fired if nr_todo reaches 0 */
+};
struct cpu_stop_work {
struct list_head list; /* cpu_stopper->works */
@@ -29,6 +38,9 @@ struct cpu_stop_work {
struct cpu_stop_done *done;
};
+void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo);
+void cpu_stop_signal_done(struct cpu_stop_done *done);
+
int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg);
int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *arg);
bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index cbc30271ea4d..cc94eb7d2c5c 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -23,16 +23,6 @@
#include <linux/nmi.h>
#include <linux/sched/wake_q.h>
-/*
- * Structure to determine completion condition and record errors. May
- * be shared by works on different cpus.
- */
-struct cpu_stop_done {
- atomic_t nr_todo; /* nr left to execute */
- int ret; /* collected return value */
- struct completion completion; /* fired if nr_todo reaches 0 */
-};
-
/* the actual stopper, one per every possible cpu, enabled on online cpus */
struct cpu_stopper {
struct task_struct *thread;
@@ -67,7 +57,7 @@ void print_stop_info(const char *log_lvl, struct task_struct *task)
static DEFINE_MUTEX(stop_cpus_mutex);
static bool stop_cpus_in_progress;
-static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
+void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
{
memset(done, 0, sizeof(*done));
atomic_set(&done->nr_todo, nr_todo);
@@ -75,7 +65,7 @@ static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
}
/* signal completion unless @done is NULL */
-static void cpu_stop_signal_done(struct cpu_stop_done *done)
+void cpu_stop_signal_done(struct cpu_stop_done *done)
{
if (atomic_dec_and_test(&done->nr_todo))
complete(&done->completion);
--
2.17.1
Powered by blists - more mailing lists