From patchwork Tue Jul 25 10:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13326254 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 339A3C001E0 for ; Tue, 25 Jul 2023 10:02:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED386B0078; Tue, 25 Jul 2023 06:02:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9D046B007B; Tue, 25 Jul 2023 06:02:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EF0C8D0001; Tue, 25 Jul 2023 06:02:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 828A36B0078 for ; Tue, 25 Jul 2023 06:02:44 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4A467160D1C for ; Tue, 25 Jul 2023 10:02:44 +0000 (UTC) X-FDA: 81049695048.26.8101038 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf18.hostedemail.com (Postfix) with ESMTP id 9B8131C0010 for ; Tue, 25 Jul 2023 10:02:40 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=P3Z4AZh7; spf=pass (imf18.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690279360; a=rsa-sha256; cv=none; b=n15iTP/L7nXsA2NdUvp3k5vSl+WXT2MTcx5GN8FDN+kJXMD0tW5E/XX6wBIVwYCI9PTzMC /a9WJmkMeer76qv/b0k6MxYzHfc+Fu8ER1YRbPUiR7LvqDYpfvJVaom6JRT8f6qBC+lC+S uOhrrBUMzV9UlTKf/yE67NRO3LOS8TQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=P3Z4AZh7; spf=pass (imf18.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690279360; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GB1lCglV8LwUrneFfqAgwx4CmNBI9hR7fw7cHMyn2BU=; b=zO122uWOTGYr48KHzcq7zoPen57tQ287X4I3Jp1Sv0kaSbM4SF3pYc53fE2cvaObSv9Adx 2xoYIvW+H3SLL4MaVG4SA7oCEDkd1b76nTsvo0l7jSeDlXeMP2v/bg4JxFtczQ2vP8gnKj /YiFH3dFlVbczbLpHYk1LembKv2t3Lo= Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36P9tNPK022247; Tue, 25 Jul 2023 10:02:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=GB1lCglV8LwUrneFfqAgwx4CmNBI9hR7fw7cHMyn2BU=; b=P3Z4AZh7vl56a3I1bDgkMQ1mJsguRpdiGdQ0OSatyBM55Mf4NIpdPWRtFQwa3E2lDiF4 2FNqw5rjLBc1UHRD1k0KQtjoDqH1Uwi87mF8vPbUTYZEn2RXDeBOacbd7pGoCVe5bZaY y4RG0RPSZNeC8Z0l6TxEZx7dPlmHmYxGJDlm7EW/tGvYpnvD4jLsuMvTPiSimcl/rYV5 jHKVv+5MCI5yJ7u1b2G3w1y8dICquEucOvIPR0A8580LwPZVkgz8/W57ifTzHOAiPIva 1512HxgaPhTXm+eWv0cfIiViXJMdhKgXUI7rKUo/r0L9oyPvOo89fiJlEm2UniE3PpA/ rg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s2bpqguqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:32 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36P9ebbx002191; Tue, 25 Jul 2023 10:02:32 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s2bpqguqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:32 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36PA2D4r014387; Tue, 25 Jul 2023 10:02:31 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3s0stxu8yr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:31 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36PA2UXE6226446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jul 2023 10:02:30 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 667F95805A; Tue, 25 Jul 2023 10:02:30 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E1B458051; Tue, 25 Jul 2023 10:02:26 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Jul 2023 10:02:26 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: Oscar Salvador , David Hildenbrand , Michal Hocko , Vishal Verma , "Aneesh Kumar K.V" Subject: [PATCH v5 2/7] mm/hotplug: Allow memmap on memory hotplug request to fallback Date: Tue, 25 Jul 2023 15:32:07 +0530 Message-ID: <20230725100212.531277-3-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> References: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: oeXic4QMWbD_ylfj6OlL41jfzQQL1IrO X-Proofpoint-ORIG-GUID: -E0t8eMXrLlWSN02ujcXTrk5D4u0dxYN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-25_04,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 mlxlogscore=953 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307250082 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9B8131C0010 X-Stat-Signature: 138zz7qnr9tk1tojx1k3pu9x11ky3gaq X-Rspam-User: X-HE-Tag: 1690279360-39222 X-HE-Meta: U2FsdGVkX1+0evs0bE0EGVSzww365nR62wD21G7EAYje8DPxWmxddrnpxyJzlK0gtesmOsgtwp3EEDZWkfh9WWpFQv4YI5LEA51eUNbcUctOd2FLn5wvFwIzFc4KiH9S5Xdc9qq8DSjxDZXh9kYCSfB5Ftb3DuZcE8a4YLmW5gP7N8+cS/aZ/xVHi+7LPbLDZlymKO4OCMwlnnUmKsqYM5StUFroYShZP2+OZOcvY7uWqHU1dVDqwI8FQNUAxx5NrTdZXJjDiYSHte3340RvwJKcace880hX58BUhz4YsxyOQ88uJpskRdFIU+47WdpyfcRguX8WUjZA8eo4n3CCE34FSgeOV7iA3eK9yOFvPV0XM0jBVrCLHNv5bKXpggxMRlRdAj6erb6DQyYr9PCA6wTEGUKgbd5nJxnJjPCO9oyk1z2TkPEPxX3UkxlI7cCMuX80tu0oCfs/DGZTuMHE2uBpbS/bSEIpVCjFQdYuofQtq1tTtIkYg0SggTlqZLVf84CGJWBffRxDL09qtC6VXk3rhKpEL+Lc2t387gjNEtfPHEpkqOc2UnVDZO/2bIhCpacSODVx8eA5TJbdLbuuIrEjut14eGdzqpiAezbnXMr+JBd5N12F1e1C3wo4WGens5xiGGE07ud/t4w9uN7pkDQ5IesciSSL/rbAA2ieLK4dcymhBeGichE9ZaGOS9JT68+X1Sufi3o7gzfwrnoltLjVXATVdYWAjpzL8FPI5TaL+a3t6D62PbUsyXIP957sMkETffL1J2OJUwtf1jjE+HDfII2aCjVnzQWC8shwgLGJIlKwrWGcUCwfZhR7r7ey/SkPYgdxo528/SDlDMHPhWTeFv15knEkWd2RpDmy1i5JUTIxFPcpqTtXKlpnnSNGfC+z/uZhk+LvrECK5rNVIRDxvjxslBkoM5cj3Xc0OscbA/N315MwRnXTvBT/WgTYm8LLvgfWdza5yEx7Oo+ 4SWff7g6 Mrb1OfMLhYkbhAmKaZFxlYY8/YkIX4/aSwpLOvv1O2fXgRWdJdLyoAN86OHsWodjpn2UZjj01Ujoi8YCk1CvKiVx1EHlxzuamVeLkXg3hIFp8+D1mel4jdXRXE5x7I8n8vsKMNb/X4+Evh/qcQV9Sj4WYuWpj6z+jc3moTjj/EUFIEhU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If not supported, fallback to not using memap on memmory. This avoids the need for callers to do the fallback. Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- drivers/acpi/acpi_memhotplug.c | 3 +-- include/linux/memory_hotplug.h | 3 ++- mm/memory_hotplug.c | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 24f662d8bd39..d0c1a71007d0 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -211,8 +211,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) if (!info->length) continue; - if (mhp_supports_memmap_on_memory(info->length)) - mhp_flags |= MHP_MEMMAP_ON_MEMORY; + mhp_flags |= MHP_MEMMAP_ON_MEMORY; result = __add_memory(mgid, info->start_addr, info->length, mhp_flags); diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 013c69753c91..7d2076583494 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -97,6 +97,8 @@ typedef int __bitwise mhp_t; * To do so, we will use the beginning of the hot-added range to build * the page tables for the memmap array that describes the entire range. * Only selected architectures support it with SPARSE_VMEMMAP. + * This is only a hint, the core kernel can decide to not do this based on + * different alignment checks. */ #define MHP_MEMMAP_ON_MEMORY ((__force mhp_t)BIT(1)) /* @@ -354,7 +356,6 @@ extern struct zone *zone_for_pfn_range(int online_type, int nid, extern int arch_create_linear_mapping(int nid, u64 start, u64 size, struct mhp_params *params); void arch_remove_linear_mapping(u64 start, u64 size); -extern bool mhp_supports_memmap_on_memory(unsigned long size); #endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __LINUX_MEMORY_HOTPLUG_H */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7cfd13c91568..eca32ccd45cc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,7 +1247,7 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } -bool mhp_supports_memmap_on_memory(unsigned long size) +static bool mhp_supports_memmap_on_memory(unsigned long size) { unsigned long nr_vmemmap_pages = size / PAGE_SIZE; unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); @@ -1339,13 +1339,12 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) * Self hosted memmap array */ if (mhp_flags & MHP_MEMMAP_ON_MEMORY) { - if (!mhp_supports_memmap_on_memory(size)) { - ret = -EINVAL; - goto error; + if (mhp_supports_memmap_on_memory(size)) { + mhp_altmap.free = PHYS_PFN(size); + mhp_altmap.base_pfn = PHYS_PFN(start); + params.altmap = &mhp_altmap; } - mhp_altmap.free = PHYS_PFN(size); - mhp_altmap.base_pfn = PHYS_PFN(start); - params.altmap = &mhp_altmap; + /* fallback to not using altmap */ } /* call arch's memory hotadd */