From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 2EFBC378D8E for ; Wed, 15 Apr 2026 11:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776252454; cv=none; b=fQu7BoL1Z1TbVWaA3lbpNGghuk2lRURlH6Ovw7GBxX7s8LVQygPL4nA2ioUJq7gDxK5EaMfZY0gIBE49IEOzj+V5tP34tmInKSLCtpXqzaNtL9RYlT3Ld0b9dPsmV5df67byiTpBvjfg6QTxAuvejwMOXjz9ej5kIA+wGZtAGBk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776252454; c=relaxed/simple; bh=mIpYW+NGmp6RcHoFdYSnZvnIi6YDwlZ3gAVUOnSLMGs=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=n3Ven/E46m4mFKByDOp9SBaPObQfU6Af+1jhWEv+sGWmJhVDkCA6kolKrDau8lLy9lWqYpPk5YoHKWYsKyj9QwoeD1gjw0cKCwYT4bOsUd+jH5DALiymfZLyW2j1igZ9QdamkUx2aA3Z3rRnuQunWWVZB31Loz978yFHiqNFHB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ChmZ18f3; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ChmZ18f3" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776252451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W/nLB/pOMgjoGvlQGXIaocK5El7h3zMc3A4XsLzA8T8=; b=ChmZ18f3JvhbPpaEqAnc6eSjFBzi2KgGxng36eRvZ2vKerK/1Yj8VS3kTtDm5L0Igs6jMI lrynZAOw99WwWSciyGCsFivc8aHBV8Jso1+1485q0Ma+wP+8r+AVvzhMTTFsPPGMyNPsAw 3Tt7FsFPBv8e3p1zdU6neMzO9SUOPmk= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.500.181\)) Subject: Re: [PATCH v2 1/6] mm/sparse-vmemmap: Fix vmemmap accounting underflow X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260415111412.1003526-2-songmuchun@bytedance.com> Date: Wed, 15 Apr 2026 19:26:48 +0800 Cc: Andrew Morton , David Hildenbrand , 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 Content-Transfer-Encoding: 7bit Message-Id: References: <20260415111412.1003526-1-songmuchun@bytedance.com> <20260415111412.1003526-2-songmuchun@bytedance.com> To: Muchun Song X-Migadu-Flow: FLOW_OUT > On Apr 15, 2026, at 19:14, Muchun Song wrote: > > In section_activate(), if populate_section_memmap() fails, the error > handling path calls section_deactivate() to roll back the state. This > causes a vmemmap accounting imbalance. > > Since commit c3576889d87b ("mm: fix accounting of memmap pages"), > memmap pages are accounted for only after populate_section_memmap() > succeeds. However, the failure path unconditionally calls > section_deactivate(), which decreases the vmemmap count. Consequently, > a failure in populate_section_memmap() leads to an accounting underflow, > incorrectly reducing the system's tracked vmemmap usage. > > Fix this more thoroughly by moving all accounting calls into the lower > level functions that actually perform the vmemmap allocation and freeing: > > - populate_section_memmap() accounts for newly allocated vmemmap pages > - depopulate_section_memmap() unaccounts when vmemmap is freed > - free_map_bootmem() handles early bootmem section accounting Sorry, this line was forgotten to be deleted. The subsequent modification of free_map_bootmem() is a separate cleanup.