[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250718023000.4044406-1-ziy@nvidia.com>
Date: Thu, 17 Jul 2025 22:29:54 -0400
From: Zi Yan <ziy@...dia.com>
To: David Hildenbrand <david@...hat.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Dan Carpenter <dan.carpenter@...aro.org>,
Antonio Quartulli <antonio@...delbit.com>,
Hugh Dickins <hughd@...gle.com>,
Kirill Shutemov <k.shutemov@...il.com>,
Zi Yan <ziy@...dia.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Nico Pache <npache@...hat.com>,
Ryan Roberts <ryan.roberts@....com>,
Dev Jain <dev.jain@....com>,
Barry Song <baohua@...nel.org>,
Balbir Singh <balbirs@...dia.com>,
Matthew Brost <matthew.brost@...el.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 0/6] __folio_split() clean up
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
Powered by blists - more mailing lists