Skip to content

Commit

Permalink
ARM: SMP: use a timing out completion for cpu hotplug
Browse files Browse the repository at this point in the history
    ARM: SMP: use a timing out completion for cpu hotplug

    Rather than open-coding the jiffy-based wait, and polling for the
    secondary CPU to come online, use a completion instead.  This
    removes the need to poll, instead we will be notified when the
    secondary CPU has initialized.

    Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King authored and Gokhan Moral committed Aug 19, 2012
1 parent 73e79f4 commit a1a50d6
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ enum ipi_msg_type {
IPI_CPU_BACKTRACE,
};

static DECLARE_COMPLETION(cpu_running);

int __cpuinit __cpu_up(unsigned int cpu)
{
struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
Expand Down Expand Up @@ -118,20 +120,12 @@ int __cpuinit __cpu_up(unsigned int cpu)
*/
ret = boot_secondary(cpu, idle);
if (ret == 0) {
unsigned long timeout;

/*
* CPU was successfully started, wait for it
* to come online or time out.
*/
timeout = jiffies + HZ;
while (time_before(jiffies, timeout)) {
if (cpu_online(cpu))
break;

udelay(10);
barrier();
}
wait_for_completion_timeout(&cpu_running,
msecs_to_jiffies(1000));

if (!cpu_online(cpu)) {
pr_crit("CPU%u: failed to come online\n", cpu);
Expand Down Expand Up @@ -331,9 +325,10 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
/*
* OK, now it's safe to let the boot CPU continue. Wait for
* the CPU migration code to notice that the CPU is online
* before we continue.
* before we continue - which happens after __cpu_up returns.
*/
set_cpu_online(cpu, true);
complete(&cpu_running);

/*
* Setup the percpu timer for this CPU.
Expand Down

0 comments on commit a1a50d6

Please sign in to comment.