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 70A0A423A75 for ; Tue, 28 Apr 2026 13:48:37 +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=1777384117; cv=none; b=KjY4rLy5fCB7qacMz4vwgzrcA/nvIajFOtSH2TQyhpU2jrpdDgmdAT8PlUxKMxAta7fjaz+L8QbqIwan56bctNjIWxntPzrpUxXLeliYDgwdAABQiz8INWpe4ZnPXum3jO8xj3E08m4U2PA84WWV0f2t+kIXzXnfEXn5QRV/BsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777384117; c=relaxed/simple; bh=pWqVblja9OGc3skZ+yvllMmHkjP/hNRclmroti3JSVM=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=FvZAVjNGJXwjz/xYNnNsDRsiXDUGd6eYzEfLgipDCG3xnVnr+7B3Rhx35DHIh8vxPUJ948gIpoT4KU0CC8Ba+wmn3Kj1gwSMjckwySuaT8v7b2kFTbJW71ajYCdS3nc38/n3dkQDcqxRedA9EXa4aEwq6oNuTvT9JOrtREivlB8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=ACWEQGe1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ACWEQGe1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9D4C2BCB8; Tue, 28 Apr 2026 13:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1777384116; bh=pWqVblja9OGc3skZ+yvllMmHkjP/hNRclmroti3JSVM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ACWEQGe15ZDmAHLKqymQl7JUn8RQ9bj3yWOUTYPDtHeZAt6nkRdRsQkAc+SXrNcuQ /6lZNybiYr9WDBJz8beGhyGDpjP/TPWcBdVTWYebO1bt97+76zTmUDH2uqq15EVUtJ 6RfXpKC0OO8W44xq0qHMimYun1z3avl0XGu39Djw= Date: Tue, 28 Apr 2026 06:48:35 -0700 From: Andrew Morton To: Muchun Song Cc: David Hildenbrand , Muchun Song , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Nicholas Piggin , Christophe Leroy , aneesh.kumar@linux.ibm.com, joao.m.martins@oracle.com, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 0/6] mm: Fix vmemmap optimization accounting and initialization Message-Id: <20260428064835.5f0db4196ac3f1e6a96abadc@linux-foundation.org> In-Reply-To: <20260428081855.1249045-1-songmuchun@bytedance.com> References: <20260428081855.1249045-1-songmuchun@bytedance.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 28 Apr 2026 16:18:49 +0800 Muchun Song wrote: > The series fixes several bugs in vmemmap optimization, mainly around > incorrect page accounting and memmap initialization in DAX and memory > hotplug paths. It also fixes pageblock migratetype initialization and > struct page initialization for ZONE_DEVICE compound pages. > > Patches 1-4 fix vmemmap accounting issues. Patch 1 fixes an accounting > underflow in the section activation failure path by moving vmemmap page > accounting into the lower-level allocation and freeing helpers. Patch 2 > fixes incorrect altmap passing in the memory hotplug error path. Patch 3 > passes pgmap through memory deactivation paths so the teardown side can > determine whether vmemmap optimization was in effect. Patch 4 uses that > information to account the optimized DAX vmemmap size correctly. > > Patches 5-6 fix initialization issues in mm/mm_init. One makes sure all > pageblocks in ZONE_DEVICE compound pages get their migratetype > initialized. The other fixes a case where DAX memory hotplug reuses an > unoptimized early-section memmap while compound_nr_pages() still assumes > vmemmap optimization, leaving tail struct pages uninitialized. Thanks, I updated mm-new to this version. > Changes in v8: > - In patch 4, move VM_WARN_ON_ONCE(nr_pages > PAGES_PER_SECTION) to the > top of section_nr_vmemmap_pages(). > - In patch 4, add Acked-by from David Hildenbrand. Here's how v8 altered mm.git: --- a/mm/sparse-vmemmap.c~b +++ a/mm/sparse-vmemmap.c @@ -654,6 +654,7 @@ static int __meminit section_nr_vmemmap_ const unsigned long pages_per_compound = 1UL << order; VM_WARN_ON_ONCE(!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SUBSECTION)); + VM_WARN_ON_ONCE(nr_pages > PAGES_PER_SECTION); if (!vmemmap_can_optimize(altmap, pgmap)) return DIV_ROUND_UP(nr_pages * sizeof(struct page), PAGE_SIZE); @@ -664,7 +665,6 @@ static int __meminit section_nr_vmemmap_ } VM_WARN_ON_ONCE(!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION)); - VM_WARN_ON_ONCE(nr_pages > PAGES_PER_SECTION); if (IS_ALIGNED(pfn, pages_per_compound)) return VMEMMAP_RESERVE_NR; _