From patchwork Tue Jul 25 10:02:10 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: 13326256 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 D3007C001DF for ; Tue, 25 Jul 2023 10:02:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F54F6B007D; Tue, 25 Jul 2023 06:02:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6C36B007E; Tue, 25 Jul 2023 06:02:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56C596B0080; Tue, 25 Jul 2023 06:02:54 -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 49D7B6B007D for ; Tue, 25 Jul 2023 06:02:54 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 06E7D40DD3 for ; Tue, 25 Jul 2023 10:02:54 +0000 (UTC) X-FDA: 81049695468.07.AAC069D Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf11.hostedemail.com (Postfix) with ESMTP id 96F804001C for ; Tue, 25 Jul 2023 10:02:51 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lmAdjlXV; 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; 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=1690279371; 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=9FoAFYimQvxvhq6QRw3I1G6YmiFvhLpdqTM8y0x/APg=; b=o9pkHn6rlO0KwzfjrFQFsMqGgKLUHolsgg8O4TptA7heigh0Y6RQrnyg44VMR+oUoWVd8f 41vpg0ncVstbctoYKYw/8f+AhnqqTBFrxTVXgh8lH4mmhYvQzdALLhtR0lM0ZN9xNBOC6F 8PNs8LuNzkdM8aB3YnpVo/aMK6j3j8M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690279371; a=rsa-sha256; cv=none; b=sDho0K9oLOtpUOWnHIy8/pSRCgf7eOB8g8LAt2o25s9P+t73cdekK5El9q5gHPS7Sxra9b DzL0dEYHV9NibE+pH5Hs4Hss8Pt7rSQjoJE/PGdIkIjX24JLwF4yQNVxS+gkHGlCopageZ vjLLruKmjCNTCCDrE3ylIP6Ql/Q5Jnc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lmAdjlXV; 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; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36P9dGLd027140; Tue, 25 Jul 2023 10:02:45 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=9FoAFYimQvxvhq6QRw3I1G6YmiFvhLpdqTM8y0x/APg=; b=lmAdjlXVKRGi4Fx1mVaPB7vwC2QRrGhZl4muqaU789kVQoI4uAryTav5shupbpD4ZwTK Zcd0/5H/fsOymT5mj1FG7Y0rpxpjYUKBP2hP9wzjYZu49JcpHztGPD8FgKEH254mETj4 JDbCkGjsCvVjOQN2F2+dK0kYuz23/AHI+UNdt/aJPNfuL6T3CHQFdcFckSSvhlzbYJaX RGijA4BxEhzcMrU9roS7tHXUSSn3QLn8gn/0dB5bzYB5UzbIscU/26ZuKOY8BBDUUt4/ BogMHrdkB/sIVzNLsZSw+E1RRfAi56bmjg9ceAQs+5e6ImYO9OaepQywW8P9cp1DEaaD Og== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s206365n0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:45 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36P9eO3P030851; Tue, 25 Jul 2023 10:02:44 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s206365md-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:44 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36P9hPjx002281; Tue, 25 Jul 2023 10:02:43 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3s0unjam31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jul 2023 10:02:43 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36PA2hDE6226474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jul 2023 10:02:43 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43D945805C; Tue, 25 Jul 2023 10:02:43 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 904AD5805E; Tue, 25 Jul 2023 10:02:39 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Jul 2023 10:02:39 +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 v5 5/7] powerpc/book3s64/memhotplug: Enable memmap on memory for radix Date: Tue, 25 Jul 2023 15:32:10 +0530 Message-ID: <20230725100212.531277-6-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> References: <20230725100212.531277-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _2Vuo1r6chdVRnOGmwrE8Y-t0v0rAhzE X-Proofpoint-ORIG-GUID: gKeHGuOleK4aWSfjOu3s69fgMSI6iccV 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-25_04,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307250082 X-Rspamd-Queue-Id: 96F804001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mh7i9dpnyxsfrrh1tyaiod13czsd9s1o X-HE-Tag: 1690279371-671436 X-HE-Meta: U2FsdGVkX1+vT+hrmHY+gsv6Mj+z+MoS9VdIbjzvCu2yEYFYt6XAfyshiUYNDuLOOCv/e05EvlsCrUFKPCWSnxXFG0CTJbpfharJ5clpg53UoVu+gCIrzX85tzdGXkSRreCyGdZpMiOkPHBe7d8EqEWS2pWUc/C9hxWlEbRZUMWZmwvJ1EFy4DxbhNUu/QGJtGtTlZxnmzR5g3S3lCj68UyF1epD8FdViOHmG29HJM6mVG7W7lqLx+8j3tADKGdnOLLWO296wkzLO1rw5qH7Sg01bps+apkypzlla6LaUaMY34F6RkFqcpBtIsaysgufwVAx8OADNVpf0Ka7V4Ey/JXkbB8QUwKw/8MhILRbD3F7VaPs/x3UbEKdEULdsgu/QH121ZSci5QJvd+rHfsWLMstPOkKmKHOoXSYu+nh/6Qbp0B4ZT+hHiAUE1bswfkU9fAIdfoudxD44oFYIDskX4aB6goa0RGIvwepjzMF+J/nWRv3p0n8CmztZ/7CCZZ28necVy0YxqnEognj0bfB2Qe42K6iVcHO0ACqiguodIaAK0xcUL0/gPuzh4CqeVW3MuqqI9lqq94Y/HswqcH7RNkk8RTp7kiDhvF73WMXTYWtKbpCdeCOn0i87sCjBcWicQt878DyB82mblQwPTvYKyEisxgG2c2dbKZRRllr4uEm/fGqM4CtbEkzgIXlPsCoscrggQ8uGlz7o7MXZw81MeGQ4GrL4UsUXr8e2tx1hncPEyei0cYO+sG/coB+vs6IG8bQ5GHnm3kB9rHlG8bK4zhb84sR/deZJBbMBr0Jq1lU9fx9ZEfdOEUPJitud2gZjKbi8L/GJIL4/L7IHNcvoRALk+2NAu6L6buLfVWMNr6rCMCBuh1vmESGhSl8sxvskemHlJNU0d9NDI/diwQgfyJMN71ABRep5R2jMecsLynOLkgiMGZJI0+i1yfpaCMQGcBGZTgfrZp/2ujvkNr ubTOMOuW L0JLHmn32eQoiK5YKVls2nCG3tBJHRYRsLzcsfaolzi1979PRPMtG/aIvpbtkRmTEJ41qmPnug7GZL2JvGO8GroUx28rTwf6zaFxg7EcvdvYXGJqDPZVn/FQSnnEyXRA/7D6dTNdfpcfcDCQLNrlmz2YJzYKVb4GRJ07ivYsw64gdBpH3k5mBTCtV0ZH61nI1gpGBnh4dY+94pD5kEAJSYBhqMzp5+0GHk2exsiDYyxIju3I= 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 Reviewed-by: David Hildenbrand --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/pgtable.h | 24 +++++++++++++++++++ .../platforms/pseries/hotplug-memory.c | 3 ++- 3 files changed, 27 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..9b4a1fd24025 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -161,6 +161,30 @@ 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 size) +{ + unsigned long nr_pages = size >> PAGE_SHIFT; + unsigned long vmemmap_size = nr_pages * sizeof(struct page); + + 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..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;