From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 302F319A for ; Fri, 27 Dec 2024 03:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735268853; cv=none; b=H0VrodGCuehElY2xLYbqVlQApn1LXuTS08CKZVxakMMEOYcdqnl3JW1m83Nagr/LRzutvMvQBlsNdCcEfC9CIfdoGMEiHMTdSgM2ekwzI2C74lj0yy+QkmfG6OQ7JdbXIZqjkjy2MRx4jcIyjwyLhbhTmejzNEyuMm8JSBG56TA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735268853; c=relaxed/simple; bh=8KpKku1Ror+teAKjOy9QyuLz34jc4zJ9AVcZnGdOfG8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DhJlnm2ORriakNgl+wWdw8IANn9+z3Y4cZflf/MqnF0/2y+4lC0+oo81e3EYVDoJ8xOjowWE3rRZKQZcIpciG3HYqz9lf+QUS4YeR9+4RAsN7HVS1K1VWDF1e9zv0Q2g7ORei0beiuNMuCnnwYf5+PKAx9AvpG/xudtZg9NW0ZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB6C71480; Thu, 26 Dec 2024 18:57:52 -0800 (PST) Received: from [10.162.16.95] (a077893.blr.arm.com [10.162.16.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B2BA3F59E; Thu, 26 Dec 2024 18:57:20 -0800 (PST) Message-ID: <39a85800-47c5-4529-906d-5a40e58ce136@arm.com> Date: Fri, 27 Dec 2024 08:27:18 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] arm64: mm: implement vmemmap_check_pmd for arm64 To: Catalin Marinas , Zhenhua Huang Cc: 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 References: <20241209094227.1529977-1-quic_zhenhuah@quicinc.com> <20241209094227.1529977-3-quic_zhenhuah@quicinc.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/21/24 00:05, Catalin Marinas wrote: > On Mon, Dec 09, 2024 at 05:42:27PM +0800, Zhenhua Huang wrote: >> vmemmap_check_pmd() is used to determine if needs to populate to base >> pages. Implement it for arm64 arch. >> >> Fixes: 2045a3b8911b ("mm/sparse-vmemmap: generalise vmemmap_populate_hugepages()") >> Signed-off-by: Zhenhua Huang >> --- >> arch/arm64/mm/mmu.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >> index fd59ee44960e..41c7978a92be 100644 >> --- a/arch/arm64/mm/mmu.c >> +++ b/arch/arm64/mm/mmu.c >> @@ -1169,7 +1169,8 @@ int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, >> unsigned long addr, unsigned long next) >> { >> vmemmap_verify((pte_t *)pmdp, node, addr, next); >> - return 1; >> + >> + return pmd_sect(*pmdp); Please change this as pmd_sect(READ_ONCE(*pmdp)) instead. >> } >> >> int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, > > Don't we need this patch only if we implement the first one? Please fold > it into the other patch. Seems like these patches might not be related. While creating huge page based vmemmap mapping during vmemmap_populate_hugepages(), vmemmap_check_pmd() validates if a populated (i.e pmd_none) PMD already represents a huge mapping and can be skipped there after. Current implementation for vmemmap_check_pmd() on arm64, unconditionally returns 1 thus asserting that the given populated PMD entry is a huge one indeed, which will be the case unless something is wrong. vmemmap_verify() only ensures that the node where the pfn is allocated from is local. int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, unsigned long addr, unsigned long next) { vmemmap_verify((pte_t *)pmdp, node, addr, next); return 1; } However it does not really check the entry to be a section mapping which it should. Returning pmd_sect(READ_ONCE(*pmdp)) is the right thing, which should have been the case from the beginning when vmemmap_check_pmd() was added. I guess because arm64's original vmemmap_populate() checked only for vmemmap_verify() as well. So probably this does not need a "Fixes: " tag.