From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
Antonio Quartulli <antonio@mandelbit.com>,
Hugh Dickins <hughd@google.com>,
Kirill Shutemov <k.shutemov@gmail.com>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Balbir Singh <balbirs@nvidia.com>,
Matthew Brost <matthew.brost@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 0/6] __folio_split() clean up
Date: Thu, 17 Jul 2025 22:29:54 -0400 [thread overview]
Message-ID: <20250718023000.4044406-1-ziy@nvidia.com> (raw)
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
next reply other threads:[~2025-07-18 2:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 2:29 Zi Yan [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250718023000.4044406-1-ziy@nvidia.com \
--to=ziy@nvidia.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=antonio@mandelbit.com \
--cc=balbirs@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=dan.carpenter@linaro.org \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=k.shutemov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=matthew.brost@intel.com \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®