mm-decrement-mthp_stat_nr_anon-in-free_zone_device_folio.patch removed from -mm tree
The quilt patch titled
Subject: mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio()
has been removed from the -mm tree. Its filename was
mm-decrement-mthp_stat_nr_anon-in-free_zone_device_folio.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nico Pache <[email protected]>
Subject: mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio()
Date: Fri, 17 Jul 2026 00:44:59 -0600
Patch series "mm: fix PMD level mTHP accounting bugs", v2.
While running selftests I noticed the PMD level per-mTHP stats (nr_anon) remained elevated after each run. After further investigation I noticed this accounting error occurs for both the migration.private_anon_htlb_test and the HMM tests.
In the HMM case this is due to folio_add_new_anon_rmap() incrementing the mTHP stats, but never containing a corresponding decrement in free_zone_device_folio(). We solve this by making sure to decrement the counter when freeing device memory.
In the migration case, we are incrementing this counter without first checking whether this folio is a hugetlb folio, which relies on a separate accounting system. We solve this by adding the proper hugetlb check before incrementing this counter.
With these changes in place, the two tests no longer cause elevated PMD level accounting issues.
This patch (of 2):
When a zone device folio is mapped as anonymous, folio_add_new_anon_rmap() increments MTHP_STAT_NR_ANON. The corresponding decrement lives in __free_pages_prepare() in page_alloc.c, but zone device folios are freed via free_zone_device_folio() which never calls __free_pages_prepare(). This causes nr_anon to remain permanently elevated after zone device folios are freed.
Add the missing mod_mthp_stat() decrement to free_zone_device_folio() so that the counter is properly balanced.
---
mm/memremap.c | 1 + 1 file changed, 1 insertion(+)
mm/memremap.c renamed from mm/memremap.c~mm-decrement-mthp_stat_nr_anon-in-free_zone_device_folio +1 -0
@@ -425,6 +425,7 @@ void free_zone_device_folio(struct foliomem_cgroup_uncharge (folio);if (folio_test_anon (folio)) { +mod_mthp_stat (folio_order (folio),MTHP_STAT_NR_ANON ,-1 );for (i =0 ; i < nr; i++)__ClearPageAnonExclusive (folio_page (folio, i)); }
_
Patches currently in -mm which might be from [email protected] are