Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753783Ab3JVPBh (ORCPT ); Tue, 22 Oct 2013 11:01:37 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:59899 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753081Ab3JVPBf (ORCPT ); Tue, 22 Oct 2013 11:01:35 -0400 Subject: [PATCH v4 2/3] x86, apic: Add disable_cpu_apicid kernel parameter To: hpa@linux.intel.com, ebiederm@xmission.com, vgoyal@redhat.com From: HATAYAMA Daisuke Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, bp@alien8.de, akpm@linux-foundation.org, fengguang.wu@intel.com, jingbai.ma@hp.com Date: Wed, 23 Oct 2013 00:01:29 +0900 Message-ID: <20131022150129.24240.4607.stgit@localhost6.localdomain6> In-Reply-To: <20131022150015.24240.39686.stgit@localhost6.localdomain6> References: <20131022150015.24240.39686.stgit@localhost6.localdomain6> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3065 Lines: 85 Add disable_cpu_apicid kernel parameter. To use this kernel parameter, specify an initial APIC ID of the corresponding CPU you want to disable. This is mostly used for the kdump 2nd kernel to disable BSP to wake up multiple CPUs without causing system reset or hang due to sending INIT from AP to BSP. Kdump users first figure out initial APIC ID of the BSP, CPU0 in the 1st kernel, for example from /proc/cpuinfo and then set up this kernel parameter for the 2nd kernel using the obtained APIC ID. This design is more flexible than disabling BSP in kernel boot time automatically in that in kernel boot time we have no choice but referring to ACPI/MP table to obtain initial APIC ID for BSP, meaning that the method is not applicable to the systems without such BIOS tables. This is designed based on the assumption that users get initial APIC ID of the BSP in still healthy state and so BSP is uniquely kept in CPU0; so through this kernel parameter, only one initial APIC ID can be specified. Signed-off-by: HATAYAMA Daisuke --- arch/x86/kernel/apic/apic.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index a7eb82d..8cc4180 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -74,6 +74,13 @@ unsigned int max_physical_apicid; physid_mask_t phys_cpu_present_map; /* + * Processor to be disabled specified by kernel parameter + * disable_cpu_apicid=, mostly used for the kdump 2nd kernel to + * avoid undefined behaviour caused by sending INIT from AP to BSP. + */ +unsigned int disabled_cpu_apicid = BAD_APICID; + +/* * Map cpu index to physical APIC ID */ DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID); @@ -2113,6 +2120,19 @@ void generic_processor_info(int apicid, int version) bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map); + if (disabled_cpu_apicid != BAD_APICID && + disabled_cpu_apicid != boot_cpu_physical_apicid && + disabled_cpu_apicid == apicid) { + int thiscpu = num_processors + disabled_cpus; + + pr_warning("ACPI: Disable specified CPU." + " Processor %d/0x%x ignored.\n", + thiscpu, apicid); + + disabled_cpus++; + return; + } + /* * If boot cpu has not been detected yet, then only allow upto * nr_cpu_ids - 1 processors and keep one slot free for boot cpu @@ -2589,3 +2609,12 @@ static int __init lapic_insert_resource(void) * that is using request_resource */ late_initcall(lapic_insert_resource); + +static int __init apic_set_disabled_cpu_apicid(char *arg) +{ + if (!arg || !get_option(&arg, &disabled_cpu_apicid)) + return -EINVAL; + + return 0; +} +early_param("disable_cpu_apicid", apic_set_disabled_cpu_apicid); -- 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/