Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755115Ab2JPQ5T (ORCPT ); Tue, 16 Oct 2012 12:57:19 -0400 Received: from mail.skyhub.de ([78.46.96.112]:38542 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754776Ab2JPQ5R (ORCPT ); Tue, 16 Oct 2012 12:57:17 -0400 Date: Tue, 16 Oct 2012 18:57:16 +0200 From: Borislav Petkov To: Fenghua Yu Cc: Ingo Molnar , Thomas Gleixner , H Peter Anvin , Linus Torvalds , Andrew Morton , Asit K Mallick , Tony Luck , Arjan Dan De Ven , Suresh B Siddha , Len Brown , "Srivatssa S. Bhat" , Randy Dunlap , Chen Gong , linux-kernel , linux-pm , x86 Subject: Re: [PATCH v9 08/12] x86, hotplug: Wake up CPU0 via NMI instead of INIT, SIPI, SIPI Message-ID: <20121016165716.GB12694@x1.osrc.amd.com> Mail-Followup-To: Borislav Petkov , Fenghua Yu , Ingo Molnar , Thomas Gleixner , H Peter Anvin , Linus Torvalds , Andrew Morton , Asit K Mallick , Tony Luck , Arjan Dan De Ven , Suresh B Siddha , Len Brown , "Srivatssa S. Bhat" , Randy Dunlap , Chen Gong , linux-kernel , linux-pm , x86 References: <1350058189-6769-1-git-send-email-fenghua.yu@intel.com> <1350058189-6769-9-git-send-email-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1350058189-6769-9-git-send-email-fenghua.yu@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2859 Lines: 82 On Fri, Oct 12, 2012 at 09:09:45AM -0700, Fenghua Yu wrote: > From: Fenghua Yu > > Instead of waiting for STARTUP after INITs, BSP will execute the BIOS boot-strap > code which is not a desired behavior for waking up BSP. To avoid the boot-strap > code, wake up CPU0 by NMI instead. > > This works to wake up soft offlined CPU0 only. If CPU0 is hard offlined (i.e. > physically hot removed and then hot added), NMI won't wake it up. We'll change > this code in the future to wake up hard offlined CPU0 if real platform and > request are available. > > AP is still waken up as before by INIT, SIPI, SIPI sequence. > > Signed-off-by: Fenghua Yu > --- > arch/x86/include/asm/cpu.h | 1 + > arch/x86/kernel/smpboot.c | 112 +++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 107 insertions(+), 6 deletions(-) [ … ] > @@ -727,8 +745,47 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle) > */ > if (apic->wakeup_secondary_cpu) > boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); > - else > - boot_error = wakeup_secondary_cpu_via_init(apicid, start_ip); > + else { > + if (cpu) > + /* > + * Wake up AP by INIT, INIT, STARTUP sequence. > + */ > + boot_error = wakeup_secondary_cpu_via_init(apicid, > + start_ip); > + else { > + /* > + * Instead of waiting for STARTUP after INITs, BSP will > + * execute the BIOS boot-strap code which is not a > + * desired behavior for waking up BSP. To avoid the > + * boot-strap code, wake up CPU0 by NMI instead. > + * > + * This works to wake up soft offlined CPU0 only. If > + * CPU0 is hard offlined (i.e. physically hot removed > + * and then hot added), NMI won't wake it up. We'll > + * change this code in the future to wake up hard > + * offlined CPU0 if real platform and request are > + * available. > + */ > + int id; > + > + enable_start_cpu0 = 1; > + /* > + * Register a NMI handler to help wake up CPU0. > + */ > + boot_error = register_nmi_handler(NMI_LOCAL, > + wakeup_cpu0_nmi, 0, "wake_cpu0"); > + > + if (!boot_error) { > + cpu0_nmi_registered = 1; > + if (apic->dest_logical == APIC_DEST_LOGICAL) > + id = cpu0_logical_apicid; > + else > + id = apicid; > + boot_error = wakeup_secondary_cpu_via_nmi(id, > + start_ip); > + } This whole else-part for cpu 0 could be carved out into a separate function so that you can save yourself the awkward code indentation and make this a lot more readable. Thanks. -- Regards/Gruss, Boris. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/