Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix deferred_split_isolate() and drop the split workaround
@ 2026-08-31  9:15 Kiryl Shutsemau
  2026-08-31  9:15 ` [PATCH v2 1/2] mm/huge_memory: do not touch frozen folios in deferred_split_isolate() Kiryl Shutsemau
  2026-08-31  9:15 ` [PATCH v2 2/2] mm/huge_memory: dequeue the deferred split after the split freeze Kiryl Shutsemau
  0 siblings, 2 replies; 7+ messages in thread
From: Kiryl Shutsemau @ 2026-08-31  9:15 UTC (permalink / raw)
  To: akpm, david, ljs, hannes, usama.arif
  Cc: lance.yang, ziy, kasong, hughd, baolin.wang, baohua, liam,
	nico.pache, dev.jain, ryan.roberts, balbirs, kas, linux-mm,
	linux-kernel

From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>

deferred_split_isolate() probes each queued folio with folio_try_get().
folio_try_get() failure is treated as a lost race with folio_put().

It leads to wrong results when !folio_try_get() was not caused by
folio_put(): for a frozen folio, PG_partially_mapped gets wrongfully
cleared and the folio dropped from the queue.

It came up in the review of my collapse RFC series:

  https://lore.kernel.org/all/20260824131224.73344-1-lance.yang@linux.dev/

The bug is inert in upstream code:

  - __folio_split() works around it;
  - __folio_migrate_mapping() freezes a folio it is about to replace;
  - reclaim freezes only what try_to_unmap() already unmapped.

No stable@ needed. But my collapse rework steps on it, so it is worth
fixing.

The branch the first patch removes also hid an inert, pre-existing bug in
the zone device path:

  https://lore.kernel.org/all/20260827163838.1813081-1-usama.arif@linux.dev/

The first patch fixes deferred_split_isolate().

The second patch removes the workaround for this deferred_split_isolate()
behaviour from __folio_freeze_and_split_unmapped().

Tested in a VM: split_huge_page_test, folio_split_race_test and cow pass.

Also ran a test that leaves 16 partially mapped THPs on the deferred
split queue and drives thp-deferred_split through debugfs, checking
nr_anon_partially_mapped.

v1: https://lore.kernel.org/all/20260826162101.1314941-1-kirill@shutemov.name/

Changes since v1:
  - Spell out in the first patch who clears PG_partially_mapped and the
    stat once the shrinker stops doing it (David Hildenbrand).
  - Add Fixes: and Closes: tags (David Hildenbrand, Zi Yan).
  - Drop the three __folio_freeze_and_split_unmapped() cleanups: Kairui
    Song's swap THP cleanup series already carries the same changes.
  - Collect review tags.

Kiryl Shutsemau (Meta) (2):
  mm/huge_memory: do not touch frozen folios in deferred_split_isolate()
  mm/huge_memory: dequeue the deferred split after the split freeze

 mm/huge_memory.c | 63 +++++++++++++-----------------------------------
 1 file changed, 17 insertions(+), 46 deletions(-)


base-commit: 33f61b12d297562321533c048e034b1fb21c1cf3
-- 
2.54.0



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

end of thread, other threads:[~2026-09-01  1:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31  9:15 [PATCH v2 0/2] Fix deferred_split_isolate() and drop the split workaround Kiryl Shutsemau
2026-08-31  9:15 ` [PATCH v2 1/2] mm/huge_memory: do not touch frozen folios in deferred_split_isolate() Kiryl Shutsemau
2026-08-31 11:16   ` Lance Yang
2026-08-31 11:23   ` Usama Arif
2026-09-01  1:38   ` Baolin Wang
2026-08-31  9:15 ` [PATCH v2 2/2] mm/huge_memory: dequeue the deferred split after the split freeze Kiryl Shutsemau
2026-08-31 11:34   ` Lance Yang

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