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 D007FF4F1 for ; Sun, 12 Apr 2026 16:26:15 +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=1776011175; cv=none; b=cQawpcG7UZMVPEsPsvGt+uojahf8m4IYopCeVVja0FNXvaDZalbjjqUMjgZ/ADJP9O1TBhBSV4xENpYhmtMQOLeSTIB4/iYW48xp3kup7l5d4OSLmoBk9h7D5G/zY1gX9cmKIvYxhTh85tV8kn0S7BU0mdhk4wg/FP435LdAeqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776011175; c=relaxed/simple; bh=rSNfWtN34FXwz/x7Q0w3Dbdq63xMPEFfeV8QcmfmuMI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SDhQlsx5OMLhGePTJ7e4H3jidYG8+4q2+Nr+FveOIBuj0RNl+F+BLpJS1zhwu2vLPz5fmQgHh5HqlJHRC4eD1IqmJn7BDDbkklgf3u+bFGvietWWUQTFtkv1Ylp1F7kI7zXDU4K55hETSj7aJLHoyFP69jneBj11CsINNPaAlaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lc8tEg37; 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="Lc8tEg37" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77AF8C19424; Sun, 12 Apr 2026 16:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776011175; bh=rSNfWtN34FXwz/x7Q0w3Dbdq63xMPEFfeV8QcmfmuMI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Lc8tEg373b347asxMiEAb+5P7Gl/BzIbH8S0kE8/0HfFAZcBxRp1EVPBsUbG0ot6N EfyL0CXmAxf/LYrkdtO0ZvuP5tiE1R3gm7Mf+BO1eP8QDfqsoou9OjetNkbn7ykfrO e5NmkH0n7mXVhpwXXpsAf14fnnuFxAb2mvmszyG+eNZmVSUpXZTT5PUPzDVk0Yn91M eKZqfOgUrittoVlisSOrib7AXw48gNYw0v2EZSWNbrLaN6ieCV+mbD2mF/72uNhciI PXU4C5RWkYmkjj2Yhub5VwofX7uma+Qkz0WHwQxSlx246LbZcbvlj8EfJavL36BeGT NFPO/sHhq+bIw== Date: Sun, 12 Apr 2026 19:26:07 +0300 From: Mike Rapoport To: Muchun Song Cc: Andrew Morton , David Hildenbrand , Muchun Song , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/sparse: Remove sparse buffer pre-allocation mechanism Message-ID: References: <20260410092419.2446420-1-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: <20260410092419.2446420-1-songmuchun@bytedance.com> On Fri, Apr 10, 2026 at 05:24:19PM +0800, Muchun Song wrote: > Commit 9bdac9142407 ("sparsemem: Put mem map for one node together.") > introduced a mechanism to pre-allocate a large memory block to hold all > memmaps for a NUMA node upfront. > > However, the original commit message did not clearly state the actual > benefits or the necessity of explicitly pre-allocating a single chunk > for all memmap areas of a given node. > > One of the concerns about removing this pre-allocation is that the > subsequent per-section memmap allocations could become scattered around, > and might turn too many memory blocks/sections into an "un-offlinable" > state. However, tests show that even without the explicit node-wide > pre-allocation, memblock still allocates memory closely and > back-to-back. When tracing vmemmap_set_pmd allocations, the physical > chunks allocated by memblock are strictly adjacent to each other in a > single contiguous physical range (mapped top-down). Because they are > packed tightly together naturally, they will at most consume or pollute > the exact same number of memory blocks as the explicit pre-allocation > did. > > Another concern is the boot performance impact of calling memmap_alloc() > multiple times compared to one large node-wide allocation. Tests on a > 256GB VM showed that memmap allocation time increased from 199,555 ns > to 741,292 ns. Even though it is 3.7x slower, on a 1TB machine, the > entire memory allocation time would only take a few milliseconds. This > boot performance difference is completely negligible. > > Since no negative impact on memory offlining behavior or noticeable > boot performance regression was found, this patch proposes removing > the explicit node-wide memmap pre-allocation mechanism to reduce the > maintenance burden. > > Signed-off-by: Muchun Song Acked-by: Mike Rapoport (Microsoft) > --- > Changes in v2: > - Addressed David Hildenbrand's and Mike Rapoport's concerns from the > v1 discussion by incorporating the detailed memblock contiguous > allocation analysis and the boot performance measurements directly > into the commit message. > --- > include/linux/mm.h | 1 - > mm/sparse-vmemmap.c | 7 +----- > mm/sparse.c | 58 +-------------------------------------------- > 3 files changed, 2 insertions(+), 64 deletions(-) -- Sincerely yours, Mike.