From patchwork Mon Nov 26 10:20:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 1801631 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 838763FC54 for ; Mon, 26 Nov 2012 10:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755048Ab2KZKvk (ORCPT ); Mon, 26 Nov 2012 05:51:40 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:41240 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754643Ab2KZKtv (ORCPT ); Mon, 26 Nov 2012 05:49:51 -0500 X-IronPort-AV: E=Sophos;i="4.83,320,1352044800"; d="scan'208";a="6277341" 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 qAQAE1QW012892; Mon, 26 Nov 2012 18:14:03 +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 2012112618133527-63622 ; 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 4/5] cpu-hotplug, memory-hotplug: clear cpu_to_node() when offlining the node Date: Mon, 26 Nov 2012 18:20:26 +0800 Message-Id: <1353925227-1877-5-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:40, Serialize complete at 2012/11/26 18:13:40 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When the node is offlined, there is no memory/cpu on the node. If a sleep task runs on a cpu of this node, it will be migrated to the cpu on the other node. So we can clear cpu-to-node mapping. 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 --- mm/memory_hotplug.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b7c30bb..5ae86d7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1669,6 +1669,34 @@ static int check_cpu_on_node(void *data) return 0; } +static void unmap_cpu_on_node(void *data) +{ +#ifdef CONFIG_ACPI_NUMA + struct pglist_data *pgdat = data; + int cpu; + + for_each_possible_cpu(cpu) + if (cpu_to_node(cpu) == pgdat->node_id) + numa_clear_node(cpu); +#endif +} + +static int check_and_unmap_cpu_on_node(void *data) +{ + int ret = check_cpu_on_node(data); + + if (ret) + return ret; + + /* + * the node will be offlined when we come here, so we can clear + * the cpu_to_node() now. + */ + + unmap_cpu_on_node(data); + return 0; +} + /* offline the node if all memory sections of this node are removed */ void try_offline_node(int nid) { @@ -1695,7 +1723,7 @@ void try_offline_node(int nid) return; } - if (stop_machine(check_cpu_on_node, NODE_DATA(nid), NULL)) + if (stop_machine(check_and_unmap_cpu_on_node, NODE_DATA(nid), NULL)) return; /*