[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51D26F57.8030400@linux.vnet.ibm.com>
Date: Tue, 02 Jul 2013 11:42:39 +0530
From: "Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To: James Hogan <james.hogan@...tec.com>
CC: linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 3/5] metag: smp: don't spin waiting for CPU to start
On 07/01/2013 09:34 PM, James Hogan wrote:
> Use a completion to block until a secondary CPU has started up, like ARM
> do, instead of a loop of udelays.
>
> On Meta, SMP is really SMT, with each "CPU" being a different hardware
> thread on the same Meta processor core, so as well as being more
> efficient and latency friendly, using a completion prevents the bogomips
> of the secondary CPU from being drastically skewed every time by the
> execution of the tight in-cache udelay loop on the other CPU.
>
> Signed-off-by: James Hogan <james.hogan@...tec.com>
> Cc: "Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> ---
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
Regards,
Srivatsa S. Bhat
> arch/metag/kernel/smp.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c
> index 09979f2..e413875 100644
> --- a/arch/metag/kernel/smp.c
> +++ b/arch/metag/kernel/smp.c
> @@ -8,6 +8,7 @@
> * published by the Free Software Foundation.
> */
> #include <linux/atomic.h>
> +#include <linux/completion.h>
> #include <linux/delay.h>
> #include <linux/init.h>
> #include <linux/spinlock.h>
> @@ -62,6 +63,8 @@ static DEFINE_PER_CPU(struct ipi_data, ipi_data) = {
>
> static DEFINE_SPINLOCK(boot_lock);
>
> +static DECLARE_COMPLETION(cpu_running);
> +
> /*
> * "thread" is assumed to be a valid Meta hardware thread ID.
> */
> @@ -235,20 +238,12 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
> */
> ret = boot_secondary(thread, 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))
> ret = -EIO;
> @@ -391,6 +386,7 @@ asmlinkage void secondary_start_kernel(void)
> * OK, now it's safe to let the boot CPU continue
> */
> set_cpu_online(cpu, true);
> + complete(&cpu_running);
>
> /*
> * Enable local interrupts.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists