From patchwork Tue Apr 27 04:57:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: minskey X-Patchwork-Id: 95250 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3R57ZnG004417 for ; Tue, 27 Apr 2010 05:09:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751306Ab0D0FJw (ORCPT ); Tue, 27 Apr 2010 01:09:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:15686 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011Ab0D0FJv (ORCPT ); Tue, 27 Apr 2010 01:09:51 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 26 Apr 2010 22:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.52,277,1270450800"; d="scan'208";a="512756825" Received: from minskey-desktop.bj.intel.com (HELO [172.16.182.160]) ([172.16.182.160]) by orsmga002.jf.intel.com with ESMTP; 26 Apr 2010 22:09:24 -0700 Subject: [PATCH] permit to online CPUs before local memory comes online From: minskey To: linux-acpi@vger.kernel.org Date: Tue, 27 Apr 2010 12:57:44 +0800 Message-ID: <1272344264.28378.3.camel@minskey-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 27 Apr 2010 05:09:53 +0000 (UTC) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 35b07b7..864035f 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -202,6 +202,7 @@ static inline int is_mem_section_removable(unsigned long pfn, } #endif /* CONFIG_MEMORY_HOTREMOVE */ +extern int mem_online_node(int nid); extern int add_memory(int nid, u64 start, u64 size); extern int arch_add_memory(int nid, u64 start, u64 size); extern int remove_memory(u64 start, u64 size); diff --git a/kernel/cpu.c b/kernel/cpu.c index f8cced2..c31b9cb 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -335,6 +335,12 @@ out_notify: int __cpuinit cpu_up(unsigned int cpu) { int err = 0; + +#ifdef CONFIG_MEMORY_HOTPLUG + int nid; + pg_data_t *pgdat; +#endif + if (!cpu_possible(cpu)) { printk(KERN_ERR "can't online cpu %d because it is not " "configured as may-hotadd at boot time\n", cpu); @@ -345,6 +351,26 @@ int __cpuinit cpu_up(unsigned int cpu) return -EINVAL; } +#ifdef CONFIG_MEMORY_HOTPLUG + nid = cpu_to_node(cpu); + if (!node_online(nid)) { + err = mem_online_node(nid); + if (err) + return err; + } + + pgdat = NODE_DATA(nid); + if (!pgdat) { + printk(KERN_ERR + "Can't online cpu %d due to NULL pgdat\n", cpu); + return -ENOMEM; + } + + if (pgdat->node_zonelists->_zonerefs->zone == NULL) { + build_all_zonelists(); + } +#endif + cpu_maps_update_begin(); if (cpu_hotplug_disabled) { diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index be211a5..2d24bef 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -482,6 +482,31 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat) } +/* + * called by cpu_up() to online a node without onlined memory. + */ +int mem_online_node(int nid) +{ + pg_data_t *pgdat; + int ret; + + lock_system_sleep(); + pgdat = hotadd_new_pgdat(nid, 0); + if (pgdat) { + ret = -ENOMEM; + goto out; + } + node_set_online(nid); + ret = register_one_node(nid); + BUG_ON(ret); + +out: + unlock_system_sleep(); + return ret; +} +EXPORT_SYMBOL_GPL(mem_online_node); + + /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ int __ref add_memory(int nid, u64 start, u64 size) {