Remove duplicate definitions from arm64/riscv, add unified
implementation in smp.h.
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
arch/arm64/kernel/smp.c | 11 -----------
arch/riscv/kernel/smp.c | 11 -----------
include/linux/smp.h | 11 +++++++++++
3 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 68cea3a4a35ca..2d1e7839dc9b0 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -1171,17 +1171,6 @@ void tick_broadcast(const struct cpumask *mask)
}
#endif
-/*
- * The number of CPUs online, not counting this CPU (which may not be
- * fully online and so not counted in num_online_cpus()).
- */
-static inline unsigned int num_other_online_cpus(void)
-{
- unsigned int this_cpu_online = cpu_online(smp_processor_id());
-
- return num_online_cpus() - this_cpu_online;
-}
-
void smp_send_stop(void)
{
static unsigned long stop_in_progress;
diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index 9dbcb9a06a96d..669325e68a21a 100644
--- a/arch/riscv/kernel/smp.c
+++ b/arch/riscv/kernel/smp.c
@@ -272,17 +272,6 @@ void smp_send_stop(void)
}
#ifdef CONFIG_KEXEC_CORE
-/*
- * The number of CPUs online, not counting this CPU (which may not be
- * fully online and so not counted in num_online_cpus()).
- */
-static inline unsigned int num_other_online_cpus(void)
-{
- unsigned int this_cpu_online = cpu_online(smp_processor_id());
-
- return num_online_cpus() - this_cpu_online;
-}
-
void crash_smp_send_stop(void)
{
static int cpus_stopped;
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 18e9c918325e5..5300c5c14232b 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -275,6 +275,17 @@ static inline int get_boot_cpu_id(void)
#define get_cpu() ({ preempt_disable(); __smp_processor_id(); })
#define put_cpu() preempt_enable()
+/*
+ * The number of CPUs online, not counting this CPU (which may not be
+ * fully online and so not counted in num_online_cpus()).
+ */
+static inline unsigned int num_other_online_cpus(void)
+{
+ unsigned int this_cpu_online = cpu_online(smp_processor_id());
+
+ return num_online_cpus() - this_cpu_online;
+}
+
/*
* Callback to arch code if there's nosmp or maxcpus=0 on the
* boot command line:
--
2.39.5