From patchwork Tue Jul 11 04:48:27 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: 13308120 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 6F64FEB64DC for ; Tue, 11 Jul 2023 04:49:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AC898E0002; Tue, 11 Jul 2023 00:49:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05CDE8D0001; Tue, 11 Jul 2023 00:49:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E40028E0002; Tue, 11 Jul 2023 00:49:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D13628D0001 for ; Tue, 11 Jul 2023 00:49:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9D677802C4 for ; Tue, 11 Jul 2023 04:49:06 +0000 (UTC) X-FDA: 80998101492.23.72B21B9 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf05.hostedemail.com (Postfix) with ESMTP id 38C9F10000B for ; Tue, 11 Jul 2023 04:49:03 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=BG9+CEHK; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf05.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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=1689050944; 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=AeSXwfsD9R/AsJzWBWx+hhyUJnbVc54scy/sJAAqljM=; b=YigDr7gELzg/kOD1qPCs4Uz1RMO3uN+1t7m3jfSWetlATNxqr8vs+1zfzm2mF15d5UtCeI b+1+NcE0d1ZsxQ8QSrlnAYvOCzzbdXxZhWCD1y6jc7/Q7JmabfU6lqCjYRj2i7xTDPKu1N PUE1HBfT8+t4aqtmac2oCNtHEb8IRMM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=BG9+CEHK; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf05.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689050944; a=rsa-sha256; cv=none; b=Z5mGyGIudmIke+JWd1E3SzkV+ROUWPfeA/ubG+32XeDGP5bQbnC5nGTJajYWYwNhkpxPeR dh5rX/W67K1rzv7b/aNBC/KrC2xjtwu2qkjL7QsFSsxr3GcMsJmb7bNx2Pn5DzPUNM9HCJ Nty5jm22C2oGdxf4Q752q+h2VjYmPWQ= Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4cNCq016693; Tue, 11 Jul 2023 04:48:57 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=AeSXwfsD9R/AsJzWBWx+hhyUJnbVc54scy/sJAAqljM=; b=BG9+CEHKYKnpiXRcdJMdYkMLdpfog0TGO9biKKeP0uRwaVDqeqR1dBE4/38XkbRhJPOE YyXx34WZ8+xgl/CkUYZ58IAgA9BJPlMopAw8CmiMIt+TYvI7w46uOd+4A1epxLSOppGB mxL7J8Npx3bS7MwGC913ZIeVwFFPNXYvxjD7Yvt5fQBX/FDO+yVuyL6DsU+DH7Jil8IH HqbFipAoi/RBg4RjG4H5o9QgSJYFbIu8UU+kBAzqe+U57XOx/vlT8Ecr6m/5JTrWyxC2 JQBNhBTuoJPkVBCMQzvE3SHZmyhQDeN6Uff3FX3yR8rCwe2MYTfQv8T9lTrn25R6V6nU Pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rryysgg53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:48:57 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36B4d3dL019940; Tue, 11 Jul 2023 04:48:56 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rryysgg4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:48:56 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B1531v027311; Tue, 11 Jul 2023 04:48:55 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([9.208.129.116]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3rpye654tu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:48:55 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4msdG41812418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:48:54 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4860B5804B; Tue, 11 Jul 2023 04:48:54 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E18D58059; Tue, 11 Jul 2023 04:48:49 +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:48 +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 1/7] mm/hotplug: Simplify ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE kconfig Date: Tue, 11 Jul 2023 10:18:27 +0530 Message-ID: <20230711044834.72809-2-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-GUID: xFXDG9NbJf4RJi01_1mNrozQ1gBXyn7t X-Proofpoint-ORIG-GUID: q9R3GYB00ZOcqzaUDUdfGuvVdo9VSWLh 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 mlxscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=731 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Queue-Id: 38C9F10000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 57yaewynyzu5iasnekf1wr78qmsab867 X-HE-Tag: 1689050943-486297 X-HE-Meta: U2FsdGVkX1/nJbhFM9LtlP3xWZQwyAD933LtAFPXHNRv9GHhBAHHvXPvPqPW6yxfd/8eyqGXzYrjT5JSE78V4jHUm/6NSeRLAemih+N4bfuaWp3c+OwWMGkNFwg1RDWdSalTt12MUS3rbSa8gHNdZpZ9G3H+fRaZajnGhKmx9aVL5hi68N6B77jmty8QTpSnhSyXmi+DNTNAxOv5tx1iJPkVUNnRJddp4vf0PyQbXS+kDuVKL2VvPxWtJ2wM1LlfFAmZKozqmo5vbxa5d4xc+YltiuU0oEHSWLCRhEEFDyv+2X/+bHSmxw7DESKjn6wTfZMUPlWLW9EDXVpPzgnh2NKx0oSswyskCWDPRq/kuba43NC8mu6zSYK3KydprtWRkgvYC5+uPS3VPrPURqsP1DmGAEeQJZcy/BvSqJIf6T7mbZKb0AAXn9aWOSeUpjG6zn3BgRvF/+6QfmliwXqHWsFOku2glPZlq1vG5zPjduMTrbGuVi1pNcI6ww/5hx++4zMtylSzAq0zv+yUAncJh1kr6svf2GuTFThIj5T8KTqJXzxYvJHGSfKUSTp9iKFKpO8Z1ZHq3+DPeffI78O0NZRGVl3a3wvo2VGemiv2u33cTzg0SAObBJaQstZIO71KU+QBYP+xt4HJ6JbbZv67Kzj7pPW8ymg+3+Qi2xO0dn5/EgGTSshFLrj7Fe6jOkf1GY5vlk0hkvBB4sZB7nSHT1yVyEaNL8afUFWtbh9ikFgO2OGXw6rKM6QR3SnPrrG7Bf+mgbRuBJgLAqtJd9LFRLtfQ9carWEkB04B38VtzOML4pC5aYjRXwuTq5CaJCDFO42OoefwDWGJdZwGCyJQAONf2JKdX3N3OcSIhV2LoqHsodBDnConzuOls7ynz9wFqiyCZUb+2iHYGuNgE4AwIh8baRE+u+PWuz6UUNJ/TxqSlBrMaOOJVaed0d8vOJf7WokASQVirWIiQufsFYV zKpo3237 5pacBaq829zuyKssEh93fhzUSVTK+aHvZ8Tnhi92+HqwRUIhdxo+3yOmhtUvpY9HJpSzj8CxtAZZnxz1AMZGK7+zU4wQ6Mv1447lt137sIv5A2eNsqReoZdZdUwP7JciAzPxxISB+iPsqY/lxYres44C39K+HxA2YaAu3LTzcKB8oJv4qzGkdQhDvMd51bwBYta+n7l4qlgDGNC4FbkE1lIjD2g== 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: Instead of adding menu entry with all supported architectures, add mm/Kconfig variable and select the same from supported architectures. No functional change in this patch. Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- arch/arm64/Kconfig | 4 +--- arch/x86/Kconfig | 4 +--- mm/Kconfig | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7856c3a3e35a..7e5985c018f8 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -78,6 +78,7 @@ config ARM64 select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION select ARCH_KEEP_MEMBLOCK + select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE select ARCH_USE_CMPXCHG_LOCKREF select ARCH_USE_GNU_PROPERTY select ARCH_USE_MEMTEST @@ -346,9 +347,6 @@ config GENERIC_CSUM config GENERIC_CALIBRATE_DELAY def_bool y -config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE - def_bool y - config SMP def_bool y diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 78224aa76409..d0258e92a8af 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -102,6 +102,7 @@ config X86 select ARCH_HAS_DEBUG_WX select ARCH_HAS_ZONE_DMA_SET if EXPERT select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO @@ -2610,9 +2611,6 @@ config ARCH_HAS_ADD_PAGES def_bool y depends on ARCH_ENABLE_MEMORY_HOTPLUG -config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE - def_bool y - menu "Power management and ACPI options" config ARCH_HIBERNATION_HEADER diff --git a/mm/Kconfig b/mm/Kconfig index 923bd35f81f2..932349271e28 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -572,6 +572,9 @@ config MHP_MEMMAP_ON_MEMORY endif # MEMORY_HOTPLUG +config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE + bool + # Heavily threaded applications may benefit from splitting the mm-wide # page_table_lock, so that faults on different parts of the user address # space can be handled with less contention: split it at this NR_CPUS. 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 */ From patchwork Tue Jul 11 04:48:29 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: 13308122 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 31FF0EB64DC for ; Tue, 11 Jul 2023 04:49:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C452D8E0005; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5118D0001; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABD4B8E0005; Tue, 11 Jul 2023 00:49:20 -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 9AEA48D0001 for ; Tue, 11 Jul 2023 00:49:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7645C1401A3 for ; Tue, 11 Jul 2023 04:49:20 +0000 (UTC) X-FDA: 80998102080.02.E3FDDE8 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf13.hostedemail.com (Postfix) with ESMTP id 3C15720007 for ; Tue, 11 Jul 2023 04:49:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=aYdTTAn3; spf=pass (imf13.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=1689050958; a=rsa-sha256; cv=none; b=8lqbVNps2jPwUresB3lGr0PTnosn32th9WUzQdaYjc3LpIWVkGxFW53k7N+kwNx5n/K8V+ 7eHh3KRU8SsJcp06e7TLO/kiDV0vPc1lPJrFmA+pNWRmB6Ohw/WfBMeHdb6+AEVEy3PgT5 gTSUZn0S6+guF5NBCAKAF+I16gP3YeA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=aYdTTAn3; spf=pass (imf13.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=1689050958; 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=xCc2t1OCuvmYEBqdWeIf9NwGoHZvnb8ZRoU9LAU+Spo=; b=NcGYpQCq4IuP3Xu0JZrS+PS15eWcBqJ2sNTH+/Sao5V3qRCSznG1fxzy/fNdPFcKdDhPs5 qkcPtxWThfpexUiF4yRnkxnU+MO0ux/zRy9s/lBRT9IT21tw+NlXAConkKG3tnf8wKBdG+ EDzpy6TWAxBp5x/cD6Beqt8vxmPhMVA= 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 36B4jXEn021316; Tue, 11 Jul 2023 04:49:10 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=xCc2t1OCuvmYEBqdWeIf9NwGoHZvnb8ZRoU9LAU+Spo=; b=aYdTTAn3Px4U7WqCq/rLeW0RDoL1Gex2HMxRR4/HHV1xgZsx/6EeffY99C5HWzeiZJ7/ nI+5am/3LUNgP/ZIq3qbf5yD37ouWe8TrnHi1lseVddElkXYo2cJ2D+Th5ehM94id9LA 3o4ev4TNOiSf534hTYQV3t0C0QsI2hporChKL0ewKJyRZVGojcK0/ilM+k5p69xLRhnz ohnrwINk8IX4Nf/6Achx+zY/2+Us+wPQvcTWLlDwMnaOwYHcKo3CXb8Scq0eLqtvO7s5 puPhABv6eSaZgUe++KhSdnx67+RLTdwc7FI081I5iY6Yhjwzaisrtc9cRAAgRg48dqyG bQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:10 +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 36B4lBiX029956; Tue, 11 Jul 2023 04:49:08 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:08 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4Ak6i017144; Tue, 11 Jul 2023 04:49:07 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3rpye6vecr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:06 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4n5Y446661908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:05 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 882EA5805B; Tue, 11 Jul 2023 04:49:05 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0E9258063; Tue, 11 Jul 2023 04:49:00 +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:49:00 +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 3/7] mm/hotplug: Allow architecture to override memmap on memory support check Date: Tue, 11 Jul 2023 10:18:29 +0530 Message-ID: <20230711044834.72809-4-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: JUM55NyZuqPvTG4pSPvoE0tJhOASM2k4 X-Proofpoint-GUID: F0LKoe514ZDp7c8YArMLPNObvg7X4Iys 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 mlxlogscore=999 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3C15720007 X-Stat-Signature: ggi7w34c6gafeggsym9fbus4sdncitck X-Rspam-User: X-HE-Tag: 1689050958-676394 X-HE-Meta: U2FsdGVkX1+KmCliBuhHCPcxqAQt9oW2uGUxRVzGIUINQRsPQQP7PHBd8+6aEjGwsx0e7dD1D0LCRuaxTZK4hWt1pjoQzYssiyyEY0VpL/xGEj7HJvzq7fZmrUUVOoDmIICMJfMAZs3C7barXCOOE0fNLzRhF5Qfwp6/kxGXeH3ZxtkRDNFOweyRhsvctTMC6oiikFbt6fjXcCoK5c9IZiZA2Jyvj0LXqdKXwo2sG5R6XgIgGjJtWBkg03QhDbRGH/CQUtyUUTWWlYmKTJAPbPoNxomTJNX5kCcOSvqUpUNa187H2LtmngzoSbo+QT/DG9ZOZN9R+Pxf2GWqQ4ztvd18T3tMi+gOkZlRCPKdVtNUZObQ7z0YWt/Etk8/tzNmkh7NN09oD00f6y6zLasszFCQCy+YAlEDwOJAwrpPJAnZ5X2t9hjnimdVDue8aqh2Se2UETyh9Y36Z1zTy04TcIYJu1yNjRh44cFlxvbGKrwEQBDhOZmtxTJOB9luibOvu2KIj6RMi4Kz9m/0I5Esu8ElwEkNgGDT68jAuAg0FtVeqkW7bdBS0M0UA0xDrq6EAAKcvLKDf0wa2TnnkszXX46xcHUpkoluVcVzrkHZDAlXU+uQV1vgl20vrJdpFUkJeIMycAg9l2UdG/oz2GEJx3L+IYrvBdz2jE+rbnSxb1PluyVVTGlX47mECCMEfElDj6LXW7Ayjm+jtgwfRA7aK7EDSIpjgwexCiowDKppM32UOegM9Q1BbcR4335HPPgFrPVtT6FHkAxWpPwxtht//shMblwa0Ro6fxYoDfvtu9E5rc4Q3thCh9p9ecuiAMhm6MLhs3/OoGqML92j0EJLqV03CkeIGQaC1JABHAwStUdRPI5CfcE50LjQYps/Md8Y7/AhFgt19GEPxjU0e2F01lbqfDHSt2OjzC0fSf+dHP0MQUfKt+W1hTUdxXA56EMbDu/H2rNdsIZK0ZACeUh T+ELKH2T 8idIcZGWaJb5jNdInK3ECLXemFNqWP3JGodip2bkR4W9JyDKaE2aRwvrqNoLz7TiMZuu2QEJI/3drx4P8NHgb9rWJVVQTqsAiCYX67SHFJTRDwDvYzgEa38oLPimTQknX5top/+cNqWikZhI= 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: Some architectures would want different restrictions. Hence add an architecture-specific override. Both the PMD_SIZE check and pageblock alignment check are moved there. Signed-off-by: Aneesh Kumar K.V --- mm/memory_hotplug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1b19462f4e72..07c99b0cc371 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,12 +1247,20 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } -static bool mhp_supports_memmap_on_memory(unsigned long size) +#ifndef arch_supports_memmap_on_memory +static inline bool arch_supports_memmap_on_memory(unsigned long size) { - unsigned long nr_vmemmap_pages = size / PAGE_SIZE; + unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); unsigned long remaining_size = size - vmemmap_size; + return IS_ALIGNED(vmemmap_size, PMD_SIZE) && + IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); +} +#endif + +static bool mhp_supports_memmap_on_memory(unsigned long size) +{ /* * Besides having arch support and the feature enabled at runtime, we * need a few more assumptions to hold true: @@ -1280,9 +1288,8 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * populate a single PMD. */ return mhp_memmap_on_memory() && - size == memory_block_size_bytes() && - IS_ALIGNED(vmemmap_size, PMD_SIZE) && - IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); + size == memory_block_size_bytes() && + arch_supports_memmap_on_memory(size); } /* From patchwork Tue Jul 11 04:48:30 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: 13308123 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 697CFEB64DC for ; Tue, 11 Jul 2023 04:49:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010758D0001; Tue, 11 Jul 2023 00:49:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F02718E0006; Tue, 11 Jul 2023 00:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA4D88D0002; Tue, 11 Jul 2023 00:49:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CD3278D0001 for ; Tue, 11 Jul 2023 00:49:23 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9CF43A02DB for ; Tue, 11 Jul 2023 04:49:23 +0000 (UTC) X-FDA: 80998102206.18.2BFCA5E Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf28.hostedemail.com (Postfix) with ESMTP id 1CF3EC000F for ; Tue, 11 Jul 2023 04:49:20 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=U5X3W+wd; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 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=1689050961; 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=qv5kdCJqHiGr521EXLRJQSJOrIbyQnPS8KUfUxzB4mk=; b=yqvfO+eXY6fmjvadehLOPzkWwTjnLN0DxAy+BdBozOxFXBg4Gr9zl/PWi8U27zHL3fWhsu OFTwAmFPcWoDq8GGgt66BD9Xh9gquQZSxap2HJ074BP8aW6kOEcdnKuvLsQ+aAQMEbn9RY VUwm20Nl4QnEeR4gLStgnF5+DfLPj6s= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=U5X3W+wd; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689050961; a=rsa-sha256; cv=none; b=4SWROWgFWnYeOR8KQMprmRcgf4gBJulsMoJPGorMJYUdmuAUWshwgTAu4o/xt3VCemLrtL E1XmsQm4ZzFTLYM1Z7/nkQtWQRLCi+zRKmUaY25TRz3YW9HSUT+3tnweiKoPOZnZvXuWac aI66d9qFKNRQyTF0u1YFg6gs5A9PmrE= Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4MKnW004609; Tue, 11 Jul 2023 04:49:15 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=qv5kdCJqHiGr521EXLRJQSJOrIbyQnPS8KUfUxzB4mk=; b=U5X3W+wdcJRG1keR0ENtpU7wWF9TFQxEzID1gCqBnn6Hc8zvRVHg6bRRg5FxfCuTIW+o zBB8F+W1uBrKpLkQALrIx1vRhi/NlaFTR0R3cZ/CdX7PNNH+oAfkSBm0U+8xKLaBw1S8 NtB/f6AdKaxF2dCwokS4yPUlj/l+jTdsu+GBsJXDu1g2SxgiCf0x5AS1m38co+BOMCY9 Kz42m0fevaSuWRJw08INAX7IpWyNeKziZzWImYti/H9XZZESkaFJnl7Pb3eiG+LQxUCN eGnDCGYOPa8KYN581G/HzJjqQkEruxH4oTRFWxfP07b1Fy89Tyc1ENifdqJ+v298P1kx 7w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs006ggta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:14 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36B4gZqj032046; Tue, 11 Jul 2023 04:49:14 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs006ggss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:14 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36AK4HvZ026626; Tue, 11 Jul 2023 04:49:12 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([9.208.130.99]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3rpye5m6xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:12 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4nBcK21365122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:11 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DEDF58063; Tue, 11 Jul 2023 04:49:11 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5BA8E58055; Tue, 11 Jul 2023 04:49:06 +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:49:05 +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 4/7] mm/hotplug: Allow pageblock alignment via altmap reservation Date: Tue, 11 Jul 2023 10:18:30 +0530 Message-ID: <20230711044834.72809-5-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: vwn1gOIxSoMzp5Tu-WhT89dd-ZCdeN2n X-Proofpoint-GUID: rkyAmsDTrnaNuMmXurezn3Z51PizvCCc 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 clxscore=1015 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1CF3EC000F X-Stat-Signature: suxbmu1xj1xj9hpanadgmpbf3igoioh4 X-HE-Tag: 1689050960-682136 X-HE-Meta: U2FsdGVkX1+P47NwLNJfz+w2aSQCU2QPJb0Z0CIO7jViz3o+DQhMIxHjKT67wPwX60Y70iAheYW867SfqzNvNblWscb4xxZU0PAEICjblNyKUE6ghkF91kRBn4yUdZbp9R9if8YYW9c8JeidQlhXEv75EC3U32oqu0t68djh/yFXXicFTm0LPd8l/VSWH2Itt8LjKeN9vWGJF1fv58VTkZiP+8ZwoAsIhkRQlIqhWQ8TMe+gq+5Lkawkr8aPRARfMEbaBJVvzf+Dw76v6yrj0/HXlnTK984L+3WTEB4cGXWfa7ENQVcoJGOURgdfEoxkPlmxQedbWKB4poHkYrMf0Y/1FeLhrNoX58F9GqVpV2555e/842QADZg58Cs2CBaf45ISTA6cqfOC2Kg76G2+JmR8aYgGAWVqo/Bp3hROY0dE/fEzi+6THXNCquucndhpmpQur07Wsc6rnHeD986/klhdtuGjBbBfVAHT1zi1b5m5MQ9kaWvaRUSY7cjkT2c41tdUegvyCYOVVmc/zo7SKbWhKgiy4JU/FdUHIH6YoBeSnwRwYibQpzUOrJJTcca9g/BJn1p0vTXxh54WE2RVwtps3lZpg57eAvpUbaV3N+EZGmfhbj7Ph1xiahMi+FPYws3T2T/FGR/5CHb0Ll2VUEk5IixmgyoEKlbbd8gmRDdwI778iSL0NgkC59TzEQtoi3evdexd5sn3IOShwhXTcsiB6FlrQFfS7Va1my3PT6ODVXaZ+lzzGuGycQtCugmqUPEBTDbK5bz9WxRwNmViSo+LoS3QXHs2RjFI9X7R8SNbmnXrJhrDrgBModQFKEL2y2PD7MqTKaTWNfjt5cw1WQhZ5Ag5yOg556CLDCmoDK9gOxOxvv+1sTWCcWZFzEB3sxTkY75OFgoYDKwPIcVedY3az3bp/WLevauZUbKGhUl7BIrIbL707VT2+0ipm3o0cVcQEt/R8GhFjRMMkBx r8YrRRdy lmONsMdJarSAubQJydwPwp9ZWABrsxy0MYn19bH0ImK7A9dLy+6mx0uWWRi+IwyIb34gFG6PBJh9uxLXS6YOifR/YPgyrHyf622AJURuQhInXXIPQogLmiyDffdR6aB4lHKmYOA+rJ3gO8Uo= 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: Add a new kconfig option that can be selected if we want to allow pageblock alignment by reserving pages in the vmemmap altmap area. This implies we will be reserving some pages for every memoryblock This also allows the memmap on memory feature to be widely useful with different memory block size values. Signed-off-by: Aneesh Kumar K.V --- mm/Kconfig | 9 +++++++ mm/memory_hotplug.c | 59 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 932349271e28..88a1472b2086 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -570,6 +570,15 @@ config MHP_MEMMAP_ON_MEMORY depends on MEMORY_HOTPLUG && SPARSEMEM_VMEMMAP depends on ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE +config MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY + bool "Allow Reserving pages for page block aligment" + depends on MHP_MEMMAP_ON_MEMORY + help + This option allows memmap on memory feature to be more useful + with different memory block sizes. This is achieved by marking some pages + in each memory block as reserved so that we can get page-block alignment + for the remaining pages. + endif # MEMORY_HOTPLUG config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 07c99b0cc371..f36aec1f7626 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1252,15 +1252,17 @@ static inline bool arch_supports_memmap_on_memory(unsigned long size) { unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); - unsigned long remaining_size = size - vmemmap_size; - return IS_ALIGNED(vmemmap_size, PMD_SIZE) && - IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)); + return IS_ALIGNED(vmemmap_size, PMD_SIZE); } #endif static bool mhp_supports_memmap_on_memory(unsigned long size) { + unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; + unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); + unsigned long remaining_size = size - vmemmap_size; + /* * Besides having arch support and the feature enabled at runtime, we * need a few more assumptions to hold true: @@ -1287,9 +1289,30 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * altmap as an alternative source of memory, and we do not exactly * populate a single PMD. */ - return mhp_memmap_on_memory() && - size == memory_block_size_bytes() && - arch_supports_memmap_on_memory(size); + if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) + return false; + /* + * Without page reservation remaining pages should be pageblock aligned. + */ + if (!IS_ENABLED(CONFIG_MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY) && + !IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT))) + return false; + + return arch_supports_memmap_on_memory(size); +} + +static inline unsigned long memory_block_align_base(unsigned long size) +{ + if (IS_ENABLED(CONFIG_MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY)) { + unsigned long align; + unsigned long nr_vmemmap_pages = size >> PAGE_SHIFT; + unsigned long vmemmap_size; + + vmemmap_size = (nr_vmemmap_pages * sizeof(struct page)) >> PAGE_SHIFT; + align = pageblock_align(vmemmap_size) - vmemmap_size; + return align; + } else + return 0; } /* @@ -1302,7 +1325,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) { struct mhp_params params = { .pgprot = pgprot_mhp(PAGE_KERNEL) }; enum memblock_flags memblock_flags = MEMBLOCK_NONE; - struct vmem_altmap mhp_altmap = {}; + struct vmem_altmap mhp_altmap = { + .base_pfn = PHYS_PFN(res->start), + .end_pfn = PHYS_PFN(res->end), + .reserve = memory_block_align_base(resource_size(res)), + }; struct memory_group *group = NULL; u64 start, size; bool new_node = false; @@ -1347,8 +1374,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) */ if (mhp_flags & MHP_MEMMAP_ON_MEMORY) { if (mhp_supports_memmap_on_memory(size)) { - mhp_altmap.free = PHYS_PFN(size); - mhp_altmap.base_pfn = PHYS_PFN(start); + mhp_altmap.free = PHYS_PFN(size) - mhp_altmap.reserve; params.altmap = &mhp_altmap; } /* fallback to not using altmap */ @@ -1360,7 +1386,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) goto error; /* create memory block devices after memory was added */ - ret = create_memory_block_devices(start, size, mhp_altmap.alloc, + ret = create_memory_block_devices(start, size, mhp_altmap.alloc + mhp_altmap.reserve, group); if (ret) { arch_remove_memory(start, size, NULL); @@ -2260,3 +2286,16 @@ int offline_and_remove_memory(u64 start, u64 size) } EXPORT_SYMBOL_GPL(offline_and_remove_memory); #endif /* CONFIG_MEMORY_HOTREMOVE */ + +static int __init memory_hotplug_init(void) +{ + + if (IS_ENABLED(CONFIG_MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY) && + mhp_memmap_on_memory()) { + pr_info("Memory hotplug will reserve %ld pages in each memory block\n", + memory_block_align_base(memory_block_size_bytes())); + + } + return 0; +} +module_init(memory_hotplug_init); From patchwork Tue Jul 11 04:48:31 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: 13308124 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 5B6F2EB64DC for ; Tue, 11 Jul 2023 04:49:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB6F38E0007; Tue, 11 Jul 2023 00:49:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E66348E0006; Tue, 11 Jul 2023 00:49:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2E568E0007; Tue, 11 Jul 2023 00:49:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C500C8E0006 for ; Tue, 11 Jul 2023 00:49:29 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 832ECAFD9E for ; Tue, 11 Jul 2023 04:49:29 +0000 (UTC) X-FDA: 80998102458.25.58BBBB4 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf02.hostedemail.com (Postfix) with ESMTP id 45FE080008 for ; Tue, 11 Jul 2023 04:49:27 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ItPoa9bt; 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; 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=1689050967; 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=9hGLX82mpM7A1sG7cUX4F22RXgthqmPVRb138g4/vAU=; b=ueVoGZfJpiAAdWdbPz6Oex+SR4cjszJeafeX1rj/+D5dLY4BdJpRGgqEz3vp2UJmonBT6R Qlk7w3g9B1USWKdYxaxWGZMfJ2bWE3TstI1Robwd6vabgob3fKwofp7RwQVW4KMM/J0n+H rS509V/dwh5HyDBQyCcexQIDpc8PJmg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689050967; a=rsa-sha256; cv=none; b=d0E5KGHKFW5rWHN3Udu8tBw0d7PdAdMIoH+4gqeA1caMKaYNWFY0SskI347xVTWWYdYcwc BxY7axBgwbIo7aVBdGIAPNlouDrRG0Z++De/jErsaWn/EOQA/6rFp4SWj5DzZ5S9qOz/zS aFXP+SSW7BR70SWgvM0adjqn+LFOt34= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ItPoa9bt; 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; dmarc=pass (policy=none) header.from=ibm.com 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 36B4kwXo016793; Tue, 11 Jul 2023 04:49:20 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=9hGLX82mpM7A1sG7cUX4F22RXgthqmPVRb138g4/vAU=; b=ItPoa9bt3C43BAS676bvRNT1jZcjwr1NAJmXMLZkqS63/ltVOYhgSaycan52ArAGCHqr TKTJXu+dnNDs+7cMap/dziHWV+/9GTFpAsI7ZQAWtWS5ERj8RjRb8ey0B9yHrjf0CMqd ZBGG4zito4yiygTY+rXZhJE5ZMNbBhA0wjTIC+8P7WlnsDuUn0w9ZVpzCa8EMFP3DJ64 7DDTDEVFjeGQZyv1y5GKd2cjKBm6AFWpw7KAW9Dxr+0zdBc2O/S4S5oIrPjqlY8Bqq6W U817niqRB0W3ZOhdBA84jO+my+xfKQ+m3GExlz6HYgtXTyzcJaLAg3v/Tjms9Ns55aAA rw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg4a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:20 +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 36B4kuEq016759; Tue, 11 Jul 2023 04:49:19 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg497-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:19 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4ZL56017145; Tue, 11 Jul 2023 04:49:18 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([9.208.129.114]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3rpye6vedj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:18 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4nHCK34603388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:17 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A78558055; Tue, 11 Jul 2023 04:49:17 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A5AB58063; Tue, 11 Jul 2023 04:49:12 +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:49:11 +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 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix Date: Tue, 11 Jul 2023 10:18:31 +0530 Message-ID: <20230711044834.72809-6-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: iew4llAaLdvPnwP5c6khYbjOxStUR01A X-Proofpoint-GUID: 06NDGcN6XjIVYL-dF1kmE_6ApCwGdXkg 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=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Queue-Id: 45FE080008 X-Rspam-User: X-Stat-Signature: h4j7xb6jkgunrtodir5bxcrhrj18fu1c X-Rspamd-Server: rspam03 X-HE-Tag: 1689050967-796149 X-HE-Meta: U2FsdGVkX1+TS7sEUEBMEZFnF8Z2o8V7Kfvx7pD0+hdEHBeO9is6Hs2m786YbmytAMAOwe+12iJhDOj+/TK27o2DzmT5V3J/TgLTMgasaC8XBJNkBsSnmQUQ0FETkaPgA9XHvZPOLfULQhvBKGaTx41chtN2EZJNnp1FmLfmHhmMkeJz/BeRNBFYbs4WRQSTNY2H06bL0A5iI5nN1Kk2gEzK5vxtIfgjeuGnseqBwUa8GwDEufnbVh/g2lFatEaaKrDHcou9M/Jwyrgm2c6eOzwqh0AdrAvVLQAk8ZvGJiI8HAeEnRjXjebeYGyJ85KsJkFHJqqU3UXs1OT0in3/6ON5G4W1OpMpR6Pkgb7w2W6JEYG/Kl2RxMaon4cpjorRIfYfkw6EkDqg0f3CbebL89CyiH+Bsl1I4j4Fk/KcwIELS2yvZB9UIACLL+IG4IpZd3LdVfkksQmaFCDdjl9bhl0F4YuXCYyT58u1PAtXFjQs3JzTJ3t56VNYnDTd8BlXxuXaL/LLrxgbNEWXQVRZR+Y3oOeMX4Wh6KmVDsXPwoZdvk/4MjHuk8C92D3HotD7sBC5yZyCxB2osk/JKa9HKpOD+cQ064h79YzW4FW3mQk3kHHl4x7ZUziXIzm2btAdTUHxNgOeMTKL/r7zQWwrLSt9e0boILLjDwZU4DFzBftPNgCoFuaGnN8lrUiyGoiDR+USQUdaKwn8+1zcvObc9rfZm/IfvGh/lLHhkMp7OsbfP6GIjHCdv9WDQoQqcyiV0gELyjtJk5YCjGrjCgnD//PYI1wY5UoAkP4fVsX2X3rpM9+Q48Em/Wwrj7vPOHw2HZ/bEJg464oFcINmjkmb5VOkrWRWILlcO9kI+eT7X2G3AvlROmluRf2isWx8UPCbjy3J99zF2rJdwJFMSCYfwOJJ0PEnhfdEhqrZ+vy8zZM72gmxmwy6qQ7Gg3T9Sr8qM3XqFsqk/5XA4F2/3tY b2CBvHlO gGBexW+FMClLRFgtklOEH7pOjNfxJCVKZ4GuVXMuzMbmrT1k/3I7GezoWXui2e0ZLfOUmAETVeX1LBbDb1Bi3E44nz1qWkPkiJfMMwrySQ0sm0ZuYzwvJYYLfJdQBMFdM9BqoRR7wvdY8X3Q= 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: Radix vmemmap mapping can map things correctly at the PMD level or PTE level based on different device boundary checks. Hence we skip the restrictions w.r.t vmemmap size to be multiple of PMD_SIZE. This also makes the feature widely useful because to use PMD_SIZE vmemmap area we require a memory block size of 2GiB We can also use MHP_RESERVE_PAGES_MEMMAP_ON_MEMORY to that the feature can work with a memory block size of 256MB. Using altmap.reserve feature to align things correctly at pageblock granularity. We can end up losing some pages in memory with this. For ex: with a 256MiB memory block size, we require 4 pages to map vmemmap pages, In order to align things correctly we end up adding a reserve of 28 pages. ie, for every 4096 pages 28 pages get reserved. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 28 +++++++++++++++++++ .../platforms/pseries/hotplug-memory.c | 3 +- mm/memory_hotplug.c | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 116d6add0bb0..f890907e5bbf 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -157,6 +157,7 @@ config PPC select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_KEEP_MEMBLOCK + select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if PPC_RADIX_MMU select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 68817ea7f994..8e6c92dde6ad 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -169,6 +169,34 @@ static inline bool is_ioremap_addr(const void *x) int __meminit vmemmap_populated(unsigned long vmemmap_addr, int vmemmap_map_size); bool altmap_cross_boundary(struct vmem_altmap *altmap, unsigned long start, unsigned long page_size); +/* + * mm/memory_hotplug.c:mhp_supports_memmap_on_memory goes into details + * some of the restrictions. We don't check for PMD_SIZE because our + * vmemmap allocation code can fallback correctly. The pageblock + * alignment requirement is met using altmap->reserve blocks. + */ +#define arch_supports_memmap_on_memory arch_supports_memmap_on_memory +static inline bool arch_supports_memmap_on_memory(unsigned long size) +{ + unsigned long nr_pages = size >> PAGE_SHIFT; + unsigned long vmemmap_size = nr_pages * sizeof(struct page); + + if (!radix_enabled()) + return false; + +#ifdef CONFIG_PPC_4K_PAGES + return IS_ALIGNED(vmemmap_size, PMD_SIZE); +#else + /* + * Make sure the vmemmap allocation is fully contianed + * so that we always allocate vmemmap memory from altmap area. + * The pageblock alignment requirement is met by using + * reserve blocks in altmap. + */ + return IS_ALIGNED(vmemmap_size, PAGE_SIZE); +#endif +} + #endif /* CONFIG_PPC64 */ #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 9c62c2c3b3d0..1447509357a7 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -617,6 +617,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) static int dlpar_add_lmb(struct drmem_lmb *lmb) { + mhp_t mhp_flags = MHP_NONE | MHP_MEMMAP_ON_MEMORY; unsigned long block_sz; int nid, rc; @@ -637,7 +638,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb) nid = first_online_node; /* Add the memory */ - rc = __add_memory(nid, lmb->base_addr, block_sz, MHP_NONE); + rc = __add_memory(nid, lmb->base_addr, block_sz, mhp_flags); if (rc) { invalidate_lmb_associativity_index(lmb); return rc; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f36aec1f7626..0c4d3fdd31a2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -2108,6 +2108,8 @@ static int __ref try_remove_memory(u64 start, u64 size) * right thing if we used vmem_altmap when hot-adding * the range. */ + mhp_altmap.base_pfn = PHYS_PFN(start); + mhp_altmap.free = PHYS_PFN(size) - nr_vmemmap_pages; mhp_altmap.alloc = nr_vmemmap_pages; altmap = &mhp_altmap; } From patchwork Tue Jul 11 04:48:32 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: 13308126 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 9C0EAEB64DC for ; Tue, 11 Jul 2023 04:49:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36B818E0006; Tue, 11 Jul 2023 00:49:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31B538E0001; Tue, 11 Jul 2023 00:49:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16E4A8E0006; Tue, 11 Jul 2023 00:49:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0AA568E0001 for ; Tue, 11 Jul 2023 00:49:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D74951C7FAC for ; Tue, 11 Jul 2023 04:49:44 +0000 (UTC) X-FDA: 80998103088.18.EB3CFD2 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf29.hostedemail.com (Postfix) with ESMTP id 99777120014 for ; Tue, 11 Jul 2023 04:49:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="eqyS98/V"; spf=pass (imf29.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=1689050982; 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=izAKLkGXW4KeySMlKO+lq28yrDcfXnzVthdmbn/zMFQ=; b=USybRpsuSWumSeihMWa1y0ibtwfG2nwloHq0aBovhveMRtvDPjKrAB2Su8AAkmO+6ID2jF RbwFm3pyHS3f0USeRewBQmymEKdgNDA4BxidBmJsd8oX2W+3D+CbUCHGkQplttSjQHXxby wUsUGRZ1QNKSZL7xvi1tJe4g+FRevVs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="eqyS98/V"; spf=pass (imf29.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=1689050982; a=rsa-sha256; cv=none; b=3T9r59QjpRLjsxuy7V3EHcXTY2MwrKUiKVwWXctjhjjMReX1PD/cPUQyVpYes6jr0WEg49 wBga87/wUpoKYELvATNG35kNYndjcKZXsr7DhMtkS1TIRJXMMF4biQD2/VqHeKw5XOEihW WcE1fgfim0wmmri9LECyJl6BqarASMI= 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 36B4kwjF016806; Tue, 11 Jul 2023 04:49:28 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=izAKLkGXW4KeySMlKO+lq28yrDcfXnzVthdmbn/zMFQ=; b=eqyS98/VjnrlSvhy86dKXl6ELjpYbS3P6rxJtEus+Fl1ZzujdgD4J6G+kakzx8KOPsTf b6WXDb58lua7Jk6FPTcVDQkDNrKOuWbpKq/JfSmAIIpkn96GvJlHYmIgg4BNUWreBP2j yCIfl4Do7J4xOPyOaXEejUaCW1HOSPjyjBbDhJGMJ/rrTHw0PT9uWIIbtlBo5S55NKtv 2sBABPmCyIc74UoK8grOp4GDRpdTRlZsF6YshrNmsDL91ajmURzF0KGCepH1x/IZD2GM 94FHswuBWGS/X7llC6nPFeIgcEyddqGjB++9XbWG4zbwf3JkaMKT11iPGmrIjcbTHW8D sA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg4g1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:27 +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 36B4kuF0016759; Tue, 11 Jul 2023 04:49:27 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs0btg4fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:26 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36AJnxOn026569; Tue, 11 Jul 2023 04:49:26 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([9.208.130.99]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3rpye5m6xx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:26 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4nOUs21561760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:24 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9351258067; Tue, 11 Jul 2023 04:49:24 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7EA25804B; Tue, 11 Jul 2023 04:49:17 +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:49:17 +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 , "Rafael J. Wysocki" , Len Brown , Dan Williams , Dave Jiang , Dave Hansen , Huang Ying , "Aneesh Kumar K . V" Subject: [PATCH v3 6/7] dax/kmem: Always enroll hotplugged memory for memmap_on_memory Date: Tue, 11 Jul 2023 10:18:32 +0530 Message-ID: <20230711044834.72809-7-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: oa8R27GieEOayLSVPDKzsgEAIl9wm7HA X-Proofpoint-GUID: dhygPK-lH0NzJ-5CMxb87fS1U4hSZ6Ai 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=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Queue-Id: 99777120014 X-Rspam-User: X-Stat-Signature: jgj5pdafh5e73j958a4hrcsipa4tkeac X-Rspamd-Server: rspam01 X-HE-Tag: 1689050982-271682 X-HE-Meta: U2FsdGVkX1+tX/GacISBzDVV0AoNYCuEK7dQAZq//5wjHUfQxVNrMNUzAs9pTAVxX7w4n0SN8j2xJ8vtLU6656rWEDnsCv8BlGIWEn9WGkiaLf6rRys4crdlvuudkCqJXti70Ws5D/oV1j+FkTnVuCuCmKeJ0/7SHd7xildZJOSRvpSGjJiWRl7SOgdbTUA4JOAaoukWHJsTWXe6iBaNg/yIf5nQMd3k2V4WjYapwm5aNm9ynHfsygcx73J88t2QJTCPz0lajWeIWWmWFCvSGyHyg5+Zf7XxH0bP4/Nt488rbuKIlxkEKFKpgMfWF5dyNslynRKQAtX8XIQ9/EEC8zCWHyHEfo/IfawGF+er3Q4x+172ZzV6hPmN4RvSSRTdLzQJnmocm9ceJ88bhrusfnGhMJfOsw9IqILyuuMyi0TzwkvzcdT/zwxxfaIzR6uMlQhgtPfsh4phJDpGtbrgZ3AgHLsl/fUTs3JmEAqpY4xvmiOjtFw6kN56uylIk9nvQAhpME5KNXWyAJe/OdmAyhOtAA7TP71LgCEtkgo0Tdpf1/IeK+TWB3yvs2q42LBO4jIYvLUIaErYDsQKHgdMNFQ8sU92OHQ4yfii9EeRQbW9k+hbmNY0yzjaGpoQRSNEYNfKzddigSqfbYJd6RzouVlPgGBaqDFJaEhYhdKA2JsHbjd/m14f3273x8FVKRhnUjbN4N9/kfuKdzSyXO8uzcT9Rc2kUfbhzXQFFj1MyyBV5N7JXNZw9wDy51cY2KpBiiv4s6cBwQsm88AJSr68Iz+rHf+oB7yiCdNm8FvtZuqVSx7fdHGRzD7RcRVglqEXIuaCUUxFlWSGLTE+k/QmYbfvGgtp1Wr46SYWglwWeq15jJmsYp+xCW+mDt8ZHlzgj5cnT5PS+s611ZhLOhlAIpclMq/u4VXlQ+68sY9PPtpTSNN3S25N3a/6eI1okgZu4um21cXGXnkKd5kfeCL SUq3u5EJ 589xrzEod1FzATEnAiTdEHi80WrIktGYKPfaB0lEJ/XIJWJ8JEYYtPz1E3tZ5PhKDAPSPIZliskU39a2ieWQRWg99DSZAiqrp6toUajIOb9NJU1xRn/OexA7c3jXPOF0O3I64iveA6zW6kcvAPi4+2dFQW43M7sy7ucjefRLBy+ogff1lxlY9qfuSAnK4Y1Iuj3NdJxuoVCe0mSIYtj7yKzj1F3TZTjzPZ+e+yAv9ZB7em8PAmxDED05zCUnqr81OFSosCiW/yKnWTLiJ9wil8VE9lmMZ6k1wq6HdeanwfBK8gAF3UqVZ1Wy7q3Tqw3SMCgL7oy3JMDEGr8Wzx9P22bORUIN14/R2BvhCzoVV8t6BJMs= 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: From: Vishal Verma With DAX memory regions originating from CXL memory expanders or NVDIMMs, the kmem driver may be hot-adding huge amounts of system memory on a system without enough 'regular' main memory to support the memmap for it. To avoid this, ensure that all kmem managed hotplugged memory is added with the MHP_MEMMAP_ON_MEMORY flag to place the memmap on the new memory region being hot added. To do this, call add_memory() in chunks of memory_block_size_bytes() as that is a requirement for memmap_on_memory. Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Andrew Morton Cc: David Hildenbrand Cc: Oscar Salvador Cc: Dan Williams Cc: Dave Jiang Cc: Dave Hansen Cc: Huang Ying Signed-off-by: Vishal Verma Signed-off-by: Aneesh Kumar K.V --- drivers/dax/kmem.c | 81 +++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 22 deletions(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index 898ca9505754..840bf7b40a44 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "dax-private.h" #include "bus.h" @@ -105,6 +106,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) data->mgid = rc; for (i = 0; i < dev_dax->nr_range; i++) { + u64 cur_start, cur_len, remaining; struct resource *res; struct range range; @@ -137,21 +139,42 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) res->flags = IORESOURCE_SYSTEM_RAM; /* - * Ensure that future kexec'd kernels will not treat - * this as RAM automatically. + * Add memory in chunks of memory_block_size_bytes() so that + * it is considered for MHP_MEMMAP_ON_MEMORY + * @range has already been aligned to memory_block_size_bytes(), + * so the following loop will always break it down cleanly. */ - rc = add_memory_driver_managed(data->mgid, range.start, - range_len(&range), kmem_name, MHP_NID_IS_MGID); - - if (rc) { - dev_warn(dev, "mapping%d: %#llx-%#llx memory add failed\n", - i, range.start, range.end); - remove_resource(res); - kfree(res); - data->res[i] = NULL; - if (mapped) - continue; - goto err_request_mem; + cur_start = range.start; + cur_len = memory_block_size_bytes(); + remaining = range_len(&range); + while (remaining) { + /* + * If alignment rules are not satisified we will + * fallback normal memmap allocation. + */ + mhp_t mhp_flags = MHP_NID_IS_MGID | MHP_MEMMAP_ON_MEMORY; + /* + * Ensure that future kexec'd kernels will not treat + * this as RAM automatically. + */ + rc = add_memory_driver_managed(data->mgid, cur_start, + cur_len, kmem_name, + mhp_flags); + + if (rc) { + dev_warn(dev, + "mapping%d: %#llx-%#llx memory add failed\n", + i, cur_start, cur_start + cur_len - 1); + remove_resource(res); + kfree(res); + data->res[i] = NULL; + if (mapped) + continue; + goto err_request_mem; + } + + cur_start += cur_len; + remaining -= cur_len; } mapped++; } @@ -186,25 +209,39 @@ static void dev_dax_kmem_remove(struct dev_dax *dev_dax) * unbind will succeed even if we return failure. */ for (i = 0; i < dev_dax->nr_range; i++) { + + u64 cur_start, cur_len, remaining; struct range range; + bool resource_remove; int rc; rc = dax_kmem_range(dev_dax, i, &range); if (rc) continue; - rc = remove_memory(range.start, range_len(&range)); - if (rc == 0) { + resource_remove = true; + cur_start = range.start; + cur_len = memory_block_size_bytes(); + remaining = range_len(&range); + while (remaining) { + + rc = remove_memory(cur_start, cur_len); + if (rc) { + resource_remove = false; + dev_err(dev, + "mapping%d: %#llx-%#llx cannot be hotremoved until the next reboot\n", + i, cur_start, cur_len); + } + cur_start += cur_len; + remaining -= cur_len; + } + if (resource_remove) { remove_resource(data->res[i]); kfree(data->res[i]); data->res[i] = NULL; success++; - continue; - } - any_hotremove_failed = true; - dev_err(dev, - "mapping%d: %#llx-%#llx cannot be hotremoved until the next reboot\n", - i, range.start, range.end); + } else + any_hotremove_failed = true; } if (success >= dev_dax->nr_range) { From patchwork Tue Jul 11 04:48:33 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: 13308125 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 3A66CEB64DD for ; Tue, 11 Jul 2023 04:49:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2ECD8E0002; Tue, 11 Jul 2023 00:49:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDF678E0001; Tue, 11 Jul 2023 00:49:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B802B8E0002; Tue, 11 Jul 2023 00:49:42 -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 A61A58E0001 for ; Tue, 11 Jul 2023 00:49:42 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 77A53C01D6 for ; Tue, 11 Jul 2023 04:49:42 +0000 (UTC) X-FDA: 80998103004.27.12285F2 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf30.hostedemail.com (Postfix) with ESMTP id 399268000C for ; Tue, 11 Jul 2023 04:49:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=KJ7+NaAp; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf30.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=1689050980; 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=eacDrbdl29DxFhYva5Qa/VnwoE6kPv96SsaOfM9iVK8=; b=CFUNGR8ol9sloWR018k7leMkHzYmvlfhMO8di2khteOq4MkenkGoLuk2sAArbuD2q0UFIh 5wK85XahD5EGrxgZTMsUjFx0kGqnAbCZ2i4XH1Nmcruf6Gd46FAiZV7tNJo9ZcZJf3L15h lJYY4KpG8c2rtiLBOJLYFhhavR/9pHA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=KJ7+NaAp; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf30.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=1689050980; a=rsa-sha256; cv=none; b=Og8EzKrp0Vug/uskzjTvbvviBO3i2QhuO4Y/OL3DeF4KaY9AfT1XmAj5KsQCMvbCnKQYPb 2F2kgOhpomKF96YUr70H5W0AmexU4c3Oe/hmHWpsGcFlLN//Oog9c76q2kYKX3odEhi+9O 3M7/Yi/J6ex+dVjc4GyWMvCXyL8PeUk= 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 36B4dAhl028675; Tue, 11 Jul 2023 04:49:33 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=eacDrbdl29DxFhYva5Qa/VnwoE6kPv96SsaOfM9iVK8=; b=KJ7+NaApI9zWgMOH8hpNhh6W+YbFGRBfkcSk5FZycQg8/kKSScp8geXmdRubJi5yDEAd IQyXFJseWPpQTIqe+ovzu7qCL9jvwZTHNaHXUSlaQGyShaIu+gZ/j4W0O0814raSRU8z ek7Fdcn5E53MMTQ0JA4WPyjrc0nBogWxgMxJeMqaxNmda6e80eybJbai3rtA7BuAQhyq 0MOUQmRXFBvxtzakxAY+l5ti8CoZJdJIhIA0d7JPVC2ASCTLCRDfGAb6WfdGVMgI+EMX DHGiYgJl5a+uDnmuAxxgl8/5vYbba2bfl4wbDeBso/LU/do4iALPtJIB70FLl4Y1tFOF IA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:33 +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 36B4k2SE022906; Tue, 11 Jul 2023 04:49:32 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs085gdq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:32 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4isnb027325; Tue, 11 Jul 2023 04:49:31 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([9.208.129.114]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3rpye654vb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 04:49:31 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36B4nUaN32178704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 04:49:30 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 537405804B; Tue, 11 Jul 2023 04:49:30 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66FD15805B; Tue, 11 Jul 2023 04:49:25 +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:49:24 +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 7/7] mm/hotplug: Embed vmem_altmap details in memory block Date: Tue, 11 Jul 2023 10:18:33 +0530 Message-ID: <20230711044834.72809-8-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: t2kWuIOWjE3PtaxHweABZiJ1AaXIKpAx X-Proofpoint-GUID: alyn84FG50u2HhQsCbuZAtw8sCs7Emcm 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 mlxlogscore=694 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110040 X-Rspamd-Queue-Id: 399268000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: n4w3mcrtahs63pmo4njerwewd7o18st4 X-HE-Tag: 1689050980-893005 X-HE-Meta: U2FsdGVkX18QP+ZfQ7if/lkuRP1sZMJbvgU4q12jm5icl6RXXjDFvPBPLBzfPQfCcJtgGOIFviNxvz3mC9QwO/dmYPUltzWwZJuEyNZoHrpHU2WrQJidBfpOn/X7RqtKvg4++pMU6DkUX+2+QoNwJ3VBRAPEWF17OnJ5w2A4UtZwnj8hFCqMAefrHKF8n06RroNyttRbzhGNCzs4LDFLCEmzSSlz7mXE7i9AlQJzKTjv4wX7ye4rbmLlcxFhbAVSwbYO4Vopp1Q6pWFPCyaoJiCajk7lYIYAi13fG+4OWjHZnx4NCCRabrT1mrMI+/+kYb/HpeT53MZD56g4tvRVwkAmYuixYn8PZpuvwdrS+Vl/VSWQ+J8PVgfN4ySTOrmaHOxPnY8hh+M6ifmfwZ5j510sS/BIk3VSAJ2wlq3+BPcYfrgjFT+uo5ZYaoHohArsuXcnt0pA2a/o5V5Qt3KqqgiANwcLG1none9rTfucbjAqwCy2ViGl0GyxrutfeR40mC7zse1+My41qlvHONpXMcPuzO0L1UBfMmUUniaAenxM1104ISnM8YrAm6UDE0QlOborbk6f+WA8K9jCB5tYCOY7vB2Nl9Z6l0s2UFyN1HbSS3xxudQUZlR8mVCVikoIN8xBFD7GSrRxVc9DSRSYnHlLGfcpABZEUVaPJQHO6J8XwGtF3wjbbc/qrAZtdNaz90btKqiPptXfAK14oUjKVdtGam/62ganVWSrrwRGiVwjoTRq2VpiAK74Ctw//1eC8F/ci2/+yPLw9kD6LTNHt3NMibRDh0wmZHLR8bkNYWk2RQLofJd0ndeAPkMNrI4oXOHhXQ9nC/XcSfweaF9Y99T2Y+vuuykAtuIiVcHOusYYdW9JMZ6vFns4jinYDj27/NJpvnalsLpIcwNlY2fchmSiqCzDO27F87o186KIuC7r5ilkuw5aCS2l3gpjkS05Vm/iBuYJ1Ew8028rFul Pga+RWuR vp1xGjWpSC6jN/UWzpjT1PTFN4U7HQzWjNQ1qR4hP2r8xRLKGNtxelcHBQyZF0vDMajaYNbB+2cE4UeC4K5CoEYKBTZYBtaTrYlynn2MuSYNJ3rQRPXrM7aFFel55wW7dQ2xwe0KsfnGaqKJfvzJpDkxTsy2OwUUkspnOUXG5GT03G3O4z1nlX0YmTv00spHNYFY1 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: With memmap on memory, some architecture needs more details w.r.t altmap such as base_pfn, end_pfn, etc to unmap vmemmap memory. Instead of computing them again when we remove a memory block embed vmem_altmap details in struct memory_block if we are using memmap on memory block feature. No functional change in this patch Signed-off-by: Aneesh Kumar K.V --- drivers/base/memory.c | 35 ++++++++++++++++++++++++++--------- include/linux/memory.h | 8 ++------ mm/memory_hotplug.c | 34 ++++++++++++++-------------------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..10aacaecf8de 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -106,6 +106,10 @@ static void memory_block_release(struct device *dev) { struct memory_block *mem = to_memory_block(dev); + if (mem->altmap) { + WARN(mem->altmap->alloc, "Altmap not fully unmapped"); + kfree(mem->altmap); + } kfree(mem); } @@ -183,7 +187,7 @@ static int memory_block_online(struct memory_block *mem) { unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; - unsigned long nr_vmemmap_pages = mem->nr_vmemmap_pages; + unsigned long nr_vmemmap_pages = 0; struct zone *zone; int ret; @@ -200,6 +204,9 @@ static int memory_block_online(struct memory_block *mem) * stage helps to keep accounting easier to follow - e.g vmemmaps * belong to the same zone as the memory they backed. */ + if (mem->altmap) + nr_vmemmap_pages = mem->altmap->alloc + mem->altmap->reserve; + if (nr_vmemmap_pages) { ret = mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone); if (ret) @@ -230,7 +237,7 @@ static int memory_block_offline(struct memory_block *mem) { unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; - unsigned long nr_vmemmap_pages = mem->nr_vmemmap_pages; + unsigned long nr_vmemmap_pages = 0; int ret; if (!mem->zone) @@ -240,6 +247,9 @@ static int memory_block_offline(struct memory_block *mem) * Unaccount before offlining, such that unpopulated zone and kthreads * can properly be torn down in offline_pages(). */ + if (mem->altmap) + nr_vmemmap_pages = mem->altmap->alloc + mem->altmap->reserve; + if (nr_vmemmap_pages) adjust_present_page_count(pfn_to_page(start_pfn), mem->group, -nr_vmemmap_pages); @@ -726,7 +736,7 @@ void memory_block_add_nid(struct memory_block *mem, int nid, #endif static int add_memory_block(unsigned long block_id, unsigned long state, - unsigned long nr_vmemmap_pages, + struct vmem_altmap *altmap, struct memory_group *group) { struct memory_block *mem; @@ -744,7 +754,14 @@ static int add_memory_block(unsigned long block_id, unsigned long state, mem->start_section_nr = block_id * sections_per_block; mem->state = state; mem->nid = NUMA_NO_NODE; - mem->nr_vmemmap_pages = nr_vmemmap_pages; + if (altmap) { + mem->altmap = kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL); + if (!mem->altmap) { + kfree(mem); + return -ENOMEM; + } + memcpy(mem->altmap, altmap, sizeof(*altmap)); + } INIT_LIST_HEAD(&mem->group_next); #ifndef CONFIG_NUMA @@ -783,14 +800,14 @@ static int __init add_boot_memory_block(unsigned long base_section_nr) if (section_count == 0) return 0; return add_memory_block(memory_block_id(base_section_nr), - MEM_ONLINE, 0, NULL); + MEM_ONLINE, NULL, NULL); } static int add_hotplug_memory_block(unsigned long block_id, - unsigned long nr_vmemmap_pages, + struct vmem_altmap *altmap, struct memory_group *group) { - return add_memory_block(block_id, MEM_OFFLINE, nr_vmemmap_pages, group); + return add_memory_block(block_id, MEM_OFFLINE, altmap, group); } static void remove_memory_block(struct memory_block *memory) @@ -818,7 +835,7 @@ static void remove_memory_block(struct memory_block *memory) * Called under device_hotplug_lock. */ int create_memory_block_devices(unsigned long start, unsigned long size, - unsigned long vmemmap_pages, + struct vmem_altmap *altmap, struct memory_group *group) { const unsigned long start_block_id = pfn_to_block_id(PFN_DOWN(start)); @@ -832,7 +849,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size, return -EINVAL; for (block_id = start_block_id; block_id != end_block_id; block_id++) { - ret = add_hotplug_memory_block(block_id, vmemmap_pages, group); + ret = add_hotplug_memory_block(block_id, altmap, group); if (ret) break; } diff --git a/include/linux/memory.h b/include/linux/memory.h index 31343566c221..f53cfdaaaa41 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -77,11 +77,7 @@ struct memory_block { */ struct zone *zone; struct device dev; - /* - * Number of vmemmap pages. These pages - * lay at the beginning of the memory block. - */ - unsigned long nr_vmemmap_pages; + struct vmem_altmap *altmap; struct memory_group *group; /* group (if any) for this block */ struct list_head group_next; /* next block inside memory group */ #if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG) @@ -147,7 +143,7 @@ static inline int hotplug_memory_notifier(notifier_fn_t fn, int pri) extern int register_memory_notifier(struct notifier_block *nb); extern void unregister_memory_notifier(struct notifier_block *nb); int create_memory_block_devices(unsigned long start, unsigned long size, - unsigned long vmemmap_pages, + struct vmem_altmap *altmap, struct memory_group *group); void remove_memory_block_devices(unsigned long start, unsigned long size); extern void memory_dev_init(void); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0c4d3fdd31a2..f22831eaa93f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1386,8 +1386,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) goto error; /* create memory block devices after memory was added */ - ret = create_memory_block_devices(start, size, mhp_altmap.alloc + mhp_altmap.reserve, - group); + ret = create_memory_block_devices(start, size, params.altmap, group); if (ret) { arch_remove_memory(start, size, NULL); goto error; @@ -1988,12 +1987,18 @@ static int check_memblock_offlined_cb(struct memory_block *mem, void *arg) return 0; } -static int get_nr_vmemmap_pages_cb(struct memory_block *mem, void *arg) +static int get_vmemmap_altmap_cb(struct memory_block *mem, void *arg) { + struct vmem_altmap **altmap = (struct vmem_altmap **)arg; /* - * If not set, continue with the next block. + * If we have any pages allocated from altmap + * return the altmap details and break callback. */ - return mem->nr_vmemmap_pages; + if (mem->altmap) { + *altmap = mem->altmap; + return 1; + } + return 0; } static int check_cpu_on_node(int nid) @@ -2068,9 +2073,8 @@ EXPORT_SYMBOL(try_offline_node); static int __ref try_remove_memory(u64 start, u64 size) { - struct vmem_altmap mhp_altmap = {}; + int ret; struct vmem_altmap *altmap = NULL; - unsigned long nr_vmemmap_pages; int rc = 0, nid = NUMA_NO_NODE; BUG_ON(check_hotplug_memory_range(start, size)); @@ -2093,25 +2097,15 @@ static int __ref try_remove_memory(u64 start, u64 size) * the same granularity it was added - a single memory block. */ if (mhp_memmap_on_memory()) { - nr_vmemmap_pages = walk_memory_blocks(start, size, NULL, - get_nr_vmemmap_pages_cb); - if (nr_vmemmap_pages) { + ret = walk_memory_blocks(start, size, &altmap, + get_vmemmap_altmap_cb); + if (ret) { if (size != memory_block_size_bytes()) { pr_warn("Refuse to remove %#llx - %#llx," "wrong granularity\n", start, start + size); return -EINVAL; } - - /* - * Let remove_pmd_table->free_hugepage_table do the - * right thing if we used vmem_altmap when hot-adding - * the range. - */ - mhp_altmap.base_pfn = PHYS_PFN(start); - mhp_altmap.free = PHYS_PFN(size) - nr_vmemmap_pages; - mhp_altmap.alloc = nr_vmemmap_pages; - altmap = &mhp_altmap; } }