From mboxrd@z Thu Jan 1 00:00:00 1970 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 6648BC021A0 for ; Thu, 13 Feb 2025 15:49:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC8816B0082; Thu, 13 Feb 2025 10:49:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D78306B0083; Thu, 13 Feb 2025 10:49:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C67716B0088; Thu, 13 Feb 2025 10:49:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A0D0B6B0082 for ; Thu, 13 Feb 2025 10:49:15 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5D7891A11C5 for ; Thu, 13 Feb 2025 15:49:15 +0000 (UTC) X-FDA: 83115355470.10.E58F9E6 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf10.hostedemail.com (Postfix) with ESMTP id B16E4C0002 for ; Thu, 13 Feb 2025 15:49:13 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739461753; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4N80hDSqq8aH8PAPx57HquTznMqgSlfxParpspmHijM=; b=24MF02dEwaauAtwuFq2ORRSc/NYdxLvZ05mEwZvWObgRHmIXAj6CzEl8HT3DRjGpSOjsBk pLVw0/ZyzdwUJD+5ACVt3VII9SC872QSCAozEURASkuu7jfDv8gPps63qsiYrakHCj2mbZ /Jl17D10Jlyly1L1raau39zQxkOCaQ0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739461753; a=rsa-sha256; cv=none; b=QR4vkpg2dPWFzKctv+51wmuF6KX+1BSz4usg98lnrgJbXxbk4tlowRrrrbLblrhXiL8yyH QSAq9A4/avsVaLyCtOH1Ylt65U49aNuj4pA2Q2j6d0KCiXKqmd33DkmLbtcbqhqoSqcAZR LyqfbVg6JMcHBaVmR2ruis8efoY8Wpg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id AC64DA42704; Thu, 13 Feb 2025 15:47:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9BFCC4CED1; Thu, 13 Feb 2025 15:49:09 +0000 (UTC) Date: Thu, 13 Feb 2025 15:49:07 +0000 From: Catalin Marinas To: David Hildenbrand Cc: Zhenhua Huang , anshuman.khandual@arm.com, will@kernel.org, ardb@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, joey.gouly@arm.com, dave.hansen@linux.intel.com, akpm@linux-foundation.org, chenfeiyang@loongson.cn, chenhuacai@kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, quic_tingweiz@quicinc.com, stable@vger.kernel.org Subject: Re: [PATCH v6] arm64: mm: Populate vmemmap/linear at the page level for hotplugged sections Message-ID: References: <20250213075703.1270713-1-quic_zhenhuah@quicinc.com> <9bc91fe3-c590-48e2-b29f-736d0b056c34@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9bc91fe3-c590-48e2-b29f-736d0b056c34@redhat.com> X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B16E4C0002 X-Stat-Signature: f17qu38cqd3fxgm88xtk7rc7fu1my5ye X-HE-Tag: 1739461753-75027 X-HE-Meta: U2FsdGVkX1+Au3ZMeGlLiZxwxZpOO4AMWXxl5VPEh7yxZJa0oDkxMtW1U0YOHuA8YHYsZ4+2c6HoZWCQkLGusJYbKIDTh5IjsKSruau5077zchxJ3ClbP9dfjA4OyWH7xHOfnsR117eA9eOieyPsQlEH9g95PXhZ62CJjWr2pMaRA/trnM413SnLKbK9IyBq43FBMDFp57VTJm0mb5aNWzFBCL9Ujl+wys7bQePBKlnTgHGS9spW4XaZkhzAsGpSwfl12LdJeeP9n6GiBU5lOFpUmtp7yC/ViumX5LCpD0s3OU68DFXcQcIdEU1qBLCm0lVUGKIIW9qlI8rvi8l+lKXJ1OSY/oMeKlx0gtNEv7VNjeS+eBV5b60iuzufccbNPPmVgbAiGFVbKNjpA7gT/PrXrJDk1PelrMWjGbossiLQP/I1QaRSqupzhsTq8NPfTPEbI90NPLF78q8qht+e1SjpFTTKYNcCNrm5xg4MpSHlkqM571purIHP+LYbMTtnIvSpBenPNGS93r2eMetonH7TVkj8MRTvjHs8+Um+fHYm3CH/y/1avSsCL2WuRoBQ2KngQClO5C2hHl3gaK4F2FTDJZetA3Da4J10g7mCJruIfTb0oyubQoJl6usXOb4ANdmTmLTKHBf1guKF2S2ByvDwY9RepCVGs5fTFfeaCnLjuD74e+L+w0WMWTlBkXhJ9UtgiGoGtHEm8GjLPvx57i3u49pAWXC1AB+O8I65SecZsAagOtMqEMk7vTuoU+0Z+j5uwxpyW1wEzbAZADq8GWb4hotv/BcVGNS8unGlXqC5nVDVHhEejM9sZbJYj9FYnhvltCwdDQKiaA9Yv+dJP2NQXmz5SOKB6+d9VZiZe+VV+8XQPjcplCg0byc+JfP8YnDuiHY2rOamc3Fmn3XlrhYKjmzNy/5TO1LS2UkPrUtEc7RMdUwmtuPqWTJX5M8DtSyGCVbtW0e2PSOjLTT 3euUC73l EJsxtzT8HhZ1LYP7LV75kGHlqihhkykb+up59/C0GHaFOb4+yNC7oDAWIKNgPv+DnLNOqaR7MQsPwOqWSU7ClEl3yfS+D+ydld1fbJ7afcF6MmbLLxjCecl/f7FYM0uSSlUyMVGatxHjSglzGtGPmWzn2R464h/o/BosHoswaZpg9WLpHM1hL7Krl9MjZo9PK50acaO2v/Bp34Upbh+5BZVqNlXJgLac2j7Zov2PL6eCjBc6p9mv48o/VwLZGQvyTrHqtU8rD3PcmW+muN6wITlrmxCiBwAs4M9wNy/xit2pelIQxjcmfMqU3cvCUiFgnMmjBRNb/MzBWgaNnXukfCReBvmzwYfQ5y4RJlocLtLmyDuQ4h93XlAR/b13FAEHXo7e3n4rwZi8PLqPpCBi2xi/v+640epJSJIyR9KoQvNohwJKQSoovEm4EC012SQBupqhyFeRiRVjTZEkL6xhTWPsEL7xng5bH9HmkpUCYc79WxzA= 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: List-Subscribe: List-Unsubscribe: On Thu, Feb 13, 2025 at 01:59:25PM +0100, David Hildenbrand wrote: > On 13.02.25 08:57, Zhenhua Huang wrote: > > On the arm64 platform with 4K base page config, SECTION_SIZE_BITS is set > > to 27, making one section 128M. The related page struct which vmemmap > > points to is 2M then. > > Commit c1cc1552616d ("arm64: MMU initialisation") optimizes the > > vmemmap to populate at the PMD section level which was suitable > > initially since hot plug granule is always one section(128M). However, > > commit ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug") > > introduced a 2M(SUBSECTION_SIZE) hot plug granule, which disrupted the > > existing arm64 assumptions. > > > > Considering the vmemmap_free -> unmap_hotplug_pmd_range path, when > > pmd_sect() is true, the entire PMD section is cleared, even if there is > > other effective subsection. For example page_struct_map1 and > > page_strcut_map2 are part of a single PMD entry and they are hot-added > > sequentially. Then page_struct_map1 is removed, vmemmap_free() will clear > > the entire PMD entry freeing the struct page map for the whole section, > > even though page_struct_map2 is still active. Similar problem exists > > with linear mapping as well, for 16K base page(PMD size = 32M) or 64K > > base page(PMD = 512M), their block mappings exceed SUBSECTION_SIZE. > > Tearing down the entire PMD mapping too will leave other subsections > > unmapped in the linear mapping. > > > > To address the issue, we need to prevent PMD/PUD/CONT mappings for both > > linear and vmemmap for non-boot sections if corresponding size on the > > given base page exceeds SUBSECTION_SIZE(2MB now). > > > > Cc: # v5.4+ > > Fixes: ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug") > > Reviewed-by: Catalin Marinas > > Signed-off-by: Zhenhua Huang > > Just so I understand correctly: for ordinary memory-sections-size hotplug > (NVDIMM, virtio-mem), we still get a large mapping where possible? Up to 2MB blocks only since that's the SUBSECTION_SIZE value. The vmemmap mapping is also limited to PAGE_SIZE mappings (we could use contiguous mappings for vmemmap but it's not wired up; I don't think it's worth the hassle). -- Catalin