From patchwork Tue Jul 11 04:48:28 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: 13308121 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 6D58EEB64DC for ; Tue, 11 Jul 2023 04:49:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0855E8E0003; Tue, 11 Jul 2023 00:49:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0353C8D0001; Tue, 11 Jul 2023 00:49:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3FE08E0003; Tue, 11 Jul 2023 00:49:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D6C768D0001 for ; Tue, 11 Jul 2023 00:49:12 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A7A131C80DE for ; Tue, 11 Jul 2023 04:49:12 +0000 (UTC) X-FDA: 80998101744.21.F242471 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf11.hostedemail.com (Postfix) with ESMTP id 5ECB64000E for ; Tue, 11 Jul 2023 04:49:10 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=QFXFxeTF; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf11.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=1689050950; 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=ovKAV65T86giU5iNR9fKUCaP+axW80f9f0pRL/qKZqI=; b=b2aXjsRRUwiBgmNG0abtxmvJ6kBfzBJcJqA40A5lx+x6kgQq6yje0GUAOagpbqrRH84U4G Xc2hDnibkyWZipACXtjmWvSTLfCFi5NRxpKD9RmfSiV0FKywmuPd12AvSSGGLU1N7+mUr2 kt653sTeF9Hgqd1ogBaQoM/P0NkZLC4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=QFXFxeTF; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf11.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=1689050950; a=rsa-sha256; cv=none; b=CZwqUfPz8dAobmIqeT6pLYVoIrHRImTb2/v0Zj4hsLYXtbpw/CKJtz70cpj/cZmvJ+l9Ax WoesgLh4oaQh1lycmaze43yal/INhh3jlvKINsqIdyLB+HnhcxvsS38pgnfFsGRApgZpKI WH8fEEf1vU9mfPGKLF+JXtyXLiGdGco= Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4l1bV016886; Tue, 11 Jul 2023 04:49:03 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=ovKAV65T86giU5iNR9fKUCaP+axW80f9f0pRL/qKZqI=; b=QFXFxeTFgYM7AmwIPAtS4KSfKFniuZhXl4i97DAOYAQMHTP99QPKnxm1DoCv0riy0Pie oDhxehNWpm13t6hgTqdMHUGiK+jmEhzjPZM7REnsSv5RruL1k2upB7dXmBoANXt4CKXB cDH1GpgbWLqnvnMmsi6RK1XwMdQL4/PLs6dPTe8Y5YUbXM7MvLGzQjJvQ/qBVfHN8DxF /9djoeIOb03FW96WS5dqC03YqP7sEtxIW6fBevj51jWWnhZawfFttrtjawz8ETMnqyyb WE9KBw8XnfV0cLKvBH76UU4/pKKOGOHGaFQPuKT0cBM6wUr1l03/pa3OQPTT63Fsao8N hg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg3s9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:02 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36B4lQgN018863; Tue, 11 Jul 2023 04:49:02 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg3r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:02 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B1GfGi014443; Tue, 11 Jul 2023 04:49:01 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3rpye5n3nk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:01 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4n0HL66716122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:00 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2289058059; Tue, 11 Jul 2023 04:49:00 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B4065804B; Tue, 11 Jul 2023 04:48:55 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.86.43]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 04:48:54 +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 v3 2/7] mm/hotplug: Allow memmap on memory hotplug request to fallback Date: Tue, 11 Jul 2023 10:18:28 +0530 Message-ID: <20230711044834.72809-3-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711044834.72809-1-aneesh.kumar@linux.ibm.com> References: <20230711044834.72809-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: XY1er3ab0bVtrv3qMRcvqfnQepeFv_yg X-Proofpoint-GUID: NnT8I5tzXtw5IYqYPtOnjZevwsu6vedM 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-11_02,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 impostorscore=0 clxscore=1015 mlxlogscore=739 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Queue-Id: 5ECB64000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mwox6gkc5yoiemqpsbcfmq59dnc7gdjr X-HE-Tag: 1689050950-284481 X-HE-Meta: U2FsdGVkX1/pAd5rh++Lx2A+RfV+uWNRStrVn8ZdWqvnOMBNZ27insQQtwmRUONlBMtMoePouMsDSKJjUBcQkzqkm1Rzfi4iPJd5NmMIhBUy8vDmrtjTT6k8G9IcLQec/9TM+iCVKY02NkdQnmweixjBiiodMLNupib6scGK8T7SMrQzQ1IpnOOXE+bmh01O2o5LnbMqxZ4uEYiCN+rZnfX+qQgJwrcXCruSrEyYqCvvssF35aifW6ccKswxJG1nCLkDWKog1Jl7HngHEAgWyc4Mbm3IBrUInkWuXd7IDTFA9/eo6wGY+57Cj3Bb6XNXfFF4jx3eY9CM1A+gdZt+TQlgQXEcre0WpgNRoIcwLwwp3YuHVWG/vA4yjKYwjqff73+LRQ4nEMyprxs2n+VYtfl2Mn5kCTZETtrznhHL93U2jrRCpXX0wNu4/UhBuSILutJMgN34ely6UZwb0P94xGenuQB085yla4XHUA02FQA4QhXH0w9M1ncW8xJSglKfSyfe0/33XhUCsB2rYRAaXQrMtzM4h5r1vLjOyD6KW0Cdg+GI6OoSvjbA0ofdoYqEpkQrfkX2YUhVISBWTAnn5zA1jW4m/sqU6DNiV1JeQwStxf6ESP/DBLPS3nV//1Y2DqyLdk5JHu4ZTqOnjJSLvhfXCTaNhqFdGz/5MrB0TjlEDT1kRwvpMQrxxWPttdhFz6tFobQY6CVILsPy96knKfY1CLmE01CdNGxOBSJr8WlHz6TqPY4Xc5lpwm2j5seZRff7iR6fVHoJhu/YDRs3J6kGwWp6NYZjnd3X/sheI5WRcswg5V6mbtbJZCSSKDMFjMukz0zhVcPh146AYzRtE2HL8hCeTymGOtxIqluIO/U61M/tjLwVdXlzlYs0cYtFOgp0OUMJ7IoiDL+Uvpdlfq3UNlz9LCzwioblZTq+3Sr+hTImB155hJc3GQ1JfwvzLD/PUXys6TVT+31E1Ag x9EfvAwR L8o/uuNUCnmXKInvW4OQa4uQxLWlhknwgb+Z2R8LHVqNo09yzRjMZw4QoXhKcmdEHQK+2XzM9SLFY8MJI37aaoKPp7sVtkJDFnQHnhyudx11S3mpzMxjECqm0BJt6DKRz2PNTDQqJjJ6JpC4= 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 --- drivers/acpi/acpi_memhotplug.c | 3 +-- include/linux/memory_hotplug.h | 1 - mm/memory_hotplug.c | 13 ++++++------- 3 files changed, 7 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..96f6127f197f 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -354,7 +354,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 */