From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B289A3859C9 for ; Tue, 28 Apr 2026 08:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777364346; cv=none; b=dfaVskipSxQNHP5aYfF2P4CfLlciZhpJheNOAN/cwCFuGLaqBCwOGcCDPp7NKDMeM08gY4H/l28VDoUquLXZqP2dVRiWMNd1lrWK5+bvYBLU17bxS0YJUDBcz3nlcFb6VZBAhiPtWx3GlqryhGG1N0OfENdXtvX2V6DBGTa3MUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777364346; c=relaxed/simple; bh=cj1CIU0Ui9hVafOzerqO593dILxlqp9jVf30jL4bVGI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nCCIBP4k9hqF8bJQqlFN7PeOsV9i8KaI0FzkWDLIT+XbuQpkPqSTs0AWn5TS2dkgbBLisWjW2wFrEyoe1LeCnsVt36L/YkhQRmCRsnn2F1FKtSyi14HjbE/0zHfXYpusm3/Unw778WtCpLdp8Q5hWM7sj+OmlAd7A9n+rfLJmhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=lVPFVDFX; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="lVPFVDFX" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3614826eca4so9774014a91.1 for ; Tue, 28 Apr 2026 01:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1777364344; x=1777969144; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hoqV22eVCAsRVRHya4lFbLghj59bHdoGO9txDqRFMfw=; b=lVPFVDFX7+8f9e1C6YPY1IqRQhxLAHO7r5EImZ2MvEB99rOGdj4qyBZHbGcmvHYFFw uUOfibwoR8t/hxa9K8hSYYIsRA/lc4v5MLLERBj5f6zEdD5xK3kLwNS1NGsmZ/puMtz3 xLQ8gxmqyYD06aEYIaHxAunXdZ5LRxj/Jjnl/JGjvMi4ypzPeTg6uH9EldLGTS3xKG2I 9OyoYBS9ItzMOqW2F36A+QcrC+IWgq0i4gjQzT8Cm/MycEkacFdqZw5tOPfXAWlN6GCC /wNZLiLfgwyaFms24kyDGM6jz+VP5ERlK4uzDQdafgfs5YV6bHiu2pOP1fgAPR+haAzA Ho1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777364344; x=1777969144; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hoqV22eVCAsRVRHya4lFbLghj59bHdoGO9txDqRFMfw=; b=Mrn2iHELZ19qEK96TBRg0IFfdu0eZK2HRWIC/rab2fTCnk1EBH9Ctp15/2fP3+Slwl mpLLmVSvH6O1+nHVa6K7Ilu5/KSj5pLReqFHZBoUYtC/19kyJd6iq52LuF7Pafn7f58w xiEdNmM9jlMkzvJOBV8Nb7ryksuwQWFZhU0lh33dpj38oHVP3Zag7g4pLXYY2Q6kJVVq iW7ZUlLUFp1c5oUgaWxcWWm+tstqguycX3rSJc5uqzatdIqMvjV0qXYBzs7EsB1Vk816 yXi1hgcxfGIfvCuG6z3G8YFrVm93gYK+CEzj+MIM2g5mqAEShxHA3UXx8oTpStMzJA8m LL8g== X-Forwarded-Encrypted: i=1; AFNElJ9MqWkWrIYIuBNfHlAb42U1gUpoagjTCbezzh6jTwVpYv6y1jYIye8bjeWHh85txfcbia5ZCLcFBGDNjFE=@vger.kernel.org X-Gm-Message-State: AOJu0YyXXkTQwtmLkDN3mGr7kWobBC8EanwpabJMYwBgvSoapBrsRzMo JfOsMogQ2vZLFMOG4Hp2r+0Lh2SQ8/rchqXG+wXD7OkJK7uW+rvNdVd8OGjFo9uee/E= X-Gm-Gg: AeBDiet+XzgAWlIFQjkr0Z0vtr+x3B+v3TTxEjQW+rZGkijJkdMuB3a8qgZ4gFWvuua YV78yhsV50/+3TQKihS2hwGNm//hkcGEwYdY5bu/Jmvt/rMHSfq8iV4P2sEv0K8zS8Ui/xwTI6j G9JxAmO5yGy4PyBSdR7GYvGgeB9Xas9bHEyDVPQ0+bqyIe3TM0Ol8Lvc+Jjb1IWLpzY6LmUF6t7 Cv9u1GOYr6K5ddz6386ZK3SsNIddZi5N/0qbTT4QMQcm3gjzKzTikvkHFu0IBIO08yQm6GjqjLg CF8kRnNzxm52oKKA6wk6164rT9QUaweHEnqkmfBpM/EOA5bmnqHPy2n71SrGvgxQrE/sASYj+b9 W1PdA6cO5ZsKJ9izILMjnrsen1YbzC/YS1kNTSdD1jY8cT9W4lO4MIXwnL3YrD9C97ad+FtJ0Wn neGy+6VUJI5LOfn3y/e8+3E1S1tm2dkC+yxEnx7H1xIVXYYvB5tp0Vh/s= X-Received: by 2002:a17:90a:d88f:b0:35b:8d89:719b with SMTP id 98e67ed59e1d1-36491fad396mr2247144a91.1.1777364343972; Tue, 28 Apr 2026 01:19:03 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.101]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3649003650esm2181356a91.8.2026.04.28.01.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 01:19:03 -0700 (PDT) From: Muchun Song To: Andrew Morton , David Hildenbrand , Muchun Song , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan Cc: 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, Muchun Song Subject: [PATCH v8 0/6] mm: Fix vmemmap optimization accounting and initialization Date: Tue, 28 Apr 2026 16:18:49 +0800 Message-Id: <20260428081855.1249045-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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. Muchun Song (6): mm/sparse-vmemmap: Fix vmemmap accounting underflow mm/memory_hotplug: Fix incorrect altmap passing in error path mm/sparse-vmemmap: Pass @pgmap argument to memory deactivation paths mm/sparse-vmemmap: Fix DAX vmemmap accounting with optimization mm/mm_init: Fix pageblock migratetype for ZONE_DEVICE compound pages mm/mm_init: Fix uninitialized struct pages for ZONE_DEVICE arch/arm64/mm/mmu.c | 5 +-- arch/loongarch/mm/init.c | 5 +-- arch/powerpc/mm/mem.c | 5 +-- arch/riscv/mm/init.c | 5 +-- arch/s390/mm/init.c | 5 +-- arch/x86/mm/init_64.c | 5 +-- include/linux/memory_hotplug.h | 8 +++-- mm/memory_hotplug.c | 13 ++++---- mm/memremap.c | 4 +-- mm/mm_init.c | 47 ++++++++++++++++----------- mm/sparse-vmemmap.c | 58 ++++++++++++++++++++++++++-------- 11 files changed, 105 insertions(+), 55 deletions(-) base-commit: 39704f00f747aba3144289870b5fd8ac230a9aaf -- 2.20.1