* [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio
@ 2025-11-19 5:46 Jiaqi Yan
2025-11-19 16:35 ` Zi Yan
2025-11-19 16:41 ` David Hildenbrand (Red Hat)
0 siblings, 2 replies; 5+ messages in thread
From: Jiaqi Yan @ 2025-11-19 5:46 UTC (permalink / raw)
To: ziy
Cc: akpm, david, baolin.wang, Liam.Howlett, npache, ryan.roberts,
dev.jain, baohua, lance.yang, linux-mm, inux-kernel, Jiaqi Yan
The correct prerequisite for this split utility isn't really about
if the folio is unmapped; it is more about after unmapped, folio's
refcount is zero and has also been frozen. So rename it to
__split_frozen_folio.
Add a warning in case the folio has non-zero refcount.
No new function is added.
Tested by running split_huge_page_test: testcases all pass and no
warning is shown in dmesg.
Suggested-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
---
mm/huge_memory.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 2f2a521e5d683..5b9c3725e9265 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3390,7 +3390,7 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
}
/*
- * It splits an unmapped @folio to lower order smaller folios in two ways.
+ * It splits an frozen @folio to lower order smaller folios in two ways.
* @folio: the to-be-split folio
* @new_order: the smallest order of the after split folios (since buddy
* allocator like split generates folios with orders from @folio's
@@ -3428,9 +3428,9 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
* For !uniform_split, when -ENOMEM is returned, the original folio might be
* split. The caller needs to check the input folio.
*/
-static int __split_unmapped_folio(struct folio *folio, int new_order,
- struct page *split_at, struct xa_state *xas,
- struct address_space *mapping, bool uniform_split)
+static int __split_frozen_folio(struct folio *folio, int new_order,
+ struct page *split_at, struct xa_state *xas,
+ struct address_space *mapping, bool uniform_split)
{
int order = folio_order(folio);
int start_order = uniform_split ? new_order : order - 1;
@@ -3439,6 +3439,8 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
int split_order;
int ret = 0;
+ VM_WARN_ON_ONCE_FOLIO(folio_ref_count(folio) != 0, folio);
+
if (folio_test_anon(folio))
mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1);
@@ -3583,9 +3585,9 @@ bool uniform_split_supported(struct folio *folio, unsigned int new_order,
* @list: after-split folios will be put on it if non NULL
* @uniform_split: perform uniform split or not (non-uniform split)
*
- * It calls __split_unmapped_folio() to perform uniform and non-uniform split.
+ * It calls __split_frozen_folio() to perform uniform and non-uniform split.
* It is in charge of checking whether the split is supported or not and
- * preparing @folio for __split_unmapped_folio().
+ * preparing @folio for __split_frozen_folio().
*
* After splitting, the after-split folio containing @lock_at remains locked
* and others are unlocked:
@@ -3698,7 +3700,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
i_mmap_lock_read(mapping);
/*
- *__split_unmapped_folio() may need to trim off pages beyond
+ *__split_frozen_folio() may need to trim off pages beyond
* EOF: but on 32-bit, i_size_read() takes an irq-unsafe
* seqlock, which cannot be nested inside the page tree lock.
* So note end now: i_size itself may be changed at any moment,
@@ -3788,8 +3790,8 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
/* lock lru list/PageCompound, ref frozen by page_ref_freeze */
lruvec = folio_lruvec_lock(folio);
- ret = __split_unmapped_folio(folio, new_order, split_at, &xas,
- mapping, uniform_split);
+ ret = __split_frozen_folio(folio, new_order, split_at, &xas,
+ mapping, uniform_split);
/*
* Unfreeze after-split folios and put them back to the right
--
2.52.0.rc1.455.g30608eb744-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio
2025-11-19 5:46 [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio Jiaqi Yan
@ 2025-11-19 16:35 ` Zi Yan
2025-11-19 16:41 ` David Hildenbrand (Red Hat)
1 sibling, 0 replies; 5+ messages in thread
From: Zi Yan @ 2025-11-19 16:35 UTC (permalink / raw)
To: Jiaqi Yan
Cc: akpm, david, baolin.wang, Liam.Howlett, npache, ryan.roberts,
dev.jain, baohua, lance.yang, linux-mm, inux-kernel
On 19 Nov 2025, at 0:46, Jiaqi Yan wrote:
> The correct prerequisite for this split utility isn't really about
> if the folio is unmapped; it is more about after unmapped, folio's
> refcount is zero and has also been frozen. So rename it to
> __split_frozen_folio.
>
> Add a warning in case the folio has non-zero refcount.
>
> No new function is added.
>
> Tested by running split_huge_page_test: testcases all pass and no
> warning is shown in dmesg.
Thank you for doing this.
>
> Suggested-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
> ---
> mm/huge_memory.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 2f2a521e5d683..5b9c3725e9265 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -3390,7 +3390,7 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
> }
>
> /*
> - * It splits an unmapped @folio to lower order smaller folios in two ways.
> + * It splits an frozen @folio to lower order smaller folios in two ways.
s/an/a
> * @folio: the to-be-split folio
> * @new_order: the smallest order of the after split folios (since buddy
> * allocator like split generates folios with orders from @folio's
> @@ -3428,9 +3428,9 @@ static void __split_folio_to_order(struct folio *folio, int old_order,
> * For !uniform_split, when -ENOMEM is returned, the original folio might be
> * split. The caller needs to check the input folio.
> */
> -static int __split_unmapped_folio(struct folio *folio, int new_order,
> - struct page *split_at, struct xa_state *xas,
> - struct address_space *mapping, bool uniform_split)
> +static int __split_frozen_folio(struct folio *folio, int new_order,
> + struct page *split_at, struct xa_state *xas,
> + struct address_space *mapping, bool uniform_split)
Hmm, bool uniform_split is changed to enum split_type split_type recently.
Can you rebase your patch on top of mm-new branch at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/?
> {
> int order = folio_order(folio);
> int start_order = uniform_split ? new_order : order - 1;
> @@ -3439,6 +3439,8 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
> int split_order;
> int ret = 0;
>
> + VM_WARN_ON_ONCE_FOLIO(folio_ref_count(folio) != 0, folio);
> +
> if (folio_test_anon(folio))
> mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1);
>
> @@ -3583,9 +3585,9 @@ bool uniform_split_supported(struct folio *folio, unsigned int new_order,
> * @list: after-split folios will be put on it if non NULL
> * @uniform_split: perform uniform split or not (non-uniform split)
> *
> - * It calls __split_unmapped_folio() to perform uniform and non-uniform split.
> + * It calls __split_frozen_folio() to perform uniform and non-uniform split.
> * It is in charge of checking whether the split is supported or not and
> - * preparing @folio for __split_unmapped_folio().
> + * preparing @folio for __split_frozen_folio().
> *
> * After splitting, the after-split folio containing @lock_at remains locked
> * and others are unlocked:
This part is also changed on mm-new branch.
> @@ -3698,7 +3700,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
> i_mmap_lock_read(mapping);
>
> /*
> - *__split_unmapped_folio() may need to trim off pages beyond
> + *__split_frozen_folio() may need to trim off pages beyond
> * EOF: but on 32-bit, i_size_read() takes an irq-unsafe
> * seqlock, which cannot be nested inside the page tree lock.
> * So note end now: i_size itself may be changed at any moment,
> @@ -3788,8 +3790,8 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
> /* lock lru list/PageCompound, ref frozen by page_ref_freeze */
> lruvec = folio_lruvec_lock(folio);
>
> - ret = __split_unmapped_folio(folio, new_order, split_at, &xas,
> - mapping, uniform_split);
> + ret = __split_frozen_folio(folio, new_order, split_at, &xas,
> + mapping, uniform_split);
>
> /*
> * Unfreeze after-split folios and put them back to the right
> --
> 2.52.0.rc1.455.g30608eb744-goog
Thanks.
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio
2025-11-19 5:46 [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio Jiaqi Yan
2025-11-19 16:35 ` Zi Yan
@ 2025-11-19 16:41 ` David Hildenbrand (Red Hat)
2025-11-19 16:52 ` Zi Yan
1 sibling, 1 reply; 5+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-19 16:41 UTC (permalink / raw)
To: Jiaqi Yan, ziy
Cc: akpm, baolin.wang, Liam.Howlett, npache, ryan.roberts, dev.jain,
baohua, lance.yang, linux-mm, inux-kernel
On 19.11.25 06:46, Jiaqi Yan wrote:
> The correct prerequisite for this split utility isn't really about
> if the folio is unmapped; it is more about after unmapped, folio's
> refcount is zero and has also been frozen. So rename it to
> __split_frozen_folio.
>
> Add a warning in case the folio has non-zero refcount.
>
> No new function is added.
>
While we're at it, can we look into calling this something with the
prefix folio_split / __folio_split to get some consistent naming at one
point?
--
Cheers
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio
2025-11-19 16:41 ` David Hildenbrand (Red Hat)
@ 2025-11-19 16:52 ` Zi Yan
2025-11-19 17:03 ` David Hildenbrand (Red Hat)
0 siblings, 1 reply; 5+ messages in thread
From: Zi Yan @ 2025-11-19 16:52 UTC (permalink / raw)
To: David Hildenbrand (Red Hat)
Cc: Jiaqi Yan, akpm, baolin.wang, Liam.Howlett, npache, ryan.roberts,
dev.jain, baohua, lance.yang, linux-mm, inux-kernel
On 19 Nov 2025, at 11:41, David Hildenbrand (Red Hat) wrote:
> On 19.11.25 06:46, Jiaqi Yan wrote:
>> The correct prerequisite for this split utility isn't really about
>> if the folio is unmapped; it is more about after unmapped, folio's
>> refcount is zero and has also been frozen. So rename it to
>> __split_frozen_folio.
>>
>> Add a warning in case the folio has non-zero refcount.
>>
>> No new function is added.
>>
>
> While we're at it, can we look into calling this something with the prefix folio_split / __folio_split to get some consistent naming at one point?
Does the prefix have to be __folio_split?
__folio_split_frozen() or __frozen_folio_split()?
In terms of naming for split a folio, I used folio_split() for non uniform split,
since split_{page,folio}* are for uniform split. Are you intended to use
folio_split prefix for both? We probably can have a separate patch to
change these function names all at once?
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio
2025-11-19 16:52 ` Zi Yan
@ 2025-11-19 17:03 ` David Hildenbrand (Red Hat)
0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-19 17:03 UTC (permalink / raw)
To: Zi Yan
Cc: Jiaqi Yan, akpm, baolin.wang, Liam.Howlett, npache, ryan.roberts,
dev.jain, baohua, lance.yang, linux-mm, inux-kernel
On 19.11.25 17:52, Zi Yan wrote:
> On 19 Nov 2025, at 11:41, David Hildenbrand (Red Hat) wrote:
>
>> On 19.11.25 06:46, Jiaqi Yan wrote:
>>> The correct prerequisite for this split utility isn't really about
>>> if the folio is unmapped; it is more about after unmapped, folio's
>>> refcount is zero and has also been frozen. So rename it to
>>> __split_frozen_folio.
>>>
>>> Add a warning in case the folio has non-zero refcount.
>>>
>>> No new function is added.
>>>
>>
>> While we're at it, can we look into calling this something with the prefix folio_split / __folio_split to get some consistent naming at one point?
>
> Does the prefix have to be __folio_split?
> __folio_split_frozen() or __frozen_folio_split()?
Personally, I think it's all easier to understand if any folio splitting
function starts with a common prefix.
At least when it comes to any functions exposed outside of hugetlb.c
For internal functions I don't care as much.
>
> In terms of naming for split a folio, I used folio_split() for non uniform split,
> since split_{page,folio}* are for uniform split. Are you intended to use
> folio_split prefix for both? We probably can have a separate patch to
> change these function names all at once?
We should change all them at some point yes.
Regarding uniform vs. !uniform we could either pass the enum later or
also have it encoded in the name.
Probably will be a longer discussion :)
--
Cheers
David
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-19 17:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-19 5:46 [PATCH v1] mm/huge_memory: rename __split_unmapped_folio to __split_frozen_folio Jiaqi Yan
2025-11-19 16:35 ` Zi Yan
2025-11-19 16:41 ` David Hildenbrand (Red Hat)
2025-11-19 16:52 ` Zi Yan
2025-11-19 17:03 ` David Hildenbrand (Red Hat)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox