From patchwork Mon Nov 26 10:20:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 1801561 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F3B1EDF230 for ; Mon, 26 Nov 2012 10:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754921Ab2KZKty (ORCPT ); Mon, 26 Nov 2012 05:49:54 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52169 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754760Ab2KZKtw (ORCPT ); Mon, 26 Nov 2012 05:49:52 -0500 X-IronPort-AV: E=Sophos;i="4.83,320,1352044800"; d="scan'208";a="6277342" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 26 Nov 2012 18:48:04 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id qAQADxOF012889; Mon, 26 Nov 2012 18:14:00 +0800 Received: from ghost.fnst.cn.fujitsu.com ([10.167.225.226]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012112618133520-63620 ; Mon, 26 Nov 2012 18:13:35 +0800 From: Wen Congyang To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, x86@kernel.org Cc: Yasuaki Ishimatsu , David Rientjes , Jiang Liu , Minchan Kim , KOSAKI Motohiro , Andrew Morton , Mel Gorman , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Peter Zijlstra , Tang Chen , "Rafael J. Wysocki" , Len Brown , Lai Jiangshan , Wen Congyang Subject: [PATCH 2/5] memory-hotplug: export the function try_offline_node() Date: Mon, 26 Nov 2012 18:20:24 +0800 Message-Id: <1353925227-1877-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1353925227-1877-1-git-send-email-wency@cn.fujitsu.com> References: <1353925227-1877-1-git-send-email-wency@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/26 18:13:35, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/26 18:13:39, Serialize complete at 2012/11/26 18:13:39 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The node will be offlined when all memory/cpu on the node have been hotremoved. So we need the function try_offline_node() in cpu-hotplug path. If the memory-hotplug is disabled, and cpu-hotplug is enabled 1. no memory no the node we don't online the node, and cpu's node is the nearest node. 2. the node contains some memory the node has been onlined, and cpu's node is still needed to migrate the sleep task on the cpu to the same node. So we do nothing in try_offline_node() in this case. Cc: Yasuaki Ishimatsu Cc: David Rientjes Cc: Jiang Liu Cc: Minchan Kim Cc: KOSAKI Motohiro Cc: Andrew Morton Cc: Mel Gorman Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Peter Zijlstra Cc: Tang Chen Signed-off-by: Wen Congyang --- include/linux/memory_hotplug.h | 2 ++ mm/memory_hotplug.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index ad2dd17..48ece75 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -187,6 +187,7 @@ extern void get_page_bootmem(unsigned long ingo, struct page *page, void lock_memory_hotplug(void); void unlock_memory_hotplug(void); +extern void try_offline_node(int nid); #else /* ! CONFIG_MEMORY_HOTPLUG */ /* @@ -221,6 +222,7 @@ static inline void register_page_bootmem_info_node(struct pglist_data *pgdat) static inline void lock_memory_hotplug(void) {} static inline void unlock_memory_hotplug(void) {} +static inline void try_offline_node(int nid) {} #endif /* ! CONFIG_MEMORY_HOTPLUG */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 52db031..b7c30bb 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1670,7 +1670,7 @@ static int check_cpu_on_node(void *data) } /* offline the node if all memory sections of this node are removed */ -static void try_offline_node(int nid) +void try_offline_node(int nid) { pg_data_t *pgdat = NODE_DATA(nid); unsigned long start_pfn = NODE_DATA(nid)->node_start_pfn; @@ -1720,6 +1720,7 @@ static void try_offline_node(int nid) arch_refresh_nodedata(nid, NULL); arch_free_nodedata(pgdat); } +EXPORT_SYMBOL(try_offline_node); int __ref remove_memory(int nid, u64 start, u64 size) {