From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933921AbcJFSh0 (ORCPT ); Thu, 6 Oct 2016 14:37:26 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47776 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933389AbcJFSgp (ORCPT ); Thu, 6 Oct 2016 14:36:45 -0400 From: Reza Arbab To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Rob Herring , Frank Rowand , Andrew Morton Cc: Bharata B Rao , Nathan Fontenot , Stewart Smith , Alistair Popple , Balbir Singh , "Aneesh Kumar K.V" , Tang Chen , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 4/5] mm: make processing of movable_node arch-specific Date: Thu, 6 Oct 2016 13:36:34 -0500 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1475778995-1420-1-git-send-email-arbab@linux.vnet.ibm.com> References: <1475778995-1420-1-git-send-email-arbab@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16100618-0028-0000-0000-000005C20E4A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005864; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000186; SDB=6.00765136; UDB=6.00365562; IPR=6.00540998; BA=6.00004791; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012897; XFM=3.00000011; UTC=2016-10-06 18:36:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16100618-0029-0000-0000-00002FD3FA52 Message-Id: <1475778995-1420-5-git-send-email-arbab@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-06_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610060324 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, CONFIG_MOVABLE_NODE depends on X86_64. In preparation to enable it for other arches, we need to factor a detail which is unique to x86 out of the generic mm code. Specifically, as documented in kernel-parameters.txt, the use of "movable_node" should remain restricted to x86: movable_node [KNL,X86] Boot-time switch to enable the effects of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details. This option tells x86 to find movable nodes identified by the ACPI SRAT. On other arches, it would have no benefit, only the undesired side effect of setting bottom-up memblock allocation. Since #ifdef CONFIG_MOVABLE_NODE will no longer be enough to restrict this option to x86, move it to an arch-specific compilation unit instead. Signed-off-by: Reza Arbab --- arch/x86/mm/numa.c | 35 ++++++++++++++++++++++++++++++++++- mm/memory_hotplug.c | 31 ------------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index fb68210..e95cab4 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -887,6 +887,38 @@ EXPORT_SYMBOL(cpumask_of_node); #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ #ifdef CONFIG_MEMORY_HOTPLUG + +static int __init cmdline_parse_movable_node(char *p) +{ +#ifdef CONFIG_MOVABLE_NODE + /* + * Memory used by the kernel cannot be hot-removed because Linux + * cannot migrate the kernel pages. When memory hotplug is + * enabled, we should prevent memblock from allocating memory + * for the kernel. + * + * ACPI SRAT records all hotpluggable memory ranges. But before + * SRAT is parsed, we don't know about it. + * + * The kernel image is loaded into memory at very early time. We + * cannot prevent this anyway. So on NUMA system, we set any + * node the kernel resides in as un-hotpluggable. + * + * Since on modern servers, one node could have double-digit + * gigabytes memory, we can assume the memory around the kernel + * image is also un-hotpluggable. So before SRAT is parsed, just + * allocate memory near the kernel image to try the best to keep + * the kernel away from hotpluggable memory. + */ + memblock_set_bottom_up(true); + movable_node_enabled = true; +#else + pr_warn("movable_node option not supported\n"); +#endif + return 0; +} +early_param("movable_node", cmdline_parse_movable_node); + int memory_add_physaddr_to_nid(u64 start) { struct numa_meminfo *mi = &numa_meminfo; @@ -899,4 +931,5 @@ int memory_add_physaddr_to_nid(u64 start) return nid; } EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); -#endif + +#endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9d29ba0..79c709a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1738,37 +1738,6 @@ static bool can_offline_normal(struct zone *zone, unsigned long nr_pages) } #endif /* CONFIG_MOVABLE_NODE */ -static int __init cmdline_parse_movable_node(char *p) -{ -#ifdef CONFIG_MOVABLE_NODE - /* - * Memory used by the kernel cannot be hot-removed because Linux - * cannot migrate the kernel pages. When memory hotplug is - * enabled, we should prevent memblock from allocating memory - * for the kernel. - * - * ACPI SRAT records all hotpluggable memory ranges. But before - * SRAT is parsed, we don't know about it. - * - * The kernel image is loaded into memory at very early time. We - * cannot prevent this anyway. So on NUMA system, we set any - * node the kernel resides in as un-hotpluggable. - * - * Since on modern servers, one node could have double-digit - * gigabytes memory, we can assume the memory around the kernel - * image is also un-hotpluggable. So before SRAT is parsed, just - * allocate memory near the kernel image to try the best to keep - * the kernel away from hotpluggable memory. - */ - memblock_set_bottom_up(true); - movable_node_enabled = true; -#else - pr_warn("movable_node option not supported\n"); -#endif - return 0; -} -early_param("movable_node", cmdline_parse_movable_node); - /* check which state of node_states will be changed when offline memory */ static void node_states_check_changes_offline(unsigned long nr_pages, struct zone *zone, struct memory_notify *arg) -- 1.8.3.1