2019-10-30 15:44:31

by Qais Yousef

[permalink] [raw]
Subject: [PATCH 11/12] smp: Create a new function to bringup nonboot cpus online

This is the last direct user of cpu_up() before we can hide it now as
internal implementation detail of the cpu subsystem.

Signed-off-by: Qais Yousef <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Josh Poimboeuf <[email protected]>
CC: "Peter Zijlstra (Intel)" <[email protected]>
CC: Jiri Kosina <[email protected]>
CC: Nicholas Piggin <[email protected]>
CC: Daniel Lezcano <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Eiichi Tsukata <[email protected]>
CC: Zhenzhong Duan <[email protected]>
CC: Nadav Amit <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: "Rafael J. Wysocki" <[email protected]>
CC: [email protected]
---
include/linux/cpu.h | 1 +
kernel/cpu.c | 13 +++++++++++++
kernel/smp.c | 9 +--------
3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 3b1fbe192989..b1c7b788b8e9 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -88,6 +88,7 @@ void notify_cpu_starting(unsigned int cpu);
extern void cpu_maps_update_begin(void);
extern void cpu_maps_update_done(void);
extern int hibernation_bringup_sleep_cpu(unsigned int sleep_cpu);
+extern void smp_bringup_nonboot_cpus(unsigned int setup_max_cpus);

#else /* CONFIG_SMP */
#define cpuhp_tasks_frozen 0
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 219f9033f438..e16695b841de 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1211,6 +1211,19 @@ int hibernation_bringup_sleep_cpu(unsigned int sleep_cpu)
}
}

+void smp_bringup_nonboot_cpus(unsigned int setup_max_cpus)
+{
+ unsigned int cpu;
+
+ /* FIXME: This should be done in userspace --RR */
+ for_each_present_cpu(cpu) {
+ if (num_online_cpus() >= setup_max_cpus)
+ break;
+ if (!cpu_online(cpu))
+ cpu_up(cpu);
+ }
+}
+
#ifdef CONFIG_PM_SLEEP_SMP
static cpumask_var_t frozen_cpus;

diff --git a/kernel/smp.c b/kernel/smp.c
index 7dbcb402c2fc..74134272b5aa 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -578,20 +578,13 @@ void __init setup_nr_cpu_ids(void)
void __init smp_init(void)
{
int num_nodes, num_cpus;
- unsigned int cpu;

idle_threads_init();
cpuhp_threads_init();

pr_info("Bringing up secondary CPUs ...\n");

- /* FIXME: This should be done in userspace --RR */
- for_each_present_cpu(cpu) {
- if (num_online_cpus() >= setup_max_cpus)
- break;
- if (!cpu_online(cpu))
- cpu_up(cpu);
- }
+ smp_bringup_nonboot_cpus(setup_max_cpus);

num_nodes = num_online_nodes();
num_cpus = num_online_cpus();
--
2.17.1


2019-11-19 22:44:32

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 11/12] smp: Create a new function to bringup nonboot cpus online

On Wed, 30 Oct 2019, Qais Yousef wrote:
> +void smp_bringup_nonboot_cpus(unsigned int setup_max_cpus)
> +{
> + unsigned int cpu;
> +
> + /* FIXME: This should be done in userspace --RR */

This fixme is stale and should just go away.

> + for_each_present_cpu(cpu) {
> + if (num_online_cpus() >= setup_max_cpus)
> + break;
> + if (!cpu_online(cpu))
> + cpu_up(cpu);
> + }
> +}

Thanks,

tglx