From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9647C3BD624 for ; Thu, 9 Apr 2026 10:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775731457; cv=none; b=Tb6wFSiaGjki+c9529GYyoGDcnnjhZHkVgzEBD19Z2uHx8hvR9Wgoj/HKjQqp9XfU0GcPncN+1RdawAfZzX+XXwGI+AXkq70lZ2OuepQesPQ71GvWSYLEi5te+Fd/R2VqkvG7Ehp91ce9N3pwZZIHuSoSKXG4YSrq0pB+oeEgR0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775731457; c=relaxed/simple; bh=4MFRTaxl6iMcBtXLBSVYfuS5O6SXdiJUZpY2SawBjc8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=vA8PgkUByuA8UvWMLSy9Wh8r4kOpW4FGlKvvi3943bFr48qh1WO3JEV+thF/WUNfX5Ghl5cYiDxNUxrDR/axfnWqv5o7JvHYGtTZDi1iNgsP8fEDm1AznZJf+dhx9nVd/LHIdLy6AO/Hx1+AVg3NGC89O7fNZfddfUfl7qGR+TU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N+UXO2Te; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N+UXO2Te" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65285C4CEF7; Thu, 9 Apr 2026 10:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775731457; bh=4MFRTaxl6iMcBtXLBSVYfuS5O6SXdiJUZpY2SawBjc8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N+UXO2TeiTIt2GFrX3ah9Dw/XzmFtWQulTegodX0DtOeZOuE4Zwz0rKKOodMPXVoB tXoECHVST8Lh/mfI4yCT90UGU+vsLJF7yzaE3EVypbWuCWENDAMm/ZTXTqjlwZwOAn ph6As8YUo+OkflICmg0PR5im7kdyI+k4F7/SqXlAhmKXFhiwF0EGU4J82t/NrXeruW hAAWM/6vXPqi3EiwPVTR0LmdsgiUtIRjPmIBXCMnUCAqfRL2SVXKpM6zYNz12Cbnp7 8/vVPKs7GkxnW73PBe/H5IviH/fi8r0K1xSwPQnV/MVFjg1+lE7OxvPF3LfnS5eqSA XlMvyxa9ZqFQQ== Date: Thu, 9 Apr 2026 13:44:11 +0300 From: Mike Rapoport To: Muchun Song Cc: Muchun Song , Andrew Morton , David Hildenbrand , linux-mm@kvack.org, Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Message-ID: References: <20260404122105.3989557-1-songmuchun@bytedance.com> <20260404122105.3989557-2-songmuchun@bytedance.com> 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: On Sun, Apr 05, 2026 at 10:07:36PM +0800, Muchun Song wrote: > > On Apr 5, 2026, at 15:07, Mike Rapoport wrote: > > On Sat, Apr 04, 2026 at 08:20:54PM +0800, Muchun Song wrote: > >> The two weak functions are currently no-ops on every architecture, > >> forcing each platform that needs them to duplicate the same handful > >> of lines. Provide a generic implementation: > >> > >> - vmemmap_set_pmd() simply sets a huge PMD with PAGE_KERNEL protection. > >> > >> - vmemmap_check_pmd() verifies that the PMD is present and leaf, > >> then calls the existing vmemmap_verify() helper. > >> > >> Architectures that need special handling can continue to override the > >> weak symbols; everyone else gets the standard version for free. > >> > >> Signed-off-by: Muchun Song > >> --- > >> mm/sparse-vmemmap.c | 7 ++++++- > >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c > >> index 6eadb9d116e4..1eb990610d50 100644 > >> --- a/mm/sparse-vmemmap.c > >> +++ b/mm/sparse-vmemmap.c > >> @@ -391,12 +391,17 @@ int __meminit vmemmap_populate_hvo(unsigned long addr, unsigned long end, > >> void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, > >> unsigned long addr, unsigned long next) > >> { > >> + BUG_ON(!pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL)); > > > > Do we have to crash the kernel here? > > Wouldn't be better to make vmemmap_set_pmd() return error and make > > vmemmap_populate_hugepages() fall back to base pages in case > > vmemmap_set_pmd() errored? > > Hi Mike, > > Thanks for the review. Let me explain my original thought process here. > > My assumption was that pmd_set_huge() for the kernel virtual address space > should rarely, if ever, fail in this context. Furthermore, if we look at the > architectures this patch replaces (e.g., arm64 and riscv), they are either > ignoring the return value of pmd_set_huge() entirely or lacking any graceful > fallback mechanism anyway. > > So, to keep the initial generic implementation as simple as possible, I used > BUG_ON() as a strict assertion. Fair enough, let's just make it VM_BUG_ON(). -- Sincerely yours, Mike.