Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753305Ab0ALMK7 (ORCPT ); Tue, 12 Jan 2010 07:10:59 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751949Ab0ALMK2 (ORCPT ); Tue, 12 Jan 2010 07:10:28 -0500 Received: from sca-es-mail-1.Sun.COM ([192.18.43.132]:48327 "EHLO sca-es-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932067Ab0ALMK1 (ORCPT ); Tue, 12 Jan 2010 07:10:27 -0500 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Date: Tue, 12 Jan 2010 04:09:04 -0800 From: Yinghai Lu Subject: [RFC PATCH -v2 4/5] x86: according to nr_cpu_ids to decide if need to leave logical flat In-reply-to: <1263298146-25597-1-git-send-email-yinghai@kernel.org> To: Suresh Siddha , Linus Torvalds , "ananth@in.ibm.com" , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton Cc: linux-kernel@vger.kernel.org, Yinghai Lu Message-id: <1263298146-25597-3-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.6.4.2 References: <1263298146-25597-1-git-send-email-yinghai@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3661 Lines: 110 should use nr_cpu_ids instead of num_processor, in case we have hotplug cpus. if current only have 8 cpus is up, but if we will have more cpus that will be hot added later, we should use physical flat at first. nr_cpu_ids is the total cpus that could be supported. -v2: per linus, chenage default_setup_apic_routing to _init, and call it for uni_processor Signed-off-by: Yinghai Lu --- arch/x86/kernel/apic/apic.c | 2 -- arch/x86/kernel/apic/probe_32.c | 20 ++++++++++++++++++-- arch/x86/kernel/apic/probe_64.c | 3 ++- arch/x86/kernel/smpboot.c | 2 -- 4 files changed, 20 insertions(+), 7 deletions(-) Index: linux-2.6/arch/x86/kernel/apic/probe_32.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/apic/probe_32.c +++ linux-2.6/arch/x86/kernel/apic/probe_32.c @@ -52,7 +52,7 @@ static int __init print_ipi_mode(void) } late_initcall(print_ipi_mode); -void default_setup_apic_routing(void) +static void local_default_setup_apic_routing(void) { #ifdef CONFIG_X86_IO_APIC printk(KERN_INFO @@ -103,7 +103,7 @@ struct apic apic_default = { .init_apic_ldr = default_init_apic_ldr, .ioapic_phys_id_map = default_ioapic_phys_id_map, - .setup_apic_routing = default_setup_apic_routing, + .setup_apic_routing = local_default_setup_apic_routing, .multi_timer_check = NULL, .apicid_to_node = default_apicid_to_node, .cpu_to_logical_apicid = default_cpu_to_logical_apicid, @@ -207,6 +207,22 @@ void __init generic_bigsmp_probe(void) apic = &apic_bigsmp; printk(KERN_INFO "Overriding APIC driver with %s\n", apic->name); + } + } +#endif +} + +void __init default_setup_apic_routing(void) +{ +#ifdef CONFIG_X86_BIGSMP + /* + * make sure we go to bigsmp according to real nr_cpu_ids + */ + if (!cmdline_apic && apic == &apic_default) { + if (nr_cpu_ids > 8) { + apic = &apic_bigsmp; + printk(KERN_INFO "Overriding APIC driver with %s\n", + apic->name); } } #endif Index: linux-2.6/arch/x86/kernel/smpboot.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/smpboot.c +++ linux-2.6/arch/x86/kernel/smpboot.c @@ -1084,9 +1084,7 @@ void __init native_smp_prepare_cpus(unsi set_cpu_sibling_map(0); enable_IR_x2apic(); -#ifdef CONFIG_X86_64 default_setup_apic_routing(); -#endif if (smp_sanity_check(max_cpus) < 0) { printk(KERN_INFO "SMP disabled\n"); Index: linux-2.6/arch/x86/kernel/apic/probe_64.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/apic/probe_64.c +++ linux-2.6/arch/x86/kernel/apic/probe_64.c @@ -67,7 +67,8 @@ void __init default_setup_apic_routing(v } #endif - if (apic == &apic_flat && num_processors > 8) + /* not just num_processors, we could have hotplug cpus */ + if (apic == &apic_flat && nr_cpu_ids > 8) apic = &apic_physflat; printk(KERN_INFO "Setting APIC routing to %s\n", apic->name); Index: linux-2.6/arch/x86/kernel/apic/apic.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/apic/apic.c +++ linux-2.6/arch/x86/kernel/apic/apic.c @@ -1647,9 +1647,7 @@ int __init APIC_init_uniprocessor(void) #endif enable_IR_x2apic(); -#ifdef CONFIG_X86_64 default_setup_apic_routing(); -#endif verify_local_APIC(); connect_bsp_APIC(); -- 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/