linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] __folio_split() clean up
@ 2025-07-18  2:29 Zi Yan
  2025-07-18  2:29 ` [PATCH v4 1/6] mm/huge_memory: move unrelated code out of __split_unmapped_folio() Zi Yan
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Zi Yan @ 2025-07-18  2:29 UTC (permalink / raw)
  To: David Hildenbrand, Lorenzo Stoakes, linux-mm
  Cc: Andrew Morton, Dan Carpenter, Antonio Quartulli, Hugh Dickins,
	Kirill Shutemov, Zi Yan, Baolin Wang, Liam R. Howlett, Nico Pache,
	Ryan Roberts, Dev Jain, Barry Song, Balbir Singh, Matthew Brost,
	linux-kernel

Hi Andrew,

This series replaces both [PATCH v3 0/2] __folio_split() clean up
and [PATCH] mm/huge_memory: refactor after-split (page) cache code.

Hi Lorenzo,

I addressed all of your comments except renaming folio to origin_folio,
since I find that might either cause confusion or require a lot of code
churn. folio variable points to the original folio throughout
__folio_split() and using origin_folio in the middle of __folio_split()
is confusing as one might wonder if origin_folio is different from or
the same as folio. The alternative is to rename all folio to origin_folio
in __folio_split(). That seems to be unnecessary code churn.

Hi all,

This patchset refactors __folio_split() and __split_unmapped_folio() to:
1. make __split_unmapped_folio() reusable for splitting unmapped
   folios. It avoids the need for a new boolean unmapped parameter to guard
   mapping-related code when __split_unmapped_folio() is reused to split
   unmapped folios.
2. improve code readability and prevent smatch/coverity checkers from
   complaining about NULL mapping referencing.

An additional benefit for __split_unmapped_folio() refactoring is that
__split_unmapped_folio() could be called on after-split folios by
__folio_split(). It can enable new split methods. For example, at deferred
split time, unmapped subpages can scatter arbitrarily within a large folio,
neither uniform nor non-uniform split can maximize after-split folio orders
for mapped subpages. The hope is that by calling __split_unmapped_folio()
multiple times, a better split result can be achieved.

The patchset is based on mm-new with aforementioned two patchsets
reverted. It passes mm selftests.

Changelog
===
From V3[4]:
1. Split up Patch 1 into incremental changes:
    a. Patch 1 moves code out of __split_unmapped_folio();
    b. Patch 2 removes after_split label in __split_unmapped_folio();
    c. Patch 3 refactors __folio_split() to deduplicate code;
    d. Patch 4 converts VM_BUGs to VM_WARMs;
2. Added "mm/huge_memory: refactor after-split (page) cache code"
   patch[5] to this series.
3. Added remap_flags to make remap_page() call easier to read.
4. Updated Patch 1 commit log to include variable rename information.
5. Converted additional VM_BUGs in __folio_split().
6. Renamed next_folio to end_folio to avoid confusion.
7. Added a comment about start for loop with folio_next(folio) instead
   of just folio plus skipping folio in the loop body.
8. Dropped swapcache folio split check code from __split_unmapped_folio(),
   since the check is already done at the beginning of __folio_split().

From V2[3]:
1. Code format fixes
2. Restructured code to remove after_split goto label.

From V1[2]:
1. Fixed indentations.
2. Used folio_expected_ref_count() to calculate ref_count instead of
   open coding.

[1] https://lore.kernel.org/linux-mm/94D8C1A4-780C-4BEC-A336-7D3613B54845@nvidia.com/
[2] https://lore.kernel.org/linux-mm/20250711030259.3574392-1-ziy@nvidia.com/
[3] https://lore.kernel.org/linux-mm/20250711182355.3592618-1-ziy@nvidia.com/
[4] https://lore.kernel.org/linux-mm/20250714171823.3626213-1-ziy@nvidia.com/
[5] https://lore.kernel.org/linux-mm/20250716171112.3666150-1-ziy@nvidia.com/

Zi Yan (6):
  mm/huge_memory: move unrelated code out of __split_unmapped_folio()
  mm/huge_memory: remove after_split label in __split_unmapped_folio().
  mm/huge_memory: deduplicate code in __folio_split().
  mm/huge_memory: convert VM_BUG* to VM_WARN* in __folio_split.
  mm/huge_memory: get frozen folio refcount with
    folio_expected_ref_count()
  mm/huge_memory: refactor after-split (page) cache code.

 mm/huge_memory.c | 317 ++++++++++++++++++++++++-----------------------
 1 file changed, 165 insertions(+), 152 deletions(-)

-- 
2.47.2


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

end of thread, other threads:[~2025-07-18 15:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18  2:29 [PATCH v4 0/6] __folio_split() clean up Zi Yan
2025-07-18  2:29 ` [PATCH v4 1/6] mm/huge_memory: move unrelated code out of __split_unmapped_folio() Zi Yan
2025-07-18  7:19   ` David Hildenbrand
2025-07-18 14:55   ` Lorenzo Stoakes
2025-07-18  2:29 ` [PATCH v4 2/6] mm/huge_memory: remove after_split label in __split_unmapped_folio() Zi Yan
2025-07-18  7:19   ` David Hildenbrand
2025-07-18 14:58   ` Lorenzo Stoakes
2025-07-18  2:29 ` [PATCH v4 3/6] mm/huge_memory: deduplicate code in __folio_split() Zi Yan
2025-07-18  7:23   ` David Hildenbrand
2025-07-18  2:29 ` [PATCH v4 4/6] mm/huge_memory: convert VM_BUG* to VM_WARN* in __folio_split Zi Yan
2025-07-18  7:22   ` David Hildenbrand
2025-07-18 14:48     ` Zi Yan
2025-07-18 15:05   ` Lorenzo Stoakes
2025-07-18  2:29 ` [PATCH v4 5/6] mm/huge_memory: get frozen folio refcount with folio_expected_ref_count() Zi Yan
2025-07-18  2:30 ` [PATCH v4 6/6] mm/huge_memory: refactor after-split (page) cache code Zi Yan
2025-07-18  5:26 ` [PATCH v4 0/6] __folio_split() clean up Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).