From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.99 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793351285; b=IhsB+zsY4bohp9EhoDDXEwqTBxhRHDnnBXOr4YZMFyyNrrfAXsSTBeNy83lDLYHWPZia ApEFDMW2+qfoed1/jW3tATC5B2lRoUz5NxKADhSJ0BrDnxiETo8EZy4bs34E55/4ipsae P+U6bwaVyvBFFa0dQor3UQR2urTQF7cJeR7rtwlD7s9Hp2EzpI/WGnOu7VU2wWVIqgft4 bg5jtSMT57aKMkOIFF2RyPdmBEI+/6aK5tISjMtzH2YLQdotmDF9EETRo4nRIwuOnrUu6 TJOaW/5i1rT6w9vzstY8bu5KgHJnSDSjzegU4c2GK0C3jtbccyxWRp3IiFQ2my+uvaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793351285; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=HzETpkZCDXkShONkGAZlIV0dEoNYXp2bUggxSrX6SDs=; b=aSu3jG+t7sYyuHcBx+A5c1Eo3pRWn5E86KJcF8co06PiI+OvB5fyALT00FurDRp5ls9z ieKwLLl1earDlPqRfbtQyMkOVS5ifKKhO9N8Ke4uCHX49+ylCZ0b74lcBUqaaZO0toVdK 56GTewy+rPkAyI50xagg/0YltbN0QXVZcBfbeUh5mxApLA1VF94eQ0KS6qjEUs9a+5HQP /6GyL7U0+FNuSdssUNFyr49aEd23E+E5Im3uOOPiaBEpXblzqmkeTl4Tro4e3Y8LXsfNf CtLpk4f8MzOkMPrqk7x3QIEqp67Mt9PX+3P3+k/UCYxHa72Tr7wyne1pbbGumYAu8Cw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=BPoXN38o; arc=none smtp.remote-ip=91.218.175.99 Received: from mta0.migadu.com (out-99.mta0.migadu.com [91.218.175.99]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C07A4606A31C for ; Fri, 30 Oct 2026 09:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C07A4606A31C 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=BPoXN38o X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=8R0FqJTbDe7nC/J3cP65RdEuTA26QhIX/KSEeF9uB9k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793351282; v=1; x=1793956082; b=BPoXN38obfYHfZy9SZp+rS0+IWXOSOa1zhP7QLcL77ktdrxAL4d2atfbjcLNQ2sB+By5fMvw Zlet4ZoKfrs3FT0BQKqZwIzk8DiwAYYqFH+PcGr1NtPmH/8/ABPUdlZ3C3w+CEm7DfCQZAxx/Af cpbh71pLOtzXW9BCaMr0ni7M= X-Envelope-To: linux-doc@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id b2e1111847a6cf4a; Fri, 30 Oct 2026 09:08:01 +0000 X-Mizu-Trace-ID: b2e1111847a6cf4a X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.100.1.1.12\)) Subject: Re: [PATCH 04/15] mm/hugetlb: account temporary folios separately From: Muchun Song In-Reply-To: <20261028-fixes_hugetlb-v1-4-a0a033db180f@kernel.org> Date: Fri, 30 Oct 2026 17:07:39 +0800 Cc: Oscar Salvador , Naoya Horiguchi , Andrew Morton , Mel Gorman , Andy Whitcroft , Miaohe Lin , Michal Hocko , Rik van Riel , Hugh Dickins , Baolin Wang , Vivek Kasireddy , Dave Airlie , Jason Gunthorpe , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Jonathan Corbet , Shuah Khan , Randy Dunlap , Peter Xu , Breno Leitao , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gerd Hoffmann , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, stable@kernel.org, Josef Bacik Content-Transfer-Encoding: quoted-printable Message-Id: References: <20261028-fixes_hugetlb-v1-0-a0a033db180f@kernel.org> <20261028-fixes_hugetlb-v1-4-a0a033db180f@kernel.org> To: "David Hildenbrand (Arm)" X-Mailer: Apple Mail (2.3901.100.1.1.12) > On Oct 29, 2026, at 04:13, David Hildenbrand (Arm) = wrote: >=20 > Hugetlb migration might have to allocate a temporary folio through > alloc_migrate_hugetlb_folio(). Such folios are currently accounted in > "nr_huge_pages" but not in "surplus_huge_pages". = persistent_huge_pages() > can mistake them as persistent huge pages, as it merely calculates the > difference. >=20 > If set_max_huge_pages() shrinks the pool at the wrong time, it will = turn > hugetlb folios into surplus folios until persistent_huge_pages() = returns > the desired number. >=20 > After the migration (successful or unsuccessful) either the new = (temporary) > folio or the old folio gets freed: this will reduce "nr_huge_pages" = but > not "surplus_huge_pages", to undo what was done when allocating a > temporary folio. >=20 > This can result in having more surplus folios than actually allocated > folios: >=20 > HugePages_Total: 0 > HugePages_Surp: 1 >=20 > =46rom then on persistent_huge_pages() returns garbage. >=20 > To fix it, add internal temporary counters and subtract them when > calculating persistent pool sizes. Update persistent_huge_pages() and = add > persistent_huge_pages_node() to make the code easier to read. >=20 > Count migration targets and rejected surplus allocations as temporary. > Transfer the per-node temporary count along with the temporary flag on > migration, such that folio freeing will always do the right thing. >=20 > Take care of calling account_new_hugetlb_folio() only after setting = the > folios to be temporary. >=20 > For now, keep temporary folios in nr_huge_pages, so HugePages_Total = and > Hugetlb continue to include them and overcommit accounting remains > unchanged. The new temporary counters are internal for now and are not > exported to userspace. >=20 > Fixes: ab5ac90aecf5 ("mm, hugetlb: do not rely on overcommit limit = during migration") > Cc: stable@kernel.org > Reported-by: Josef Bacik > Signed-off-by: David Hildenbrand (Arm) Acked-by: Muchun Song Thanks.