From patchwork Tue Jul 18 02:44:05 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: 13316690 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 ED9C7EB64DC for ; Tue, 18 Jul 2023 02:44:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 882BC6B0078; Mon, 17 Jul 2023 22:44:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 832928D0001; Mon, 17 Jul 2023 22:44:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 722A76B007D; Mon, 17 Jul 2023 22:44:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 63ABD6B0078 for ; Mon, 17 Jul 2023 22:44:38 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 362BC1206CF for ; Tue, 18 Jul 2023 02:44:38 +0000 (UTC) X-FDA: 81023189436.21.5D5B5A4 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf02.hostedemail.com (Postfix) with ESMTP id EDA4880004 for ; Tue, 18 Jul 2023 02:44:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=S9hriD9o; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf02.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689648276; 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=vaFf+Tj84fQOuQn1LSclsCakzJe93KcVYoOBxNETnCk=; b=XpPthwQHge2JaZHA9Z2SM6B8RTnkF9CP6Et/a/M06n/5P4DPRcIbjYtixhoKAtIZBd2CHW GERSIC7ePro3kmFltgp+Izi+D1zDBDZp5mkTuxKjgRtDvWfIWKeJ5olmLjJheb7sAkb2us NvCbpPHzvylqxjBfMfPoWhmnnXlGexA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=S9hriD9o; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf02.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689648276; a=rsa-sha256; cv=none; b=1neoxO/OygydYre99Plh726col4Ut3cyeTimRFVGsZRsFLluybgsL8D+hBGzee+/kTpbg7 H4fd1Yz74cbCSQK2dVvOeXOVjqAH83QVvp8iLfdqZHbTi2nom5LZaRVwHPiJf52kN1oo0U FfuRXA9wTgqqXDZaW08I7QiGmFZQRgE= Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36I2PtkD019839; Tue, 18 Jul 2023 02:44:29 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=vaFf+Tj84fQOuQn1LSclsCakzJe93KcVYoOBxNETnCk=; b=S9hriD9ojrraVhrxWf8hp8wtHwgUI128b3vFevNnA5eC6k8PFZJSQt8UR8YiUvPBKQl2 J3XxZHQQ1eF+HrqEjXg+gBjW50AvpirdvIXOMAc0FiRBN0CJD0sRP96+hYihaqKorUIp IbTfy+aD6yztv81x/WSr2LlXs6E4upkCm2+WUy3lPmwYYWwnaJqW8G1VxtzDct6E79ro cbrvwMnq0+bShpeXRERcWFlfbuNb/D7fMIb5C5qmwGPGMwfET8SimQ72zvph9W1u6ad3 27e+3RKlNr/eib+nsCNBjvM9hegqsbvsAnfDny5qQm6+yELOpSq3OoKZ/dQ+VnORP1hB wg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rwhxv0e43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 02:44:29 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36I2c6x7020427; Tue, 18 Jul 2023 02:44:28 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rwhxv0e3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 02:44:28 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36HK7mFv030687; Tue, 18 Jul 2023 02:44:27 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv79jhhj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Jul 2023 02:44:27 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36I2iRtO62914838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Jul 2023 02:44:27 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E10395805E; Tue, 18 Jul 2023 02:44:26 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE2BF58051; Tue, 18 Jul 2023 02:44:22 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.62.199]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 18 Jul 2023 02:44:22 +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 v4 2/6] mm/hotplug: Allow memmap on memory hotplug request to fallback Date: Tue, 18 Jul 2023 08:14:05 +0530 Message-ID: <20230718024409.95742-3-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230718024409.95742-1-aneesh.kumar@linux.ibm.com> References: <20230718024409.95742-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: neW0gZDso7HhNBLmR7uzg4mWlrocQ9X7 X-Proofpoint-ORIG-GUID: GdU3A1fgFYOOEzTISok73_QLpSDQCJaC 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-17_15,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 impostorscore=0 adultscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=897 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307180022 X-Rspamd-Queue-Id: EDA4880004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: k8p5uwn1obmkpqnhij11ecex8795nruo X-HE-Tag: 1689648275-796962 X-HE-Meta: U2FsdGVkX1+7pRAOjp2PGN/wJteysE08kGUrBYbRnTiZSm/s7G+1nvmiYUjzThsxahJnZ7jmuZsYXlgDXBIx9QBAEgtBLp1AZup7Y4g52RLHtkzTMVOYFAuyXyyJdDIvOXfns3V1mrB9PXEiu+0ImiaD8ZQbdFE+dnu2Zi8JHPSBWTfxS4qpOCIiDWROV/qGhLxij8KJ+jKkudZxxHrcnPs+8HYF2yk61Shy023w5GIJJCex1PJ5fOwHOx7n/XVsfsOR03OP9ZuUBXG8hX7+0RQutuYcPciR06H+wxU0ZitW3s49v50zCCkAf6HkOccMSOHiOAwMJQgScpfywURW1A/0AjzsvGXerqdozl8h7n9w5aTv5I71rWBFTqojnxpVXzagI00I7ribCxwVwy9V6f/Mb7ufqNwxpdaHHVjUdNMaIanOZlN14AvMyMz2m0rdStiXkmjSWxymA1EBdMwvjaw7KtyuFxLgRs7r9+DKQwoU4uW6h9sKPvwh7MSNN5rMNtFYKwPzCGM7B5DszRtma3ZkPKdndT6zyDT/XOyZ5xPbu2dSfaoievjpiKEEltzBpjpui4JiNw8DuRMRc+Y8lTIaI1FP91whWo4HW1cB5oIP2TirrHo1jXKBTsFc7zNp/s7+N2WtTncxpwMVOgS3eZw9Ob5c7EvcqEUR/vX5p5qWIWKei/qnxdQMt5twhu/VbcC6o/lgi8alkhY1hN8UQQEUd1d//i7piGv3v044MhVQv9+gZk2ZM9D0EcYOfNXoayePDnBx3koblcHqU234HcMjQVuEZ/p19HJ580mNHxJ9qtrOBMf349nVS7WYVY98XZjxFZmZ/94Ok18vvWQ7NR8T7lv9uNoBWcBLM0cNjYjHmSXk0+SkF08IzePBts4jjH7l++1D+I3x0GT7U8/3zFAhvmNgYSeA8YWpK/AG/Hq+0KmEhj5+6R7AT82oX1BnsQe0nMthReW+R999Uwd LwJvC4ZC YDztGfqPOm33qp813sKpYI3ltk2gxqO/6dpxR8fyDsbWsaN1bgkg7YBVbQQZ2s4G2UOU/KIeUE8o/E313UR7+riMpwwtasQUHNEwHdn+MLNyDeSekl+bZ62qBQEzYinU/f6NCA23F1+0fowU= 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. Signed-off-by: Aneesh Kumar K.V Acked-by: David Hildenbrand --- 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 3f231cf1b410..1b19462f4e72 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 */