Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mm: fix PMD level mTHP accounting bugs
@ 2026-07-02 17:25 Nico Pache
  2026-07-02 17:25 ` [PATCH 1/2] mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio() Nico Pache
  2026-07-02 17:25 ` [PATCH 2/2] mm/migrate: exclude hugetlb folios from MTHP_STAT_NR_ANON accounting Nico Pache
  0 siblings, 2 replies; 9+ messages in thread
From: Nico Pache @ 2026-07-02 17:25 UTC (permalink / raw)
  To: Barry Song, David Hildenbrand, linux-cxl, linux-kernel, linux-mm
  Cc: ljs, willy, Nico Pache, Oscar Salvador, Andrew Morton, Zi Yan,
	Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park,
	Gregory Price, Ying Huang, Alistair Popple

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.

Co-developed-by: David Hildenbrand <david@kernel.org>
Signed-off-by: David Hildenbrand <david@kernel.org>
Signed-off-by: Nico Pache <npache@redhat.com>

Nico Pache (2):
  mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio()
  mm/migrate: exclude hugetlb folios from MTHP_STAT_NR_ANON accounting

 mm/memremap.c | 1 +
 mm/migrate.c  | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

-- 
2.54.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-07-03 12:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 17:25 [PATCH 0/2] mm: fix PMD level mTHP accounting bugs Nico Pache
2026-07-02 17:25 ` [PATCH 1/2] mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio() Nico Pache
2026-07-02 17:31   ` Zi Yan
2026-07-02 17:25 ` [PATCH 2/2] mm/migrate: exclude hugetlb folios from MTHP_STAT_NR_ANON accounting Nico Pache
2026-07-02 17:33   ` Zi Yan
2026-07-03  3:09   ` Baolin Wang
2026-07-03  7:13     ` David Hildenbrand (Arm)
2026-07-03  8:25       ` Richard Cheng
2026-07-03 12:57     ` Nico Pache

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox