* [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
@ 2025-11-12 2:00 Wei Yang
2025-11-12 2:37 ` Lance Yang
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Wei Yang @ 2025-11-12 2:00 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
npache, ryan.roberts, dev.jain, baohua, lance.yang
Cc: linux-mm, Wei Yang
SCAN_PMD_NONE means current pmd is empty, but we can still continue
collapse next pmd range.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/khugepaged.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 7e8cb181d5bd..4c2217076ad3 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
goto handle_result;
/* Whitelisted set of results where continuing OK */
case SCAN_PMD_NULL:
+ case SCAN_PMD_NONE:
case SCAN_PTE_NON_PRESENT:
case SCAN_PTE_UFFD_WP:
case SCAN_LACK_REFERENCED_PAGE:
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 2:00 [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
@ 2025-11-12 2:37 ` Lance Yang
2025-11-12 3:40 ` Wei Yang
2025-11-12 3:33 ` Dev Jain
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Lance Yang @ 2025-11-12 2:37 UTC (permalink / raw)
To: Wei Yang
Cc: linux-mm, baolin.wang, dev.jain, Liam.Howlett, ryan.roberts,
npache, baohua, akpm, david, lorenzo.stoakes, ziy
On 2025/11/12 10:00, Wei Yang wrote:
> SCAN_PMD_NONE means current pmd is empty, but we can still continue
> collapse next pmd range.
Right, bailing out of the whole MADV_COLLAPSE request just because
we encounter one empty PMD is too strict ...
It makes sense to treat SCAN_PMD_NONE like the other whitelisted cases
(e.g., SCAN_PMD_NULL).
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
LGTM.
Reviewed-by: Lance Yang <lance.yang@linux.dev>
> mm/khugepaged.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 7e8cb181d5bd..4c2217076ad3 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> goto handle_result;
> /* Whitelisted set of results where continuing OK */
> case SCAN_PMD_NULL:
> + case SCAN_PMD_NONE:
> case SCAN_PTE_NON_PRESENT:
> case SCAN_PTE_UFFD_WP:
> case SCAN_LACK_REFERENCED_PAGE:
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 2:00 [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
2025-11-12 2:37 ` Lance Yang
@ 2025-11-12 3:33 ` Dev Jain
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-13 2:44 ` Baolin Wang
3 siblings, 0 replies; 11+ messages in thread
From: Dev Jain @ 2025-11-12 3:33 UTC (permalink / raw)
To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang,
Liam.Howlett, npache, ryan.roberts, baohua, lance.yang
Cc: linux-mm
On 12/11/25 7:30 am, Wei Yang wrote:
> SCAN_PMD_NONE means current pmd is empty, but we can still continue
> collapse next pmd range.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>
LGTM
Reviewed-by: Dev Jain <dev.jain@arm.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 2:37 ` Lance Yang
@ 2025-11-12 3:40 ` Wei Yang
2025-11-12 3:58 ` Dev Jain
0 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2025-11-12 3:40 UTC (permalink / raw)
To: Lance Yang
Cc: Wei Yang, linux-mm, baolin.wang, dev.jain, Liam.Howlett,
ryan.roberts, npache, baohua, akpm, david, lorenzo.stoakes, ziy
On Wed, Nov 12, 2025 at 10:37:06AM +0800, Lance Yang wrote:
>
>
>On 2025/11/12 10:00, Wei Yang wrote:
>> SCAN_PMD_NONE means current pmd is empty, but we can still continue
>> collapse next pmd range.
>
>Right, bailing out of the whole MADV_COLLAPSE request just because
>we encounter one empty PMD is too strict ...
>
>It makes sense to treat SCAN_PMD_NONE like the other whitelisted cases
>(e.g., SCAN_PMD_NULL).
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>
>LGTM.
>
>Reviewed-by: Lance Yang <lance.yang@linux.dev>
>
Thanks for the review.
I'm currently evaluating the use of SCAN_NULL versus SCAN_NONE. It seems their
usage in the current code is intermixed, and I'm questioning if there's a
strong, practical reason to maintain a distinction between these two states.
Should they be unified?
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 3:40 ` Wei Yang
@ 2025-11-12 3:58 ` Dev Jain
2025-11-12 9:10 ` Wei Yang
0 siblings, 1 reply; 11+ messages in thread
From: Dev Jain @ 2025-11-12 3:58 UTC (permalink / raw)
To: Wei Yang, Lance Yang
Cc: linux-mm, baolin.wang, Liam.Howlett, ryan.roberts, npache,
baohua, akpm, david, lorenzo.stoakes, ziy
On 12/11/25 9:10 am, Wei Yang wrote:
> On Wed, Nov 12, 2025 at 10:37:06AM +0800, Lance Yang wrote:
>>
>> On 2025/11/12 10:00, Wei Yang wrote:
>>> SCAN_PMD_NONE means current pmd is empty, but we can still continue
>>> collapse next pmd range.
>> Right, bailing out of the whole MADV_COLLAPSE request just because
>> we encounter one empty PMD is too strict ...
>>
>> It makes sense to treat SCAN_PMD_NONE like the other whitelisted cases
>> (e.g., SCAN_PMD_NULL).
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>> ---
>> LGTM.
>>
>> Reviewed-by: Lance Yang <lance.yang@linux.dev>
>>
> Thanks for the review.
>
> I'm currently evaluating the use of SCAN_NULL versus SCAN_NONE. It seems their
> usage in the current code is intermixed, and I'm questioning if there's a
> strong, practical reason to maintain a distinction between these two states.
> Should they be unified?
There was some discussion about that in this thread:
https://lore.kernel.org/all/v5ivpub6z2n2uyemlnxgbilzs52ep4lrary7lm7o6axxoneb75@yfacfl5rkzeh/
There are some cleanups mentioned in the thread which you can try if you want :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 3:58 ` Dev Jain
@ 2025-11-12 9:10 ` Wei Yang
0 siblings, 0 replies; 11+ messages in thread
From: Wei Yang @ 2025-11-12 9:10 UTC (permalink / raw)
To: Dev Jain
Cc: Wei Yang, Lance Yang, linux-mm, baolin.wang, Liam.Howlett,
ryan.roberts, npache, baohua, akpm, david, lorenzo.stoakes, ziy
On Wed, Nov 12, 2025 at 09:28:34AM +0530, Dev Jain wrote:
>
>On 12/11/25 9:10 am, Wei Yang wrote:
>> On Wed, Nov 12, 2025 at 10:37:06AM +0800, Lance Yang wrote:
>> >
>> > On 2025/11/12 10:00, Wei Yang wrote:
>> > > SCAN_PMD_NONE means current pmd is empty, but we can still continue
>> > > collapse next pmd range.
>> > Right, bailing out of the whole MADV_COLLAPSE request just because
>> > we encounter one empty PMD is too strict ...
>> >
>> > It makes sense to treat SCAN_PMD_NONE like the other whitelisted cases
>> > (e.g., SCAN_PMD_NULL).
>> > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> > > ---
>> > LGTM.
>> >
>> > Reviewed-by: Lance Yang <lance.yang@linux.dev>
>> >
>> Thanks for the review.
>>
>> I'm currently evaluating the use of SCAN_NULL versus SCAN_NONE. It seems their
>> usage in the current code is intermixed, and I'm questioning if there's a
>> strong, practical reason to maintain a distinction between these two states.
>> Should they be unified?
>
>There was some discussion about that in this thread:
>
>https://lore.kernel.org/all/v5ivpub6z2n2uyemlnxgbilzs52ep4lrary7lm7o6axxoneb75@yfacfl5rkzeh/
>
>There are some cleanups mentioned in the thread which you can try if you want :)
>
Thanks, will take a look.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 2:00 [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
2025-11-12 2:37 ` Lance Yang
2025-11-12 3:33 ` Dev Jain
@ 2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-13 2:44 ` Baolin Wang
3 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-12 9:51 UTC (permalink / raw)
To: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
npache, ryan.roberts, dev.jain, baohua, lance.yang
Cc: linux-mm
On 12.11.25 03:00, Wei Yang wrote:
> SCAN_PMD_NONE means current pmd is empty, but we can still continue
> collapse next pmd range.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
> mm/khugepaged.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 7e8cb181d5bd..4c2217076ad3 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> goto handle_result;
> /* Whitelisted set of results where continuing OK */
> case SCAN_PMD_NULL:
> + case SCAN_PMD_NONE:
> case SCAN_PTE_NON_PRESENT:
> case SCAN_PTE_UFFD_WP:
> case SCAN_LACK_REFERENCED_PAGE:
Looks ok to me.
I am really confused about PMD_NONE vs. PMD_NULL.
Is my understanding correct, hat with your patch we can just merge both
into a single NO_PMD_TABLE or sth. like that?
--
Cheers
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
@ 2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-12 11:27 ` Wei Yang
0 siblings, 1 reply; 11+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-12 9:51 UTC (permalink / raw)
To: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
npache, ryan.roberts, dev.jain, baohua, lance.yang
Cc: linux-mm
On 12.11.25 10:51, David Hildenbrand (Red Hat) wrote:
> On 12.11.25 03:00, Wei Yang wrote:
>> SCAN_PMD_NONE means current pmd is empty, but we can still continue
>> collapse next pmd range.
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>> mm/khugepaged.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index 7e8cb181d5bd..4c2217076ad3 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
>> goto handle_result;
>> /* Whitelisted set of results where continuing OK */
>> case SCAN_PMD_NULL:
>> + case SCAN_PMD_NONE:
>> case SCAN_PTE_NON_PRESENT:
>> case SCAN_PTE_UFFD_WP:
>> case SCAN_LACK_REFERENCED_PAGE:
>
> Looks ok to me.
>
> I am really confused about PMD_NONE vs. PMD_NULL.
>
> Is my understanding correct, hat with your patch we can just merge both
> into a single NO_PMD_TABLE or sth. like that?
NO_PTE_TABLE, actually
--
Cheers
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
@ 2025-11-12 11:27 ` Wei Yang
2025-11-12 11:41 ` David Hildenbrand (Red Hat)
0 siblings, 1 reply; 11+ messages in thread
From: Wei Yang @ 2025-11-12 11:27 UTC (permalink / raw)
To: David Hildenbrand (Red Hat)
Cc: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
npache, ryan.roberts, dev.jain, baohua, lance.yang, linux-mm
On Wed, Nov 12, 2025 at 10:51:43AM +0100, David Hildenbrand (Red Hat) wrote:
>On 12.11.25 10:51, David Hildenbrand (Red Hat) wrote:
>> On 12.11.25 03:00, Wei Yang wrote:
>> > SCAN_PMD_NONE means current pmd is empty, but we can still continue
>> > collapse next pmd range.
>> >
>> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> > ---
>> > mm/khugepaged.c | 1 +
>> > 1 file changed, 1 insertion(+)
>> >
>> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> > index 7e8cb181d5bd..4c2217076ad3 100644
>> > --- a/mm/khugepaged.c
>> > +++ b/mm/khugepaged.c
>> > @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
>> > goto handle_result;
>> > /* Whitelisted set of results where continuing OK */
>> > case SCAN_PMD_NULL:
>> > + case SCAN_PMD_NONE:
>> > case SCAN_PTE_NON_PRESENT:
>> > case SCAN_PTE_UFFD_WP:
>> > case SCAN_LACK_REFERENCED_PAGE:
>>
>> Looks ok to me.
>>
>> I am really confused about PMD_NONE vs. PMD_NULL.
>>
>> Is my understanding correct, hat with your patch we can just merge both
>> into a single NO_PMD_TABLE or sth. like that?
>
>NO_PTE_TABLE, actually
>
I am thinking about this too.
If no other objections, I will prepare a v2 with this.
BTW, you prefer merge them directly, or merge on top of this change?
>--
>Cheers
>
>David
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 11:27 ` Wei Yang
@ 2025-11-12 11:41 ` David Hildenbrand (Red Hat)
0 siblings, 0 replies; 11+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-12 11:41 UTC (permalink / raw)
To: Wei Yang
Cc: akpm, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett, npache,
ryan.roberts, dev.jain, baohua, lance.yang, linux-mm
On 12.11.25 12:27, Wei Yang wrote:
> On Wed, Nov 12, 2025 at 10:51:43AM +0100, David Hildenbrand (Red Hat) wrote:
>> On 12.11.25 10:51, David Hildenbrand (Red Hat) wrote:
>>> On 12.11.25 03:00, Wei Yang wrote:
>>>> SCAN_PMD_NONE means current pmd is empty, but we can still continue
>>>> collapse next pmd range.
>>>>
>>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>>> ---
>>>> mm/khugepaged.c | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>>>> index 7e8cb181d5bd..4c2217076ad3 100644
>>>> --- a/mm/khugepaged.c
>>>> +++ b/mm/khugepaged.c
>>>> @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
>>>> goto handle_result;
>>>> /* Whitelisted set of results where continuing OK */
>>>> case SCAN_PMD_NULL:
>>>> + case SCAN_PMD_NONE:
>>>> case SCAN_PTE_NON_PRESENT:
>>>> case SCAN_PTE_UFFD_WP:
>>>> case SCAN_LACK_REFERENCED_PAGE:
>>>
>>> Looks ok to me.
>>>
>>> I am really confused about PMD_NONE vs. PMD_NULL.
>>>
>>> Is my understanding correct, hat with your patch we can just merge both
>>> into a single NO_PMD_TABLE or sth. like that?
>>
>> NO_PTE_TABLE, actually
>>
>
> I am thinking about this too.
>
> If no other objections, I will prepare a v2 with this.
>
> BTW, you prefer merge them directly, or merge on top of this change?
I'd probably do it in a single commit, stating that both scenarios
should be handled completely the same.
But no strong opinion against doing it in two commits from my side.
--
Cheers
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE
2025-11-12 2:00 [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
` (2 preceding siblings ...)
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
@ 2025-11-13 2:44 ` Baolin Wang
3 siblings, 0 replies; 11+ messages in thread
From: Baolin Wang @ 2025-11-13 2:44 UTC (permalink / raw)
To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, Liam.Howlett,
npache, ryan.roberts, dev.jain, baohua, lance.yang
Cc: linux-mm
On 2025/11/12 10:00, Wei Yang wrote:
> SCAN_PMD_NONE means current pmd is empty, but we can still continue
> collapse next pmd range.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
Make sense to me. And I agree with others' opinions to unify
SCAN_PMD_NULL and SCAN_PMD_NONE.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> mm/khugepaged.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 7e8cb181d5bd..4c2217076ad3 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2835,6 +2835,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> goto handle_result;
> /* Whitelisted set of results where continuing OK */
> case SCAN_PMD_NULL:
> + case SCAN_PMD_NONE:
> case SCAN_PTE_NON_PRESENT:
> case SCAN_PTE_UFFD_WP:
> case SCAN_LACK_REFERENCED_PAGE:
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-11-13 2:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-12 2:00 [PATCH] mm/khugepaged: continue to collapse on SCAN_PMD_NONE Wei Yang
2025-11-12 2:37 ` Lance Yang
2025-11-12 3:40 ` Wei Yang
2025-11-12 3:58 ` Dev Jain
2025-11-12 9:10 ` Wei Yang
2025-11-12 3:33 ` Dev Jain
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-12 9:51 ` David Hildenbrand (Red Hat)
2025-11-12 11:27 ` Wei Yang
2025-11-12 11:41 ` David Hildenbrand (Red Hat)
2025-11-13 2:44 ` Baolin Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox