From patchwork Thu Jul 27 08:02: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: 13329619 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 96966C001E0 for ; Thu, 27 Jul 2023 08:26:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 162538D0010; Thu, 27 Jul 2023 04:26:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EC1E8D0001; Thu, 27 Jul 2023 04:26:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E80988D0010; Thu, 27 Jul 2023 04:26:46 -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 D68DD8D0001 for ; Thu, 27 Jul 2023 04:26:46 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A8732160445 for ; Thu, 27 Jul 2023 08:26:46 +0000 (UTC) X-FDA: 81056710812.29.4DE91A6 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf26.hostedemail.com (Postfix) with ESMTP id 4B8C1140014 for ; Thu, 27 Jul 2023 08:26:44 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XScvb7zU; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf26.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=1690446404; 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=BjYJXV5N11wL76yHr9AAmtIgTWnnXskHJ7TtOgZ1WIblB1A0BMdeolXEsf+5OTPhrL1u4d yjyjverfjrnR6U3pkA+Dl8xGpFJPcUC51BxlMLf6HcWNoeXKqSSwoap9gIIzIwm/VxQchv I6s1RPyo89wxXPWjh9ydV0Z93bNh30I= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XScvb7zU; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf26.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=1690446404; a=rsa-sha256; cv=none; b=XTBl1HSN4K1yTsW3JM0yRNYcVpE9vvG3ch5Vogbt17A8t2igNxcfD6BPh70VCapwJPPTFW t3cN+UgbrK8fdBMc1ApgCAUo7WTIHg0xZ2/of0s8hCdvS99WKdmAKkzIriAOFrEuHuISJX 0DfE0REoUkStTEVwE20xAyJB+9hvk3M= 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 36R889ip002066; Thu, 27 Jul 2023 08:26:38 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=XScvb7zUHqNJ/6WMfJLWApZXomcTJFmhwRZdbErn0Miefw41VPRilp9k44XhHFnBQ7Wo DOH/XqmlirxL8lcwsRS3QDemZbWf2nsRMVr3N5d5HJS16vBWKf7UBTSEYu+KZxW8NrHn CjroOQR/T994u/Elj1tk6W+Xu2R5fxn7e6c3zw6RRiJDqFSSW4pP0lQulgwSfsVwoYvj gENf8CAPqH8NISIZJh7lgjug3EtQorrPJPHUwLRNs468VyuSoN/2PS/kGLvqnUZMyeXf +ftt4qy3uxvEpoOMnhlpB02bUKkMwLvYABMoHThkdRo+rV7O+aDhl6WUhUCyXIXmhngk 6g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s3kn6thv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 08:26:37 +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 36R89mdA008631; Thu, 27 Jul 2023 08:26:36 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 3s3kn6thrf-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 08:26:36 +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 36R666Jr002024; Thu, 27 Jul 2023 08:03:06 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3s0tenbse5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 08:03:06 +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 36R836uI32506594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jul 2023 08:03:06 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 733EE58055; Thu, 27 Jul 2023 08:03:06 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B88158063; Thu, 27 Jul 2023 08:03:02 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 27 Jul 2023 08:03:01 +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 v6 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix Date: Thu, 27 Jul 2023 13:32:30 +0530 Message-ID: <20230727080232.667439-6-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727080232.667439-1-aneesh.kumar@linux.ibm.com> References: <20230727080232.667439-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lh_ZiFxalrUlTTNaM9GqpVKrngePgJpC X-Proofpoint-GUID: 3DHdKSiL-Hg0qtHRueiisS1Gh-XDlQmi 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-26_08,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307270070 X-Rspam-User: X-Stat-Signature: 8xjjugffys8zt1ms8dmdjt8i1xeqpi6w X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4B8C1140014 X-HE-Tag: 1690446404-159475 X-HE-Meta: U2FsdGVkX19bO83nrpzNG88fkoQ1AMeelHMM8fQ2YamXuaxg0jJW1hqatwK/ZGci4iabz69gduBEPzdnkUVKslnjQ0YukfYksMwsbEK0XXZ9URG2QnXA3XJrPJgSJbLNgEE9FF8BqP2YpD0sVqdhvPlaPnNyfdrEPdC0lB8wQfDmLpUC85IHD/h56W9y5pRSslS8pHYNVS2xMwjKXL2DUO0MaaM7RQzdJd01HvJ+GJ3UQcLPYBjy7p4u2Xu3yW3ItMaOwUtTF6Jq4IyOzgnqpotAgYlTTDoBYwLm65gziHOQtfgvte+aRXochTgJGbG0vh9KkMeVkcbCiZ8e0PU/Ld2Tq/C53MgKt+U3sSB3ybVfKgmSfCF3hkPyRkk7eigfRqo5zk8TXbF2srzDMZK1c7HDxlFmACQO3PPpl5qM6fD93H+fNMGfUH3mmyyibhfN8DvkfIcVZRvjaJFIoEipryBHtA6ljCZEfg3EXdm5bL2iL0YeHWUiSKVeJb3mnCC8dATuaowSPzfZ5zTR49a54fUx8QiO0dlcqYxlulXjYBmxo6XZbSDa621F0PNgsNjXK4eQD+LgJcHUHS5FuUwOAWJFGT3X5ntKRgkVwnU+W+jZyOoyF4uZq69duQ2FtdJo5513D+t1pLJcA+HT/DkuEIS4Qyd86KiYlK00QknY7Vf1hosZ4XJQGbjEiYASWM1fC3IWJdYfNnHyPGjcZ7qhXqMWY8zEfgYXVGSkXQkRxvI6DPVYz3Kmluo9cuRwRj/c4KiwxEZrmzQ6UcQW1mxlDosqsVVrSXb5N2YG/fOS9snTErF2WD3BQQOUfA9U79Nqu2VBv/v2RSCDx2KthdQDsgDisp7zrGR5izrnu3EDEUFDwOzt4iU9nGbqGo/lH8LXYzSU863K4Ahw9bhJXNCEwFWwqysXGC/AWWN1JGnN4frpZu4WrH2fxF+JB40+zLenlkdjqaVX21+oN80xIZS p1QQKlk1 hTYhRJNJDDsHjL4TOFdjvq4x1+Hw87jGv0jfOOGKOB+e/BgPAckOjhZT6pmB1MphJ8bhgwt0AHDidqThcsW7xjjNtwkPC6b8jj4Hx10KDHJ221RarpgveJNcZqfkgskSU+9EhMUuMVOtPThHxUcZRsZXh3LbnUd2punL7HDWsY/iCxm4= 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;