From patchwork Tue Oct 1 09:54:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Zhang X-Patchwork-Id: 2969141 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF347BFF0B for ; Tue, 1 Oct 2013 09:55:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F88B203EB for ; Tue, 1 Oct 2013 09:55:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BBC8203DB for ; Tue, 1 Oct 2013 09:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753300Ab3JAJzG (ORCPT ); Tue, 1 Oct 2013 05:55:06 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:57234 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752995Ab3JAJzE (ORCPT ); Tue, 1 Oct 2013 05:55:04 -0400 X-IronPort-AV: E=Sophos;i="4.90,1013,1371052800"; d="scan'208";a="8662842" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 01 Oct 2013 17:51:47 +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 r919t0Le013836; Tue, 1 Oct 2013 17:55:00 +0800 Received: from [10.167.226.121] ([10.167.226.121]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013100117530802-1917226 ; Tue, 1 Oct 2013 17:53:08 +0800 Message-ID: <524A9BBF.3060305@cn.fujitsu.com> Date: Tue, 01 Oct 2013 17:54:07 +0800 From: Zhang Yanfei User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: robert.moore@intel.com, lv.zheng@intel.com, "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Tejun Heo , Thomas Renninger , Yinghai Lu , Jiang Liu , Wen Congyang , Lai Jiangshan , Yasuaki Ishimatsu , Taku Izumi , Mel Gorman , Minchan Kim , "mina86@mina86.com" , gong.chen@linux.intel.com, vasilis.liaskovitis@profitbricks.com, Rik van Riel , prarit@redhat.com, Toshi Kani CC: Zhang Yanfei , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Linux MM , linux-acpi@vger.kernel.org, Tang Chen , imtangchen@gmail.com, Zhang Yanfei Subject: [PATCH -mm 5/8] acpi, numa, mem_hotplug: Mark hotpluggable memory in memblock References: <524A991D.3050005@cn.fujitsu.com> In-Reply-To: <524A991D.3050005@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/10/01 17:53:08, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/10/01 17:53:09, Serialize complete at 2013/10/01 17:53:09 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tang Chen When parsing SRAT, we know that which memory area is hotpluggable. So we invoke function memblock_mark_hotplug() introduced by previous patch to mark hotpluggable memory in memblock. Besides, move setting back to top-down allocation just right after we mark hotpluggable memory in memblock. Signed-off-by: Tang Chen Signed-off-by: Zhang Yanfei --- arch/x86/kernel/setup.c | 7 ------- arch/x86/mm/numa.c | 2 ++ arch/x86/mm/srat.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index b8fefb7..36cfce3 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1132,13 +1132,6 @@ void __init setup_arch(char **cmdline_p) early_acpi_boot_init(); initmem_init(); - - /* - * When ACPI SRAT is parsed, which is done in initmem_init(), - * set memblock back to the top-down direction. - */ - memblock_set_bottom_up(false); - memblock_find_dma_reserve(); /* diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index ac4ea06..ef9130d 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -569,6 +569,8 @@ static int __init numa_init(int (*init_func)(void)) memset(&numa_meminfo, 0, sizeof(numa_meminfo)); WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory, MAX_NUMNODES)); + /* In case that parsing SRAT failed. */ + WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX)); numa_reset_distance(); ret = init_func(); diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c index 266ca91..246739c 100644 --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -181,6 +181,11 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) (unsigned long long) start, (unsigned long long) end - 1, hotpluggable ? " hotplug" : ""); + /* Mark hotplug range in memblock. */ + if (hotpluggable && memblock_mark_hotplug(start, ma->length)) + pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n", + (unsigned long long) start, (unsigned long long) end - 1); + return 0; out_err_bad_srat: bad_srat(); @@ -197,5 +202,13 @@ int __init x86_acpi_numa_init(void) ret = acpi_numa_init(); if (ret < 0) return ret; + + /* + * When ACPI SRAT is parsed, and hotpluggable range in + * memblock is marked, set memblock back to the top-down + * direction. + */ + memblock_set_bottom_up(false); + return srat_disabled() ? -EINVAL : 0; }