From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 601E98460 for ; Tue, 14 Apr 2026 03:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776135841; cv=none; b=gc8ogDJ3n58k60PmUIkNdlVhutCmk05EVnH3BvbsE0NNj/L4LaQtcqm6Nf/OkhK27mLoPm2BOLmo78ntyKakAIQ8FprZ+PofMIjuzApyNzOac8vd+xMjkXij7UE6b42JEFQLzvTMP1rUtma7x4wPVRRyoaruUDZnXQO5umGfGL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776135841; c=relaxed/simple; bh=Ciso2AWjvBYztbs3BLR9p/CMgpuF4vlx9bslXu0LY7Y=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=sZmaTbhtAjjUXrTLXZZltEbDqsrU90273ewCtdE3dlLbCg2L0cMYBE3wspGdPJJNRcM9ba1KUfakWzYszESO0txYi4G6oirJfN39o5Jzp8ehuwuR6rMyY/kCL901Nl2487FpmA+/4BGwnjCwzSfIyCVusHoQUjOwABPbFAjxwPo= 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=Tobz5XxS; arc=none smtp.client-ip=95.215.58.173 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="Tobz5XxS" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776135838; 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=Ciso2AWjvBYztbs3BLR9p/CMgpuF4vlx9bslXu0LY7Y=; b=Tobz5XxSRsi9ARWqmEcgmiOa3dSNzREEH+4KLg2B8Lwg/NzF7mQwVhrFOQd0ZgZs/xNmvg jWz/oQHSJ6TprcZb/Fqxg8G7aVFlThSaj1LmzdAzo/yVyKSqpbpVu8MvjIwtO/5s4LdP+U oyegkg75cyXyxBg+99X7Q1AdM6w8rNU= 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 01/49] mm/sparse: fix vmemmap accounting imbalance on memory hotplug error X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <2f092c37-95b3-4206-9866-f844273ed1bd@kernel.org> Date: Tue, 14 Apr 2026 11:03:08 +0800 Cc: Muchun Song , Andrew Morton , 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: quoted-printable Message-Id: References: <20260405125240.2558577-1-songmuchun@bytedance.com> <20260405125240.2558577-2-songmuchun@bytedance.com> <2f092c37-95b3-4206-9866-f844273ed1bd@kernel.org> To: "David Hildenbrand (Arm)" X-Migadu-Flow: FLOW_OUT > On Apr 14, 2026, at 02:35, David Hildenbrand (Arm) = wrote: >=20 > On 4/5/26 14:51, Muchun Song wrote: >> In section_activate(), if populate_section_memmap() fails, the error >> handling path calls section_deactivate() to roll back the state. This >> approach introduces an accounting imbalance. >>=20 >> Since the commit c3576889d87b ("mm: fix accounting of memmap pages"), >> memmap pages are accounted for only after populate_section_memmap() >> succeeds. However, section_deactivate() unconditionally decrements = the >> vmemmap account. Consequently, a failure in populate_section_memmap() >> leads to a negative offset (underflow) in the system's vmemmap = tracking. >>=20 >> We can fix this by ensuring that the vmemmap accounting is = incremented >> immediately before checking for the success of = populate_section_memmap(). >> If populate_section_memmap() fails, the subsequent call to >> section_deactivate() will decrement the accounting, perfectly = offsetting >> the increment and maintaining balance. >>=20 >> Fixes: c3576889d87b ("mm: fix accounting of memmap pages") >> Signed-off-by: Muchun Song >> --- >=20 > Can you send the revised fix separately, please? No problem. Muchun, Thanks. >=20 > AI review flagged that recently on one of my series that touched the > code, thanks for taking it off my todo list :) >=20 > --=20 > Cheers, >=20 > David