From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F184B1A9F9B for ; Wed, 22 Jul 2026 12:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784723537; cv=none; b=I+8ngS0Uo540eNyDuVET7OQZF+DjrozC16sU3qfhm+bSWUIfJW/d8JyNHusmt9SxCijVA2GhAjfowbokrQ2lAg3uZGAX2NaqrsjVBWtmKTUMBI/LHYQBs8ThIOmY6Idlb9H7B8YancKynDNX6U5VXmr2p83Lz0ZNSsu6ZXmo/CA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784723537; c=relaxed/simple; bh=oAPABRJP1LnF3Y8YBJ8+b/Eb7y7nfoP4b4yQWZvAyns=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j4z09c1ZFrKy7xUSoEKCXoYxEYMyvDFH2y/gyyOh/sOmwQdr6F3KqkMHZ5z+SbNi7XGshOSpHcPKM5EOrlOJDPX702PKS5bvLVUpqdMRMeW7FWp5vXpjLG6XxNWDfZEN/FfJ6YjfOoC578yKJm7nUnmL/3+xk4P25gjPAAPqeac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AOHz42z+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AOHz42z+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 199031F00A3E; Wed, 22 Jul 2026 12:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784723535; bh=lnxlxmPT8kUh0+TLlrEX3X7DjHb/GZYj15xXsKbQU+g=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=AOHz42z+4saXeEFOaiTY/undQpiA7hP3KHl3uYFTn06AE3Mhx3zoLsWvPzfpUiP61 9rc6bO2gzHbfKFdStk1rrYH9PBKSf4qYTIOpwFcqn0/feFC2pEXdPu1ApMntKR7Cb+ DuWq0qzjRLr7kmcZvS/sVzmLGwZDlqozAyrk8A0dV++TFZJs5/BqQruQ4PRNfCKgQg bJI9NCNrl1DjCWvflQcmrA6BekG6rGjQxF+geFHZC9I3uPPgecYFmcvrq2Dhm6/M7F 070IV4EuaMmmbVkgQOAiFTQfd+fXNb5iaPT8Cl2d+WXFe/Mh90muDiYfbxUvjztGck AdkTT89TrEWxQ== Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfauth.phl.internal (Postfix) with ESMTP id 54003F40066; Wed, 22 Jul 2026 08:32:14 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Wed, 22 Jul 2026 08:32:14 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF8TT/vDWioYkWdZrYizKr34no4dSvpXzh8N48LVZZQZqB/wSjKuB1GxsBFuHqNVQ GrXfDoi/gTnPqOz9NywDHbklLV/vEBCMTlo8D23V0lP6ETNgoGfqly2ixdUB5oriFaGZo2 qiBnOauJoAsEkIpLse0B9lrTNjzFyVzGyIDSMUxGH9ACPTK0D4IQE+bulsr/kCy4DszbeL JSXNphFwamAJHMjxaf30zIL2ghJ8cmQ7g8OJS+9m/oSB6ikxaU8BzTfXgFMgABSHA1vtSQ W4NxwjELXX400Odu2xg9u9q2JVBBqmoBUicprRjUVWwhGw+yeFeCBAErAW/FOV7A2PpuMn 9PjWNPvSbn+/b2UnKCRuEb4nJ/5rBkwRVvURTJr08kKE5m/A7LCNIbKRilrSyOYDPWpj5Y B6GKwBU9s/XY2r6oBoYuqXIPLCm76bG9o89jYu3jVE6+IDvNO1IMQpjjxSliPUy10uPaet aBRFjezYyoLJ9fMPWdqBnA+orVErUEMuYSF1LPgx86KqkzFAOSHHRbnylCst0hJFTUB85W b+pJzbobJsuV5itUdeBvbv9X6s9T9GxOOglUca5yJwcathV/dqYCXcWP45mdJNn7Pa2hbk N4r9BFSofiz8lVpuHU8a9OjXSe7OqRhPlnWa1LzW2FzqBt4yS0wbQRuSOdDQ X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Jul 2026 08:32:13 -0400 (EDT) Date: Wed, 22 Jul 2026 13:32:12 +0100 From: Kiryl Shutsemau To: Jiakai Xu Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, David Hildenbrand , Guo Ren , Mike Rapoport , Vishal Moola , Albert Ou , Alexandre Ghiti , Andrew Morton , Junhui Liu , Muchun Song , Nam Cao , Palmer Dabbelt , Paul Walmsley , Vivian Wang Subject: Re: [PATCH] riscv/mm: use physical alignment for vmemmap_start_pfn Message-ID: References: <20260716115326.3466926-1-xujiakai2025@iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260716115326.3466926-1-xujiakai2025@iscas.ac.cn> On Thu, Jul 16, 2026 at 11:53:25AM +0000, Jiakai Xu wrote: > RISC-V computes vmemmap_start_pfn by rounding phys_ram_base down to > VMEMMAP_ADDR_ALIGN. That alignment must therefore be expressed in the > physical-address domain. > > Commit 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size") > attempted to account for the maximal folio alignment by feeding > MAX_FOLIO_VMEMMAP_ALIGN directly into VMEMMAP_ADDR_ALIGN. However, > MAX_FOLIO_VMEMMAP_ALIGN is measured in bytes of struct page storage, > whereas VMEMMAP_ADDR_ALIGN is used to align a physical address. > > The mask-based compound_info encoding requires pfn_to_page(0) to be > naturally aligned to MAX_FOLIO_VMEMMAP_ALIGN. Commit 9f94db4c7eaa > ("mm/sparse: check memmap alignment for compound_info_has_mask()") > added a check for that requirement and exposed the unit mismatch on > systems such as QEMU virt, where the DRAM base is not aligned to > MAX_FOLIO_NR_PAGES * PAGE_SIZE. > > Convert MAX_FOLIO_VMEMMAP_ALIGN to the equivalent physical alignment > before using it in VMEMMAP_ADDR_ALIGN. This keeps the existing > round_down() logic while making the resulting vmemmap base satisfy the > mask-alignment requirement. > > Fixes: 476849b0fba4 ("riscv/mm: align vmemmap to maximal folio size") > Signed-off-by: Jiakai Xu > Assisted-by: YuanSheng:DeepSeek-V4-Flash Reviewed-by: Kiryl Shutsemau (Meta) -- Kiryl Shutsemau / Kirill A. Shutemov