Skip to content

Commit

Permalink
cpu/hotplug: Move bringup of secondary CPUs out of smp_init()
Browse files Browse the repository at this point in the history
This is the last direct user of cpu_up() before it can become an internal
implementation detail of the cpu subsystem.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200323135110.30522-17-qais.yousef@arm.com
  • Loading branch information
Qais Yousef authored and Thomas Gleixner committed Mar 25, 2020
1 parent 457bc8e commit b99a265
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/linux/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void notify_cpu_starting(unsigned int cpu);
extern void cpu_maps_update_begin(void);
extern void cpu_maps_update_done(void);
int bringup_hibernate_cpu(unsigned int sleep_cpu);
void bringup_nonboot_cpus(unsigned int setup_max_cpus);

#else /* CONFIG_SMP */
#define cpuhp_tasks_frozen 0
Expand Down
12 changes: 12 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,18 @@ int bringup_hibernate_cpu(unsigned int sleep_cpu)
return 0;
}

void bringup_nonboot_cpus(unsigned int setup_max_cpus)
{
unsigned int cpu;

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;

Expand Down
9 changes: 1 addition & 8 deletions kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,20 +597,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);
}
bringup_nonboot_cpus(setup_max_cpus);

num_nodes = num_online_nodes();
num_cpus = num_online_cpus();
Expand Down

0 comments on commit b99a265

Please sign in to comment.