From patchwork Tue Aug 8 09:14:56 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: 13345889 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 0DE96C04A94 for ; Tue, 8 Aug 2023 09:15:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A9126B0074; Tue, 8 Aug 2023 05:15:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 831836B0075; Tue, 8 Aug 2023 05:15:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 637658D0001; Tue, 8 Aug 2023 05:15:24 -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 4B0336B0074 for ; Tue, 8 Aug 2023 05:15:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0883A40C83 for ; Tue, 8 Aug 2023 09:15:24 +0000 (UTC) X-FDA: 81100378968.01.3BD6712 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf28.hostedemail.com (Postfix) with ESMTP id 9DAABC0028 for ; Tue, 8 Aug 2023 09:15:21 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=FSVpmLm8; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.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=1691486121; a=rsa-sha256; cv=none; b=CIZM1hAxxudiMh3AWSlfGyVVzhDa9gO+2p6IT+HU7c3oZ+forYP6HDHKIt8giVNqAjTBY3 kE+UBJUgPZeggbYc7/Kf0Vtp/il0Q0sowB/YJAJFqw/Of4jOvYPI2bgwxv3T18wVqh23p6 weOJ4alnq7TkM7j2ZOHrOuz9hF6JQxM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=FSVpmLm8; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.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=1691486121; 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=eUj6SooswbSssTf+siMtVhIFc1VnmxrknO53WAz9LiQ=; b=hJVVBPw/8G8+nQRc22FzqWRtR37CfsJnL3Ip7pjZm4nYcY77qQ76bU7ySZ1BaYhmAjbfZy iWej72H6dlFYoJxu/2vJXY/dsrRkf3xPcZ9vkaUcM4w4JLA9tT/amvHRdSdQbiMXA9K1/F 1uBCkqBdXedKFSmyL4xorgAAZJAT+wI= 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 3789CfTG027798; Tue, 8 Aug 2023 09:15: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=eUj6SooswbSssTf+siMtVhIFc1VnmxrknO53WAz9LiQ=; b=FSVpmLm88psbwBxEkchsyrYGar+d63DnsZlplFqfEZSSlyXJR+VvLL7BkGSfgs7ETvRs X5GQjEPg9BIXXxteWCl7wl6+FYBWpi4fpzo5lkreSEupOcvgskSKZOUDB4DqXF0IpDLP pGgVMJK6/31UmwjTsGEPceLPslvA4mGvVUXY2YaSLS64e728CBdI+oV0BTBIGwCTDvCX 4NUWGUGHVrGNb8vvOK+bZboSSRcmgN7jWBJs/Q78uPc/MF7yTPnxMv9kUZxhligCuRE1 WHsLx3j66RKnsKLG57PHcUn3CXWYOzXoP4vfbojQuke0cD9646nG5hlWv6hMYtBMQLkm JA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjn8097c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:14 +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 3789Ckpx028080; Tue, 8 Aug 2023 09:15:14 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjn80970-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:14 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3788qZbM030348; Tue, 8 Aug 2023 09:15:13 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa1rn55h3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:13 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FCU531261268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:12 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A005C5803F; Tue, 8 Aug 2023 09:15:12 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6BC4158064; Tue, 8 Aug 2023 09:15:09 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:09 +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 v8 1/6] mm/memory_hotplug: Simplify ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE kconfig Date: Tue, 8 Aug 2023 14:44:56 +0530 Message-ID: <20230808091501.287660-2-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Kyb7Rlef4fcADFibeT6fdG9PIy1iyosr X-Proofpoint-ORIG-GUID: UqjyfyjD34Vu2EQE4peVTv_qhBP4oDXx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxlogscore=674 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9DAABC0028 X-Stat-Signature: 7eokbf9m4a8w814akq65am6c4sxcnp1e X-HE-Tag: 1691486121-889175 X-HE-Meta: U2FsdGVkX1/5KX0ialYKxtkLW170X0BeacfnXkuP0RBxmGpQf3may8nYLXcg3Lk+xDBwvB1p0PT4znvA5Ne8WdGUEvVOR/Fpyv+cVNZmecQYPN9Wh0XrJKhC1E/eOV2fDif4vRsWFmmYv/JVtHuQNyc1GWtHMZXuFPe1vRj47YBKdLFRMGQXHmCC6nsYDr/x46++vTEz0va41cmOTyPVTMkMvGcHOyMaJKi3w2qoys6kDlxSlAyffARUHDQsrRQyV0DLaGpdlH7p+DndxbxBHW/Tb2mA0PvRS05ttR7l7VpCuQWOEwACGZWyMWPXkuEV8ussQXuBxjTEj/AAStz2OdDuo87ENNwWmu0mGPM7r2hSsOADoXLry34BJmHraAWnI05b4kbW6IrG1KAorQmWPIdMmwwobMSxiyTeK3wIIGoROvnsGWodhnHD4bFG6/fhWPeW1PlBLXews8TUN9jZM15G6a8N3Pt3ypiLTm66mCcdPu8ICyNrdoHYNILdj8go15f7OQWYJikOEdUbaYsjE+UlEJwmMAFdtytzkdtFbKhoEJxJL5BNKHP2PxcG1K8cncUvVZYBGaXRq6XC5baeyMBqUgEv/5xvnI/GYxoAsgElIwzHhh8HT4aFCSe13ycz7QUPjtW0jE4GmPwo6C2+9nYp4JHvCFB1CBt7H/gKF1aCYt0FM+GIik7aHQLifKw4hGXwPRmsrH71yPU1qokswHjyJ2RlLzHqTAkWgPqVXcnYEloa7Sed5SVUepPbYjoR+a/B1EdUYsmrxC0FwP3GSRXrXZ7hfxwyYSKAuhU82X8rqtQ7BgGPeIZzNLQ6/TreKQSArqxpK7DU2+YuduIyQKV3JLj2Lb3NiTYBdzX+pHpkbqG+fvBqMZ4owzUsx4IclPa1SAySm0sp/buTUF3obb3r0V+Q9I77AGUP4tljXWLrXZ445wfhgP2xOGPeZSxkpsXYKyOkkPI5g2+CVb3 gRGRz2tt UbeLzD8UrU0TyMakKvg+1q6fLjiWhkOCVIKT4ucP5TaaWT3zmQVRONMMqN1uNUlifiyeHp+BOAFje5CI80xqqmYekqaHu4PIY3Pf1WmoLhvjQCdjFnkx1Wj25CFQTvMD6fhiMV/ouI8yjwkISfp2AVaiLiz57CaNVndF7O1wSo7YjAF87iBORFdfZG1jLQTeJvhq/d0BidNztuZxnPalWyb5/DaU47EjM+/ZMFXUT89ZdXmqJzD4sCZsuYwnTarzjYAlgImBUD+ApRcc= 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: Michal Hocko 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 b1573257a4d6..0f749cfab8e6 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 @@ -347,9 +348,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 5fe49c030961..721dc88423c7 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -571,6 +571,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 Aug 8 09:14:57 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: 13345895 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 3ACEFC001B0 for ; Tue, 8 Aug 2023 09:34:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFC946B0074; Tue, 8 Aug 2023 05:34:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAC776B0075; Tue, 8 Aug 2023 05:34:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B75BC8D0001; Tue, 8 Aug 2023 05:34:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A7DD46B0074 for ; Tue, 8 Aug 2023 05:34:08 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 77238B163A for ; Tue, 8 Aug 2023 09:34:08 +0000 (UTC) X-FDA: 81100426176.01.2148D14 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf09.hostedemail.com (Postfix) with ESMTP id 1EEBF140019 for ; Tue, 8 Aug 2023 09:34:05 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bCYQvryZ; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf09.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=1691487246; 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=tyTQZF8WZbk6E9JH+rrRWf58Awf2yhaBpYeGQE6gY3g=; b=BM7DyNxMTPC+rCxGOGTKHvo5nqrkvI5vTYci+6yx3N8SgH+CST9ixR5ktfEvDQ3boT0WGb Xwl+C2eqLBj3zGbkeQSijZWLAiVFCe08vt7a32YtUj3u8XWtIF8cwfQVWV2FhmiVC1evR8 vlDdn5Ag1kN1VA8BI+0PSkN9Gpm16VM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bCYQvryZ; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf09.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=1691487246; a=rsa-sha256; cv=none; b=insfhzh9OiHlckJkKXtizTcwfY7/FiBjnx/TGICBwV0Y+WtgI0AZDsRQX5cbbW5He7PyPo HThVjVHZ7ANctuW2tfxuI6IIAkv6uqNbellIVUlbGEpz4/IRbDODJebLW69TyopkYlKS7j /cF2KwOQ47yw9mHCXtnsngFaHmqxyfs= 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 37898kfe010793; Tue, 8 Aug 2023 09:15:19 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=tyTQZF8WZbk6E9JH+rrRWf58Awf2yhaBpYeGQE6gY3g=; b=bCYQvryZ7MGCsbVaq04id0wXwVt0TLPdwfeoyi1DrtGcSWpypZiHwzvTcxrCNIxal2AT cQN0kre1yD9b91y1NB5tyVW4/+kYPDVRzQCDt0lvutXlTubvP8D9jHcPlKZEctbiRjXk 24N55T+6EDqH5JT1cXjAcCpgzHe53G2xXDz887aINWbwugD3R24SdzhmsDblFF/IIbNz i1jCK6yuNraCp0jWktCO+EVMAoC/esc9clTGWn9kKvZnMuwYWCDjeGyL9vjFVStRnsWG 3Vj7gSAcPz9wf8VMFkV018zisYLmV0Ze63VYuxTTJ2pizdxCNLfjTY60TtYoMOwNnG1J Eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpt8ftg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:18 +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 37898r3Q011546; Tue, 8 Aug 2023 09:15:18 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpt8ft3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:17 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3788KpXt007573; Tue, 8 Aug 2023 09:15:17 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa14y5f9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:17 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FGuu34996768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:16 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A8295805A; Tue, 8 Aug 2023 09:15:16 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 251465803F; Tue, 8 Aug 2023 09:15:13 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:12 +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 v8 2/6] mm/memory_hotplug: Allow memmap on memory hotplug request to fallback Date: Tue, 8 Aug 2023 14:44:57 +0530 Message-ID: <20230808091501.287660-3-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3LR2yuBc6OHoWk6QbaVAeEqDNYKc2CH4 X-Proofpoint-ORIG-GUID: OlOahb-5vcLFQmoPwH1n99cOoHU90Qhn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=934 adultscore=0 impostorscore=0 mlxscore=0 spamscore=0 phishscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspamd-Queue-Id: 1EEBF140019 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: zsa7946co985dp6wp6mbmq6x4rgywxdt X-HE-Tag: 1691487245-489572 X-HE-Meta: U2FsdGVkX18Hqf3tw4gKoMsqenod4JOsBswix9pt/ZyvhLMUP1yAs4KIuX42S61RwA1vldGHepI+yxHMA2N9LgWrZL3CaMY7yvIQEOe42Zh7lpvWBbcGQG0LZPhzWJc1QbR+jV/MV2KTlsJLVbxE6h+W2WrFeqlNedRsH6JnUKqdq3e1kz7PFOrvdy0Chpo9PpIAYKURlP1kQ7DyFt0L2EJtb6GQqskGcGPzMKwzEoMY9pvbkFUeIkEAk3VNiISMPQbf5iiphiJG1zddt+2Ni8GJEonnhIoDSKlG6m5ELY27w22r54B96gzNwEJV98CHjpqt7QSw9oW4xi0bav+0GXqeZyt7xe+D1go6PpP1c+7Cmb85oPNDyviwlFLIwkFGKTeUlCav9+RvhIaT4ZD+x7+SnqMxAJTQHtftwEFUH4QoYlPd64urmKwJw6NzsoK41MV0eBxpdV27aipT6fj4txSRogWrhfT13p4T4wmbYziMI+8rO7sZE8e8e1Zt1RK3uSzK0dtZ/56vUYr9nRjYjDNERqy0E/roCQFOujOchhrWoLxLrSUdoXomKSfRGI7xRSijuuQJAF843gn0ubySjhd5GZi8cExkLNHqZFolnrhKs/QPOHUmDLxzmKzmO3zP/17Od56o8iWCRflSSDF507HJsMyrW+Y8ECPQzTvlR8lz7Lrw6htdNRzdr6pdVVH0FJfJ+7sAIJTLCoIJfyfkFBaLXohyCo8Q8UrUlb1QJxO7f2aGqAfdAT2W4riic9nyd8tF1nylIp+WFUdpib2VtzavesC+0sOCFA/S4/qvFLNHR34+s/shiCJC4p2gpFQ0o0d2dG2DfiO7knkI1npB82RvtUWhyarYztY15NeAFmIsAjyjNAaZQzGFhTobFGWVe2DhPt++nWHw/9pdgG4H1iNgalV31k4FofFTZYOVwEvBGsKikg+g9AoC8TYXZbW4aw3BADvLxPtuxpEJ3Fx hHBtLMa1 /5AYmniYO4Wxlg1QxtgqvDD1/eo0RiLQO+Qmmzr0ja4gARkk0DDgDyExquZXf/r6fTEF9k+VW7xeUfQ0HWcyhV7fWqduFTJWL1yc4wFmwZjhKMS3TisViEUG9PBEVOIfU1IXeKstbi4owyte6QCYxWUEGlz2i2eh+T9FbKPX/HOpQCcrLeIx67VCMpbqJEnTqbzJR3F9PLQacOaoCrxKDIvNxVQotDCAJWIxb61mIkwF5YPo8iYIJ5jgaTiKU3FJJS3ZKyDUYVmRzyrs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If not supported, fallback to not using memap on memmory. This avoids the need for callers to do the fallback. Acked-by: Michal Hocko Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- drivers/acpi/acpi_memhotplug.c | 3 +-- include/linux/memory_hotplug.h | 3 ++- mm/memory_hotplug.c | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 24f662d8bd39..d0c1a71007d0 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -211,8 +211,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) if (!info->length) continue; - if (mhp_supports_memmap_on_memory(info->length)) - mhp_flags |= MHP_MEMMAP_ON_MEMORY; + mhp_flags |= MHP_MEMMAP_ON_MEMORY; result = __add_memory(mgid, info->start_addr, info->length, mhp_flags); diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 013c69753c91..7d2076583494 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -97,6 +97,8 @@ typedef int __bitwise mhp_t; * To do so, we will use the beginning of the hot-added range to build * the page tables for the memmap array that describes the entire range. * Only selected architectures support it with SPARSE_VMEMMAP. + * This is only a hint, the core kernel can decide to not do this based on + * different alignment checks. */ #define MHP_MEMMAP_ON_MEMORY ((__force mhp_t)BIT(1)) /* @@ -354,7 +356,6 @@ extern struct zone *zone_for_pfn_range(int online_type, int nid, extern int arch_create_linear_mapping(int nid, u64 start, u64 size, struct mhp_params *params); void arch_remove_linear_mapping(u64 start, u64 size); -extern bool mhp_supports_memmap_on_memory(unsigned long size); #endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* __LINUX_MEMORY_HOTPLUG_H */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7cfd13c91568..eca32ccd45cc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,7 +1247,7 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } -bool mhp_supports_memmap_on_memory(unsigned long size) +static bool mhp_supports_memmap_on_memory(unsigned long size) { unsigned long nr_vmemmap_pages = size / PAGE_SIZE; unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); @@ -1339,13 +1339,12 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) * Self hosted memmap array */ if (mhp_flags & MHP_MEMMAP_ON_MEMORY) { - if (!mhp_supports_memmap_on_memory(size)) { - ret = -EINVAL; - goto error; + if (mhp_supports_memmap_on_memory(size)) { + mhp_altmap.free = PHYS_PFN(size); + mhp_altmap.base_pfn = PHYS_PFN(start); + params.altmap = &mhp_altmap; } - mhp_altmap.free = PHYS_PFN(size); - mhp_altmap.base_pfn = PHYS_PFN(start); - params.altmap = &mhp_altmap; + /* fallback to not using altmap */ } /* call arch's memory hotadd */ From patchwork Tue Aug 8 09:14:58 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: 13345890 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 CFAFEC001DF for ; Tue, 8 Aug 2023 09:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59C626B0075; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54B5D6B0078; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EC6F8D0001; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2F75D6B0075 for ; Tue, 8 Aug 2023 05:15:32 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F0106140BFA for ; Tue, 8 Aug 2023 09:15:31 +0000 (UTC) X-FDA: 81100379262.29.FD74F81 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf02.hostedemail.com (Postfix) with ESMTP id B091A80027 for ; Tue, 8 Aug 2023 09:15:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nFshiSnJ; 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=1691486129; 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=Uym2Ib4yS6cvP//xSpA4G+vKrmClYZ/jTf92DopX4wI=; b=tCIM5Ovcl/nn8nGCPdwgdI796edvE5Vdvd8d4kSN8k0oB+XhXFUnWPBugAlYx/e7ui6cIJ JFJlcg9dmYF424zDK4IJo6ruQ3k803mrMZA+/u/+oZrM4EN/OqLwat+FNFlisNQKwG2DDw /fKknpegPUWNnKtRo6gqPF76skE55LE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691486129; a=rsa-sha256; cv=none; b=qJzoPLsb2y54Y8BATYgXagzRrPrEh7AbkwY+KoqNNkKcLKJXRHCLUZDgbzMeks3CwauFnR UjfGihG98KPI5sWtSNsOcYuAmJmS7bJHw/jKxprNe7yJYI7u0BUzQFKr0SmbOKF3Y84iOh xabXfIfG79ZuVlKj+23UZAxeshr8SX8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=nFshiSnJ; 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 (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3789AgcK005289; Tue, 8 Aug 2023 09:15:23 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=Uym2Ib4yS6cvP//xSpA4G+vKrmClYZ/jTf92DopX4wI=; b=nFshiSnJXL/jYixi+6SU+HrqtE5PAHbHVeetcFRYrzQUiDPs+u09Z+4VSVTLjLssQ4/G aO/BycTuCFySTKu2cAtWNfNRH/4bvwgGy/oxQn4rmcJf1wP+tex93yIK0JIxB2DsWJri V0Vr25uL49dONmQdgqPR4hfDiGS222FAIVvcOJtxiYrwapuxxF2SjF5YaZ0pC2Lddf55 gTfg1kFyCi2BYgk9Dw5GfImXXnNh8nrX7e1fSzwehfqYJ2lzhq+jrHuT8gQfCEmZ3yD0 NY6H+6pH0MnZzViAsZcmfAmU3PtE5cguLryrWkzb36wzopg3AY3F+9ZIjQibXXGmRzQ5 wg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpvr8wj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:22 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3789FLp4027524; Tue, 8 Aug 2023 09:15:21 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjpvr8w6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:21 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37896xQ3030379; Tue, 8 Aug 2023 09:15:20 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa1rn55hy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:20 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FKMS24183088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:20 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 146925805A; Tue, 8 Aug 2023 09:15:20 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D39C158063; Tue, 8 Aug 2023 09:15:16 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:16 +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 v8 3/6] mm/memory_hotplug: Allow architecture to override memmap on memory support check Date: Tue, 8 Aug 2023 14:44:58 +0530 Message-ID: <20230808091501.287660-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0lsKjxdJ7j-98BK5bmCHRNtDqvloK3Us X-Proofpoint-GUID: JqxU4V-9hljRbw6__j7VqJmrm2rU8Sir X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspamd-Queue-Id: B091A80027 X-Rspam-User: X-Stat-Signature: fpaypbhn1st94cs6smd89ae1pckxoukz X-Rspamd-Server: rspam03 X-HE-Tag: 1691486129-228136 X-HE-Meta: U2FsdGVkX1/2Ax9OS4FpyjjIxAi4USKGAlrYIFeM/uP6OBr1+4Afg7qAgiKN+mADfn872QqCmKzwhMc8C4ct9ZlXcoVy0sensmHaMqS2n2EANHUhziVwb9g3XqJypAfbwmCHBSO3Xp4C0i9rSEkw2hF8Re0ZRgULyns0/PRMV7BYDvAvs+fTHahs8E3kiFldefQ/6PgjbHtx/TqeunUxHM23JCnhKa6WaseYPIbUuRvBwUZCNRdlDMPCMfrGPZY6QoywZjX2qJFlFW4pclZA6TWSH7yahfGihaRrvoZwOihV8t7MBSz9gDQ5OXHcurPwf3vVUDeMmTTgh+RbhnkiMXFh3OeFeb/3R3rjCorclHwpeYxvKa/kIUL5ovFkTkRDfc7/qvQkc0V84ZAjspxLqSj+Eq5/4BFjqOnqzkJxSnoA6C1Rx3FebpUxQDlqnfkphZmrcRYW0f/rNrFC9mdBGIJgWAKUEBNLi3LrSN3coOZ/dQAqr4fAowybbOIrjbxcUZfU70BTc/FtZXjBMhyzSVPP5kTqWZDZRjccrUpVcOz0GbDwudmLT2WYw8qIdyRgMSrT6ErHzbGW4iiD8Jh9cxY6bYK3k3i7wcEUYrgwxPeIsvMMgIrVtDffIFsuALSd9w6YSZbvB1geF0M47VWWQ3W5OdGBLxhPaKtmSUyInV2xqhh38wzKR12wCsC3UnIrEbqzyXYGIXiqG104urRJqpfrzr/0eYLE0bTC0PANsCVWYnCrG5rh6v/XWeDTaiJJreUfdm5YKawgAg2qOx6U+fyQaEa7FPFezOxlnJmlvB6XWYvLK0z0U3AI8BiIh1qbFY2HgFsYmQMhcjho/JqKaF8pdC2ARjDHiHAtEkART7EuxpOzbIxYEqJh8u5nSN8pGvt/QU9tWEpAlPTBbqJkNZb0ipslZ0QL2WVYhqVKFqSYW2BB4Km91GVwNV1TQ8YD1kFyqTZltxylqtQT4DM bfWF0MS/ Fd0C3+vO0421qqrqqbfX5pJJQRbkGC7vM9gWI7bGEDXwmyu2jXvvR/kODxonMXp/3VTRpE2Cka3qWwz6e8xDxbYxv5TWHsa9t2/0Opu0u7PToTuh2gF9xffp6dvN5eR1QJC3w9iT5fFZkc/dJnSHA0dcdnQ0EnbgO/QjSUzEBt3BPFIRADqMIAf7UIU3cGaF9C2MSixWGBwD1cZwy6qq7TACChp5PBW+y5WuvNnKsXNWn52AxcJzQC6j1WI6XLA2VLFEY4zF3EROBN7M= 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. The PMD_SIZE check is moved there. Acked-by: Michal Hocko Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- mm/memory_hotplug.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index eca32ccd45cc..746cb7c08c64 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1247,10 +1247,26 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } +static inline unsigned long memory_block_memmap_size(void) +{ + return PHYS_PFN(memory_block_size_bytes()) * sizeof(struct page); +} + +#ifndef arch_supports_memmap_on_memory +static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) +{ + /* + * As default, we want the vmemmap to span a complete PMD such that we + * can map the vmemmap using a single PMD if supported by the + * architecture. + */ + 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_SIZE; - unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page); + unsigned long vmemmap_size = memory_block_memmap_size(); unsigned long remaining_size = size - vmemmap_size; /* @@ -1281,8 +1297,8 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) */ 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)); + IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)) && + arch_supports_memmap_on_memory(vmemmap_size); } /* From patchwork Tue Aug 8 09:14:59 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: 13345959 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 D95BEC001B0 for ; Tue, 8 Aug 2023 10:49:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67F306B0078; Tue, 8 Aug 2023 06:49:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62EC68D0002; Tue, 8 Aug 2023 06:49:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A86D8D0001; Tue, 8 Aug 2023 06:49:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3A8846B0078 for ; Tue, 8 Aug 2023 06:49:17 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 097261205D6 for ; Tue, 8 Aug 2023 10:49:17 +0000 (UTC) X-FDA: 81100615554.11.D68F223 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf26.hostedemail.com (Postfix) with ESMTP id C5B3C140007 for ; Tue, 8 Aug 2023 10:49:13 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=il7xRxqY; spf=pass (imf26.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=1691491754; 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=5mjq5+2Nd6VHb/q7Xo3dch0NKiPxwL4OZuCku/NkQGg=; b=cwryvnxdXqdjwOM25AlfRSUXkROrqcRe0Dfd1cH7Y5uvnZJQKGA2ejNbu5B5QuFAdVUAID mEo1q/Pe4fue2YEBPESez3DGadjh8+3qzil6vlDd4ALePt6LYo/QCz8/JSFJ0AyPh9rKuV qiG/hFn5wMX/ly4xAc+LyJiZno9qEww= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691491754; a=rsa-sha256; cv=none; b=AHoyHEQxEO7wYu3CEPu7EWT4Qa6vGJX1/D5a05c79Wm5fPj9jEiB5f7uLJOJQk12bqAmoY Miu/2fhO1XHHbUO3IiLC7bTaOxysVr2Q2JlgP36WGWpytnlEOjYcLRXnOTd8DPoTcr0gg1 zld2LmcF0AuFRjO23JDIc2U/Ny6EsG8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=il7xRxqY; spf=pass (imf26.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 (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3789EbtS022671; Tue, 8 Aug 2023 09:15:26 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=5mjq5+2Nd6VHb/q7Xo3dch0NKiPxwL4OZuCku/NkQGg=; b=il7xRxqYnPXEPtVEZNfkp0go7ukvHZ/kA0LfM6ZMMvvsqF+ihykBWKkHAfzNHoI5OhYV Joo6eTWI8VoS7hGthCUiSZynEuhUxVh9N/Dh1Q+zIbQjtgiM/gOXlKiRl5VdQu62K8Ok fCj8ABp0zV3oKoVWHiyn0ypzJELXa6PsF7/ic7qV8FaGnO+XpPsPhZ333SPUkOqui8oe lpamxy4rQexDRMSE8y1PD/7hPxuEGHq5QkKT8Dp9L1J/Zt4x2oC7ugp87qy2Gw6OdK9e wSAesR5BdB6zO4Hcyrum2vCAu2mAh/mKvmRpnX5BiPMwkt62oulYQ0hXAOjyx4coFmT5 sw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjw7g0jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:25 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3789Er1P023140; Tue, 8 Aug 2023 09:15:25 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjw7g0jd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:25 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 378895tE007593; Tue, 8 Aug 2023 09:15:24 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa14y5fad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:24 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FNq961866486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:24 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C172B58056; Tue, 8 Aug 2023 09:15:23 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CC075803F; Tue, 8 Aug 2023 09:15:20 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:20 +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 v8 4/6] mm/memory_hotplug: Support memmap_on_memory when memmap is not aligned to pageblocks Date: Tue, 8 Aug 2023 14:44:59 +0530 Message-ID: <20230808091501.287660-5-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gJ3i6rjoOFVJYx1F3txUK4lzl7E1VujS X-Proofpoint-ORIG-GUID: X_z5AKrhsMVhzGusW79tUljT7nTq2sZc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 priorityscore=1501 mlxscore=0 phishscore=0 impostorscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Stat-Signature: sd1x5uwxtmw17xdt64fzzptfwu9uo9jj X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C5B3C140007 X-Rspam-User: X-HE-Tag: 1691491753-949197 X-HE-Meta: U2FsdGVkX1+ficVjlElezXtAPjolLfemgTwA/UdGVz3KyIEFfbMZJLBgE8H+BwEW6JhQl9HFdu0msZKSMrgc4FaE35ODZP6FkM7Ftqc2G350ZZA5/rdwopqsh2lsKyvRSja9OxEeYVER8SW9sCa7Z5RFmRz1Y0zlncI2l7601DBglfxv7/5r+Io57FGNK1woyWIWyvF8+1IRZ6AWs/2WPsHn9JHAJsQCZSWE9QLt8qhTrKMipIC42FjBusr9S8zf6CtdTIPxOCEIxV1QBEuthaHWHomddnSKTj70lFdDbwoSdmX7YOb9080zqF7b+gONYU4h7nbkWbPHwIAsIYzIDijWybHh0FMiqmwvcE9p3bufg6+szWYxiieSxZjNBrM81GhAtkAg1D9j5ilLBIpEGW0l9xFCoi3Tajw0+KC6jCAZlHTEp+AwcuqhRgw6Z//AVAVBJ8PLPoTfqdqskmn+sOc8pfoCQil3kbQ96EB1TqPZUt2Ofpjut20txwWbbyBw9HO2kuO6jXWj42yBlzPk2NqpAg6/nm8dZ3zqPPc3cYmyojiLqaXw3L/LTJCgu3rdlrbQfsX2mpKzDClYeIJ5KoFmo0OG8Sk81vNPXpIg4GqQhPh5RkTnloHmXmimiRahwrw+6vEAL4gh1VUYlx8nJhER8bVOJg28wyn3Pb0ceg+X6Gyq1FRe89cZcMrkLz97gnIkcp+DiKKLqZnskLmruHMlGRSGvnMLc9EBTCCiuNgZw7SN9g8eW+cGGqF7ZS6T0fdFD1sDMWu+uYmIKJk0L2BQsh7vfLnnRmxutUr0VmH1zQG2genBafXWSS42NCqM+gHtTzeVKaNc7f7yGpofZrhSqVn9NJgsJagcPoyEaLDKIH7tzRbBlbehmcis+a9uKSpfkvo13lwCo1qyWMC5UWvbVQn9wEO6rp8/QGMko5CX7t8SE8hIxyq/a0H7zsfQyKzHT9FjtugazENrDiV uzJ9ZIJi xG4Yt7N4/pKhgPYsqigvSR0wTIDJgbkvScec7gjZylLFmcWh5HN+6bSO1HN2+X+Z8lZoHDdq44bVmwKQsluH8ObTr1y3Yd3WMAlcKSlkgdipiEJ+P82krNVocU/46H51LQDmhC0JikOQ/SkgfDf+B9McIAIHsvM+raB0FzoVhGCAhE2iqkgTQVv8GGJ4CybZEvB5SG8pd6/iPevqbuv/4zmbmCvg+y/S6Yd56eq3+LLDfnPSuzhqAbj7bRvXhyE1zcldY4mrqGwq+M77oCzhO5u3CQSM+zksV8OYUnWlKPAxsXCB/FIy1KFvTM/Q3QJ9+ffjT 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: Currently, memmap_on_memory feature is only supported with memory block sizes that result in vmemmap pages covering full page blocks. This is because memory onlining/offlining code requires applicable ranges to be pageblock-aligned, for example, to set the migratetypes properly. This patch helps to lift that restriction by reserving more pages than required for vmemmap space. This helps the start address to be page block aligned with different memory block sizes. Using this facility implies the kernel will be reserving some pages for every memoryblock. This allows the memmap on memory feature to be widely useful with different memory block size values. For ex: with 64K page size and 256MiB memory block size, we require 4 pages to map vmemmap pages, To align things correctly we end up adding a reserve of 28 pages. ie, for every 4096 pages 28 pages get reserved. Acked-by: Michal Hocko Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- .../admin-guide/mm/memory-hotplug.rst | 12 ++ mm/memory_hotplug.c | 120 +++++++++++++++--- 2 files changed, 113 insertions(+), 19 deletions(-) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index bd77841041af..2994958c7ce8 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -433,6 +433,18 @@ The following module parameters are currently defined: memory in a way that huge pages in bigger granularity cannot be formed on hotplugged memory. + + With value "force" it could result in memory + wastage due to memmap size limitations. For + example, if the memmap for a memory block + requires 1 MiB, but the pageblock size is 2 + MiB, 1 MiB of hotplugged memory will be wasted. + Note that there are still cases where the + feature cannot be enforced: for example, if the + memmap is smaller than a single page, or if the + architecture does not support the forced mode + in all configurations. + ``online_policy`` read-write: Set the basic policy used for automatic zone selection when onlining memory blocks without specifying a target zone. diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 746cb7c08c64..76b813991bdc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -41,17 +41,83 @@ #include "internal.h" #include "shuffle.h" +enum { + MEMMAP_ON_MEMORY_DISABLE = 0, + MEMMAP_ON_MEMORY_ENABLE, + MEMMAP_ON_MEMORY_FORCE, +}; + +static int memmap_mode __read_mostly = MEMMAP_ON_MEMORY_DISABLE; + +static inline unsigned long memory_block_memmap_size(void) +{ + return PHYS_PFN(memory_block_size_bytes()) * sizeof(struct page); +} + +static inline unsigned long memory_block_memmap_on_memory_pages(void) +{ + unsigned long nr_pages = PFN_UP(memory_block_memmap_size()); + + /* + * In "forced" memmap_on_memory mode, we add extra pages to align the + * vmemmap size to cover full pageblocks. That way, we can add memory + * even if the vmemmap size is not properly aligned, however, we might waste + * memory. + */ + if (memmap_mode == MEMMAP_ON_MEMORY_FORCE) + return pageblock_align(nr_pages); + return nr_pages; +} + #ifdef CONFIG_MHP_MEMMAP_ON_MEMORY /* * memory_hotplug.memmap_on_memory parameter */ -static bool memmap_on_memory __ro_after_init; -module_param(memmap_on_memory, bool, 0444); -MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug"); +static int set_memmap_mode(const char *val, const struct kernel_param *kp) +{ + int ret, mode; + bool enabled; + + if (sysfs_streq(val, "force") || sysfs_streq(val, "FORCE")) { + mode = MEMMAP_ON_MEMORY_FORCE; + } else { + ret = kstrtobool(val, &enabled); + if (ret < 0) + return ret; + if (enabled) + mode = MEMMAP_ON_MEMORY_ENABLE; + else + mode = MEMMAP_ON_MEMORY_DISABLE; + } + *((int *)kp->arg) = mode; + if (mode == MEMMAP_ON_MEMORY_FORCE) { + unsigned long memmap_pages = memory_block_memmap_on_memory_pages(); + + pr_info_once("Memory hotplug will waste %ld pages in each memory block\n", + memmap_pages - PFN_UP(memory_block_memmap_size())); + } + return 0; +} + +static int get_memmap_mode(char *buffer, const struct kernel_param *kp) +{ + if (*((int *)kp->arg) == MEMMAP_ON_MEMORY_FORCE) + return sprintf(buffer, "force\n"); + return param_get_bool(buffer, kp); +} + +static const struct kernel_param_ops memmap_mode_ops = { + .set = set_memmap_mode, + .get = get_memmap_mode, +}; +module_param_cb(memmap_on_memory, &memmap_mode_ops, &memmap_mode, 0444); +MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug\n" + "With value \"force\" it could result in memory wastage due " + "to memmap size limitations (Y/N/force)"); static inline bool mhp_memmap_on_memory(void) { - return memmap_on_memory; + return memmap_mode != MEMMAP_ON_MEMORY_DISABLE; } #else static inline bool mhp_memmap_on_memory(void) @@ -1247,11 +1313,6 @@ static int online_memory_block(struct memory_block *mem, void *arg) return device_online(&mem->dev); } -static inline unsigned long memory_block_memmap_size(void) -{ - return PHYS_PFN(memory_block_size_bytes()) * sizeof(struct page); -} - #ifndef arch_supports_memmap_on_memory static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) { @@ -1267,7 +1328,7 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) static bool mhp_supports_memmap_on_memory(unsigned long size) { unsigned long vmemmap_size = memory_block_memmap_size(); - unsigned long remaining_size = size - vmemmap_size; + unsigned long memmap_pages = memory_block_memmap_on_memory_pages(); /* * Besides having arch support and the feature enabled at runtime, we @@ -1295,10 +1356,28 @@ 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() && - IS_ALIGNED(remaining_size, (pageblock_nr_pages << PAGE_SHIFT)) && - arch_supports_memmap_on_memory(vmemmap_size); + if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) + return false; + + /* + * Make sure the vmemmap allocation is fully contained + * so that we always allocate vmemmap memory from altmap area. + */ + if (!IS_ALIGNED(vmemmap_size, PAGE_SIZE)) + return false; + + /* + * start pfn should be pageblock_nr_pages aligned for correctly + * setting migrate types + */ + if (!pageblock_aligned(memmap_pages)) + return false; + + if (memmap_pages == PHYS_PFN(memory_block_size_bytes())) + /* No effective hotplugged memory doesn't make sense. */ + return false; + + return arch_supports_memmap_on_memory(vmemmap_size); } /* @@ -1311,7 +1390,10 @@ 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), + }; struct memory_group *group = NULL; u64 start, size; bool new_node = false; @@ -1356,8 +1438,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 = memory_block_memmap_on_memory_pages(); params.altmap = &mhp_altmap; } /* fallback to not using altmap */ @@ -1369,8 +1450,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, - group); + ret = create_memory_block_devices(start, size, mhp_altmap.free, group); if (ret) { arch_remove_memory(start, size, NULL); goto error; @@ -2096,6 +2176,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 = nr_vmemmap_pages; mhp_altmap.alloc = nr_vmemmap_pages; altmap = &mhp_altmap; } From patchwork Tue Aug 8 09:15:00 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: 13345891 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 0EFEAC001DB for ; Tue, 8 Aug 2023 09:15:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E1506B0074; Tue, 8 Aug 2023 05:15:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 991D46B0078; Tue, 8 Aug 2023 05:15:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 833108D0001; Tue, 8 Aug 2023 05:15:41 -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 722E46B0074 for ; Tue, 8 Aug 2023 05:15:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3DEC9140BE8 for ; Tue, 8 Aug 2023 09:15:41 +0000 (UTC) X-FDA: 81100379682.11.5E36EF7 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf29.hostedemail.com (Postfix) with ESMTP id CF361120014 for ; Tue, 8 Aug 2023 09:15:38 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="JVOPm96/"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf29.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=1691486139; 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=F4qcZEoTqwkRahHimypWFVri5q7pOMDH/5i6hbY2k60=; b=wnstbDrpEqLx0Sq2BPAEzOW31l182THnicQRTqIoXcqIOSI/VXlMufMkSgZQMpDmKWdgIO Hz0As7qwsS8A93Tonl/Kqu2Ia2vG9zONx6Y7dkTnCcT5dHOi+u0z+LvNrv6xRhBGNAGIt5 /hkjybqsZPnv6Qh9KgrwnZsQRia5gZc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="JVOPm96/"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf29.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=1691486139; a=rsa-sha256; cv=none; b=MQDwlyDAFTz4XoETZttTE3KM0Yu9WHG5F95T1xswD4I6XpruH/xtgCk7CJIgD0pI+kwv8U ubV/4L7SNprrCij8YT7nZjNuAXaCZFWeTKLvbMGeqJGwQN6W5FMO5hcX94akKz8AlpJ9Mg tK+bmf+g8xfQClrHqwd7gDNoHpuBiPY= Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3789Aa6j017580; Tue, 8 Aug 2023 09:15:30 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=F4qcZEoTqwkRahHimypWFVri5q7pOMDH/5i6hbY2k60=; b=JVOPm96/j0X8kFA8apVEdjWMh97uvFOaLSLJ9TpsyK1jFR/uYl5B3SZEdOU+4RGXglkE W0nmhIhddUVIHn/3sxGWzPsGIcUQU09UpBx9L6bSIXAxtT8wVwAG3KLinCmdO5WHBwOT rjXjUHquy0oJsC7ek6KFWctsf67Y4C4gLyNNWUwGaY4JWkWP4loFJLTNyP8glc0SplSv os3LhNEV0vAeZPwia3SjRsXkmCIg1Q2tg2KhOLiR4GlI0+fJrc0ZHFsGG58ses1Pcv7c HsQ5YGHYti/ZWwvm7VBNltNyyvSX01E423AtvddM/+HcMdnnc1AIKet4E4Ad1e+JdcyH ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjm4gc54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:30 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3789AWkU017230; Tue, 8 Aug 2023 09:15:29 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjm4gc4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:29 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3788vsun030364; Tue, 8 Aug 2023 09:15:28 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa1rn55jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:28 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FRtt1770004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:27 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89EF058056; Tue, 8 Aug 2023 09:15:27 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CB655803F; Tue, 8 Aug 2023 09:15:24 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:23 +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 v8 5/6] powerpc/book3s64/memhotplug: Enable memmap on memory for radix Date: Tue, 8 Aug 2023 14:45:00 +0530 Message-ID: <20230808091501.287660-6-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GW9-WWF7_8M275jMTVd-bOv3qUbYfcwM X-Proofpoint-ORIG-GUID: j5-TvMJus9zTK1Uu5m4KouMpY_tNcR1m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CF361120014 X-Stat-Signature: uzabeu8t5nhnh9bxb6jkjcs7joyh7bq6 X-Rspam-User: X-HE-Tag: 1691486138-26906 X-HE-Meta: U2FsdGVkX1/NSawC8y9TUl9fqIpI2IQ5/ejVVtOS3/DhSCsSviQ8t92L/h0upzwxJf1Z8h86dP1c4e5ptWY4fQR0s+tFbUaxXRd8Ibh81ZaBM0p1O64aps3tP+I8DNs/LKR/nALZUEWVe2AIQ/5aYytTcJGJ+vbhIbCGplRUZ8qXX1l4/8bMWvDexIXaxkdFr020imLcQZ+uf8Zi9QEPIPVQ7lb49s+cwcLgGKdJX6HvDH/2EjI61tDYTI9OsDCa0OxN/O3+cEUYWaxDiqVDxOT2griD52xj7Xkgwg05zi8rKBVzyMimTad3aCgfCurNbU4LLuDmQ5VhGybWarxsmR4G15rDK9e6/gMFJ4Nz5vpPo4LdUs8qGHwibdhEnkH7dMNYuDUAcHp1amhO9hjyx5ifTnamcgEBwWSYuvq0Rr2yffvaGBQvexq+lCDq7hhEbw9ZBsRaCTSG3xCC2OJUg86iZqjyonHpth5MvD/IuVpH5Un7LYdumD299jnLFfGTiNA9kau58v1Tc/uClIXSY6C5ZBUSgWfwIhMHGWb40FhxiGz4wD9kv0XnKo5YUC3udEa7Kp0QkLk5RsAs7S48MN5lb96k9JrTVHNGrWRovUD4g3hx6YmIY7ZgAOgtni6rEbxozL91b3Sgu1Pysuu+LYh/UiAzZ4wKhtwOcote+I1bDt4/FY2s7jl9Lk+wxu1x4KJ93VEGLshgG3LjIlpmRfMtkcH0heKgbaFY3IdKgvsZosLuGMl45HDf960fnc2qXZSbnxjOEX7kogij4C11W+fVWJkbs5FMYgK44GRajPNky0Ywcnnk7ln/2D/Tb6UQqd9fKradeTRN9uJ2PWJdCXSE4gCLrSa5Im3zqovoC/+eB1j2YbeW2l7n4NjN1v47gaP1BzYgN9sIeypiN/IQ7xWhpAcMnLl2TeL37uyjUckisrylvMI4eff/aQSvwmqO0RYdACk/SB3JkR1PiAd z8FG77wn 7ZHrve9cXJ+9S3MS4FIj0FbdCmavW/FQ1syYpH8zWlQ50HhQdS97fQpnw5CgdxPrUWBIR1i+NOkefxuOQDe5uCFZUHqDrXbmqqaufKn9maJ+myZtcEx0w2MMkBZkJTQln7WDt5HlOyuxzaiMNMU/1kthD8Gl0AZr0svO+GyCFEjxsUJk= 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. Reviewed-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 21 +++++++++++++++++++ .../platforms/pseries/hotplug-memory.c | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d0497d13f5b4..938294c996dc 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 a4893b17705a..33464e6d6431 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -161,6 +161,27 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd) 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 vmemmap_size) +{ + if (!radix_enabled()) + return false; + /* + * With 4K page size and 2M PMD_SIZE, we can align + * things better with memory block size value + * starting from 128MB. Hence align things with PMD_SIZE. + */ + if (IS_ENABLED(CONFIG_PPC_4K_PAGES)) + return IS_ALIGNED(vmemmap_size, PMD_SIZE); + return true; +} + #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..4f3d6a2f9065 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -637,7 +637,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_MEMMAP_ON_MEMORY); if (rc) { invalidate_lmb_associativity_index(lmb); return rc; From patchwork Tue Aug 8 09:15:01 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: 13345919 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 60974C001DB for ; Tue, 8 Aug 2023 10:05:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFDC86B0071; Tue, 8 Aug 2023 06:05:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAE5E8D0002; Tue, 8 Aug 2023 06:05:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4EF68D0001; Tue, 8 Aug 2023 06:05:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B22376B0071 for ; Tue, 8 Aug 2023 06:05:14 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 852698070D for ; Tue, 8 Aug 2023 10:05:14 +0000 (UTC) X-FDA: 81100504548.25.33639C1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf01.hostedemail.com (Postfix) with ESMTP id EF35740011 for ; Tue, 8 Aug 2023 10:05:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ppPYYxmr; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf01.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=1691489111; 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=TMwsNHQ5gDf4ED/4iTXEiIlkIpskq6hOlBxAXB/D+tA=; b=gM0i1tzg6jsPfOEFqb29JnGAZwj9wxU8/1q9IADQbq0IKBpYvX9Psevlg8wGXCqsnzNp8v H1zMSpPntkhar4NVR4jZQmvGuWslATPE22EtvyfPsN5uHB0Xeng3u0T51O5La7TZYk+m7w VxKaLAA10Kfe8DjdjXNCoS+v2oZt5tM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=ppPYYxmr; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf01.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=1691489111; a=rsa-sha256; cv=none; b=TsWwgOiA3K/GFEd14f2IGhrMzI50/YhLO6M8hj1Or8fERCjobEkEKlewFUpZ+vq9dYrJyz U2P91gMAzEpgKFp/Bkes1NwR4eWAa0Fe7tVfzrdbH3VJBfB1KRtcXvoMU9rLTk7yT1lIgg wGuWDuPNP4XnI+wc4yfI/xZBxnmLC14= Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3789BTpv030141; Tue, 8 Aug 2023 09:15:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=TMwsNHQ5gDf4ED/4iTXEiIlkIpskq6hOlBxAXB/D+tA=; b=ppPYYxmrky/ZPlRGybcxKr6wf5IefnZ6jeCLOFeiWJdN0xUFaJuIhbMdfh/RC7o3Af5y QlMAheuf+fvZqn3onrMmVHu1LUXtN07BKq7YcsnxcHD16deq0iMS6cwezAaL/ZgNvllv b3+NmRKiXXlpf85CZABh6hUUyMWHxX6pQKlwHvLXiVKlq9aPQjpxqL2zseZAWp31BuvE EV6BBxltBXlhv15dCzG1bQux0OJzmgdT8TztvWAh9mzlktR5m3T47Uzd3zAOmHMUQnxa h1uQYXOh6FRtYpjgUl5nTffwrEddJaVHMSe2aufggx0yA50T+jqVaeUO9QZ7nhI8+X9V ow== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjny072y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:34 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3789C9EK032115; Tue, 8 Aug 2023 09:15:33 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sbjny0721-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:33 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3789EAGu000368; Tue, 8 Aug 2023 09:15:32 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3sa28kd0rm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 09:15:32 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3789FVCh5702356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2023 09:15:31 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 430FA5803F; Tue, 8 Aug 2023 09:15:31 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EC1E58060; Tue, 8 Aug 2023 09:15:28 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Aug 2023 09:15:27 +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 v8 6/6] mm/memory_hotplug: Embed vmem_altmap details in memory block Date: Tue, 8 Aug 2023 14:45:01 +0530 Message-ID: <20230808091501.287660-7-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> References: <20230808091501.287660-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gHy0Eaaks8kPFuECqskL1tiSQYreoaoB X-Proofpoint-GUID: glyNei6psgrULgPyLemTkKxdcsVIDY_m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_07,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 mlxlogscore=864 priorityscore=1501 suspectscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080081 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EF35740011 X-Stat-Signature: x5gqnwyum5zsohnfgcm13iyrj118kn7p X-HE-Tag: 1691489110-607411 X-HE-Meta: U2FsdGVkX1/PkyMRZ6E0Mrui1AbdBd6ddK63Ag6s2H8G039ddJKXw9hiJXF9yXgLklEbpyVV/DX5C72PUk2U8+WgfU30lsDQzACo0RSRVewK17qUURpO5UNRTcfrtkWXY4bfnizHGLmpwqbbpIWfiBx7Ae1Sef9Ubdg8F7kkLQiD+Omt7jbmni9Tl8omQVyayqX5TEIPz9cWgLRr5y5OYovOB2BomCKamnXVAIRav8m9n8zpQKrC3WHd12mplQWZ/DNQC7nerpnwCek1KBSYU8cxWTHzhXVefREVzgC1CAultPot9x/sL6puN3OHXWk0ad24wBNf1TLa0oF5aoQwxhxqPS8WscEsdBNDuqjSf0Gb6iKFKo2klX8kmfKosi6PZUOqz/VWnX6BNPudEbW/BQkMr3zvRVEqG5Mjw7j/43vzZxpWtYhWQa+xppl28WlhC/eRp0zntHy3aFL+VPHoNrcHtvDrV+H+FNKjzH+/+f9Lph9wvNr+dKN/s4ph1GgagaLVbR50ySRxb8fsQ1N+UPUEqlfrXDCEmwbQC6kJa27PB5CBV0m68cLGWtZWr4gDWwufQzgbwUY13AosBUHHeJGILVDlmy4WQTGOq4587u6n5OGIJlxgCo6XAKvjYBCqz7e90UsOSU06csQTWQwW4RR7zJm+RJRNYC/oUBDj7UTBcNV0MQsjUkdKhpd/qvk3IElx+s1cHQm6OeZfUrJ0bOunYKzhsJcyhhsaIpBz3QDFP1zjJhZSKSlcx8mM1EfQcrtmDXTa+oBS5T4UxZKYfMNxVMd87g/UVn++6zBuoILg/x5X68YIiaetCPDZ+CVYcfGHlhn/cADZgo7gmHYV6/SH8POcWZbXijDShFEpNbi9Ld0xUkMTGknjgETXnhO2ZlqB1dsNSN+pCrV2Gq+v+fxtbUa/NXMMDoFkkotX76F642a8kVEJdl3ZbhzN7EGwXSER4uAuPCW0K8Ym/xh moO7KhgN Vc+sXN8Z2RRiHvH1AtITR9HpEbzJKTakoXS03owiPyNWJ5cU6IFvm5Ukv8rh/2gziUEM6uBE5VyttawNgF7CQgQUKPsCwWK7SK/esbbbYsQZIMZNB3mZjTcOWjS1nx+vqfw3yV/qZRgqNUSUY9BQQ5CT+Rr8UkQKcYHjVKDNOIPBXSErqgEVUp3zLdwt/NQHyHo45fagYL/DszzbZyC5l6H4ddW+tdcG0R2njLX9Vn2F3bvmKckWedBmLnOTbxWRLtcNTzHYnaJtBUImJhP7SetakPQ== 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. Acked-by: Michal Hocko Acked-by: David Hildenbrand Signed-off-by: Aneesh Kumar K.V --- drivers/base/memory.c | 27 +++++++++++++-------- include/linux/memory.h | 8 ++----- mm/memory_hotplug.c | 54 ++++++++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..8191709c9ad2 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -105,7 +105,8 @@ EXPORT_SYMBOL(unregister_memory_notifier); static void memory_block_release(struct device *dev) { struct memory_block *mem = to_memory_block(dev); - + /* Verify that the altmap is freed */ + WARN_ON(mem->altmap); kfree(mem); } @@ -183,7 +184,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 +201,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->free; + if (nr_vmemmap_pages) { ret = mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone); if (ret) @@ -230,7 +234,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 +244,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->free; + if (nr_vmemmap_pages) adjust_present_page_count(pfn_to_page(start_pfn), mem->group, -nr_vmemmap_pages); @@ -726,7 +733,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 +751,7 @@ 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; + mem->altmap = altmap; INIT_LIST_HEAD(&mem->group_next); #ifndef CONFIG_NUMA @@ -783,14 +790,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 +825,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 +839,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 76b813991bdc..f8d3e7427e32 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1439,7 +1439,11 @@ 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 = memory_block_memmap_on_memory_pages(); - params.altmap = &mhp_altmap; + params.altmap = kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL); + if (!params.altmap) + goto error; + + memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap)); } /* fallback to not using altmap */ } @@ -1447,13 +1451,13 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) /* call arch's memory hotadd */ ret = arch_add_memory(nid, start, size, ¶ms); if (ret < 0) - goto error; + goto error_free; /* create memory block devices after memory was added */ - ret = create_memory_block_devices(start, size, mhp_altmap.free, group); + ret = create_memory_block_devices(start, size, params.altmap, group); if (ret) { arch_remove_memory(start, size, NULL); - goto error; + goto error_free; } if (new_node) { @@ -1490,6 +1494,8 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) walk_memory_blocks(start, size, NULL, online_memory_block); return ret; +error_free: + kfree(params.altmap); error: if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) memblock_remove(start, size); @@ -2056,12 +2062,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 test_has_altmap_cb(struct memory_block *mem, void *arg) { + struct memory_block **mem_ptr = (struct memory_block **)arg; /* - * If not set, continue with the next block. + * return the memblock if we have altmap + * and break callback. */ - return mem->nr_vmemmap_pages; + if (mem->altmap) { + *mem_ptr = mem; + return 1; + } + return 0; } static int check_cpu_on_node(int nid) @@ -2136,10 +2148,9 @@ EXPORT_SYMBOL(try_offline_node); static int __ref try_remove_memory(u64 start, u64 size) { - struct vmem_altmap mhp_altmap = {}; - struct vmem_altmap *altmap = NULL; - unsigned long nr_vmemmap_pages; + struct memory_block *mem; int rc = 0, nid = NUMA_NO_NODE; + struct vmem_altmap *altmap = NULL; BUG_ON(check_hotplug_memory_range(start, size)); @@ -2161,25 +2172,20 @@ 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) { + rc = walk_memory_blocks(start, size, &mem, test_has_altmap_cb); + if (rc) { if (size != memory_block_size_bytes()) { pr_warn("Refuse to remove %#llx - %#llx," "wrong granularity\n", start, start + size); return -EINVAL; } - + altmap = mem->altmap; /* - * Let remove_pmd_table->free_hugepage_table do the - * right thing if we used vmem_altmap when hot-adding - * the range. + * Mark altmap NULL so that we can add a debug + * check on memblock free. */ - mhp_altmap.base_pfn = PHYS_PFN(start); - mhp_altmap.free = nr_vmemmap_pages; - mhp_altmap.alloc = nr_vmemmap_pages; - altmap = &mhp_altmap; + mem->altmap = NULL; } } @@ -2196,6 +2202,12 @@ static int __ref try_remove_memory(u64 start, u64 size) arch_remove_memory(start, size, altmap); + /* Verify that all vmemmap pages have actually been freed. */ + if (altmap) { + WARN(altmap->alloc, "Altmap not fully unmapped"); + kfree(altmap); + } + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { memblock_phys_free(start, size); memblock_remove(start, size);