linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
@ 2025-08-22  6:33 Wei Yang
  2025-08-22  7:34 ` Dev Jain
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-22  6:33 UTC (permalink / raw)
  To: akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, dev.jain, baohua
  Cc: linux-mm, Wei Yang, Liam R . Howlett, stable

Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
mmu_notifier_test_young(), but we should pass the address need to test.
In xxx_scan_pmd(), the actual iteration address is "_address" not
"address". We seem to misuse the variable on the very beginning.

Change it to the right one.

Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
CC: <stable@vger.kernel.org>

---
The original commit 8ee53820edfd is at 2011.
Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
extract khugepaged from mm/huge_memory.c") in 2022.
---
 mm/khugepaged.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 24e18a7f8a93..b000942250d1 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
 		if (cc->is_khugepaged &&
 		    (pte_young(pteval) || folio_test_young(folio) ||
 		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
-								     address)))
+								     _address)))
 			referenced++;
 	}
 	if (!writable) {
-- 
2.34.1



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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
@ 2025-08-22  7:34 ` Dev Jain
  2025-08-23  1:32   ` Wei Yang
  2025-08-22  7:38 ` Dev Jain
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Dev Jain @ 2025-08-22  7:34 UTC (permalink / raw)
  To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, baohua
  Cc: linux-mm, Liam R . Howlett, stable


On 22/08/25 12:03 pm, Wei Yang wrote:
> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> mmu_notifier_test_young(), but we should pass the address need to test.
> In xxx_scan_pmd(), the actual iteration address is "_address" not
> "address". We seem to misuse the variable on the very beginning.
>
> Change it to the right one.
>
> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> CC: <stable@vger.kernel.org>
>
> ---
> The original commit 8ee53820edfd is at 2011.
> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
> extract khugepaged from mm/huge_memory.c") in 2022.
> ---
>   mm/khugepaged.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 24e18a7f8a93..b000942250d1 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>               if (cc->is_khugepaged &&
>                   (pte_young(pteval) || folio_test_young(folio) ||
>                    folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
> -                                                                  address)))
> +                                                                  _address)))
>                       referenced++;
>       }
>       if (!writable) {

Wow, I have gone through this code so many times and never noticed this.

Reviewed-by: Dev Jain <dev.jain@arm.com>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
  2025-08-22  7:34 ` Dev Jain
@ 2025-08-22  7:38 ` Dev Jain
  2025-08-22  7:48   ` Greg KH
  2025-08-23  1:29   ` Wei Yang
  2025-08-22 17:19 ` Zi Yan
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Dev Jain @ 2025-08-22  7:38 UTC (permalink / raw)
  To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, baohua
  Cc: linux-mm, Liam R . Howlett, stable


On 22/08/25 12:03 pm, Wei Yang wrote:
> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> mmu_notifier_test_young(), but we should pass the address need to test.
> In xxx_scan_pmd(), the actual iteration address is "_address" not
> "address". We seem to misuse the variable on the very beginning.
>
> Change it to the right one.
>
> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> CC: <stable@vger.kernel.org>
>
> ---

I hope you must have rebased since your previous patch got pulled, and
the difference of time between these two events is less than 1.5 hours :)

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  7:38 ` Dev Jain
@ 2025-08-22  7:48   ` Greg KH
  2025-08-23  1:29   ` Wei Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Greg KH @ 2025-08-22  7:48 UTC (permalink / raw)
  To: Dev Jain
  Cc: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, baohua, linux-mm, Liam R . Howlett, stable

On Fri, Aug 22, 2025 at 01:08:57PM +0530, Dev Jain wrote:
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Now deleted.


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
  2025-08-22  7:34 ` Dev Jain
  2025-08-22  7:38 ` Dev Jain
@ 2025-08-22 17:19 ` Zi Yan
  2025-08-26  8:53 ` David Hildenbrand
  2025-08-26  9:07 ` Lorenzo Stoakes
  4 siblings, 0 replies; 12+ messages in thread
From: Zi Yan @ 2025-08-22 17:19 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, david, lorenzo.stoakes, baolin.wang, npache, ryan.roberts,
	dev.jain, baohua, linux-mm, Liam R . Howlett, stable

On 22 Aug 2025, at 2:33, Wei Yang wrote:

> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> mmu_notifier_test_young(), but we should pass the address need to test.
> In xxx_scan_pmd(), the actual iteration address is "_address" not
> "address". We seem to misuse the variable on the very beginning.
>
> Change it to the right one.
>
> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> CC: <stable@vger.kernel.org>
>
> ---
> The original commit 8ee53820edfd is at 2011.
> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
> extract khugepaged from mm/huge_memory.c") in 2022.
> ---
>  mm/khugepaged.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 24e18a7f8a93..b000942250d1 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>  		if (cc->is_khugepaged &&
>  		    (pte_young(pteval) || folio_test_young(folio) ||
>  		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
> -								     address)))
> +								     _address)))
>  			referenced++;
>  	}
>  	if (!writable) {
> -- 
> 2.34.1

LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

--
Best Regards,
Yan, Zi


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  7:38 ` Dev Jain
  2025-08-22  7:48   ` Greg KH
@ 2025-08-23  1:29   ` Wei Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-23  1:29 UTC (permalink / raw)
  To: Dev Jain
  Cc: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, baohua, linux-mm, Liam R . Howlett, stable

On Fri, Aug 22, 2025 at 01:08:57PM +0530, Dev Jain wrote:
>
>On 22/08/25 12:03 pm, Wei Yang wrote:
>> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
>> mmu_notifier_test_young(), but we should pass the address need to test.
>> In xxx_scan_pmd(), the actual iteration address is "_address" not
>> "address". We seem to misuse the variable on the very beginning.
>> 
>> Change it to the right one.
>> 
>> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
>> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
>> Cc: Nico Pache <npache@redhat.com>
>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>> Cc: Dev Jain <dev.jain@arm.com>
>> Cc: Barry Song <baohua@kernel.org>
>> CC: <stable@vger.kernel.org>
>> 
>> ---
>
>I hope you must have rebased since your previous patch got pulled, and
>the difference of time between these two events is less than 1.5 hours :)
>

Thanks

I took a look at the latest mm-new, this one applies.


-- 
Wei Yang
Help you, Help me


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  7:34 ` Dev Jain
@ 2025-08-23  1:32   ` Wei Yang
  0 siblings, 0 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-23  1:32 UTC (permalink / raw)
  To: Dev Jain
  Cc: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, baohua, linux-mm, Liam R . Howlett, stable

On Fri, Aug 22, 2025 at 01:04:51PM +0530, Dev Jain wrote:
>
>On 22/08/25 12:03 pm, Wei Yang wrote:
>> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
>> mmu_notifier_test_young(), but we should pass the address need to test.
>> In xxx_scan_pmd(), the actual iteration address is "_address" not
>> "address". We seem to misuse the variable on the very beginning.
>> 
>> Change it to the right one.
>> 
>> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
>> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
>> Cc: Nico Pache <npache@redhat.com>
>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>> Cc: Dev Jain <dev.jain@arm.com>
>> Cc: Barry Song <baohua@kernel.org>
>> CC: <stable@vger.kernel.org>
>> 
>> ---
>> The original commit 8ee53820edfd is at 2011.
>> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
>> extract khugepaged from mm/huge_memory.c") in 2022.
>> ---
>>   mm/khugepaged.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index 24e18a7f8a93..b000942250d1 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>>               if (cc->is_khugepaged &&
>>                   (pte_young(pteval) || folio_test_young(folio) ||
>>                    folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
>> -                                                                  address)))
>> +                                                                  _address)))
>>                       referenced++;
>>       }
>>       if (!writable) {
>
>Wow, I have gone through this code so many times and never noticed this.
>

Yeah, also I am surprised when noticing it.


-- 
Wei Yang
Help you, Help me


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
                   ` (2 preceding siblings ...)
  2025-08-22 17:19 ` Zi Yan
@ 2025-08-26  8:53 ` David Hildenbrand
  2025-08-26  9:03   ` Lorenzo Stoakes
  2025-08-26 12:49   ` Wei Yang
  2025-08-26  9:07 ` Lorenzo Stoakes
  4 siblings, 2 replies; 12+ messages in thread
From: David Hildenbrand @ 2025-08-26  8:53 UTC (permalink / raw)
  To: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, dev.jain, baohua
  Cc: linux-mm, Liam R . Howlett, stable

On 22.08.25 08:33, Wei Yang wrote:
> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> mmu_notifier_test_young(), but we should pass the address need to test.

... "but we are passing the wrong address".

> In xxx_scan_pmd(), the actual iteration address is "_address" not
> "address". We seem to misuse the variable on the very beginning.
> 
> Change it to the right one.
> 
> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> CC: <stable@vger.kernel.org>
> 
> ---
> The original commit 8ee53820edfd is at 2011.
> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
> extract khugepaged from mm/huge_memory.c") in 2022.
> ---
>   mm/khugepaged.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 24e18a7f8a93..b000942250d1 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>   		if (cc->is_khugepaged &&
>   		    (pte_young(pteval) || folio_test_young(folio) ||
>   		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
> -								     address)))
> +								     _address)))

Please just put that into a single line, that's a perfectly reasonable 
case to exceed 80 chars.


Acked-by: David Hildenbrand <david@redhat.com>

>   			referenced++;
>   	}
>   	if (!writable) {

Maybe, just maybe, it's because of *horrible* variable naming.

Can someone please send a cleanup to rename address -> pmd_addr and
_address -> pte_addr or sth like that?

pretty much any naming is better than this.

-- 
Cheers

David / dhildenb



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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-26  8:53 ` David Hildenbrand
@ 2025-08-26  9:03   ` Lorenzo Stoakes
  2025-08-26 12:51     ` Wei Yang
  2025-08-26 12:49   ` Wei Yang
  1 sibling, 1 reply; 12+ messages in thread
From: Lorenzo Stoakes @ 2025-08-26  9:03 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Wei Yang, akpm, ziy, baolin.wang, npache, ryan.roberts, dev.jain,
	baohua, linux-mm, Liam R . Howlett, stable

On Tue, Aug 26, 2025 at 10:53:45AM +0200, David Hildenbrand wrote:
> On 22.08.25 08:33, Wei Yang wrote:
> > Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> > mmu_notifier_test_young(), but we should pass the address need to test.
>
> ... "but we are passing the wrong address".
>
> > In xxx_scan_pmd(), the actual iteration address is "_address" not
> > "address". We seem to misuse the variable on the very beginning.
> >
> > Change it to the right one.
> >
> > Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > Cc: Zi Yan <ziy@nvidia.com>
> > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> > Cc: Nico Pache <npache@redhat.com>
> > Cc: Ryan Roberts <ryan.roberts@arm.com>
> > Cc: Dev Jain <dev.jain@arm.com>
> > Cc: Barry Song <baohua@kernel.org>
> > CC: <stable@vger.kernel.org>
> >
> > ---
> > The original commit 8ee53820edfd is at 2011.
> > Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
> > extract khugepaged from mm/huge_memory.c") in 2022.
> > ---
> >   mm/khugepaged.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index 24e18a7f8a93..b000942250d1 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
> >   		if (cc->is_khugepaged &&
> >   		    (pte_young(pteval) || folio_test_young(folio) ||
> >   		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
> > -								     address)))
> > +								     _address)))
>
> Please just put that into a single line, that's a perfectly reasonable case
> to exceed 80 chars.
>
>
> Acked-by: David Hildenbrand <david@redhat.com>
>
> >   			referenced++;
> >   	}
> >   	if (!writable) {
>
> Maybe, just maybe, it's because of *horrible* variable naming.
>
> Can someone please send a cleanup to rename address -> pmd_addr and
> _address -> pte_addr or sth like that?

YES THIS.

>
> pretty much any naming is better than this.

I despise it, and I realyl underlined this on review in Nico's series because
it's just beyond belief.

It's terrible. I mean maybe even I will do something about this, if my review
load eases up at some point...

>
> --
> Cheers
>
> David / dhildenb
>

Cheers, Lorenzo


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
                   ` (3 preceding siblings ...)
  2025-08-26  8:53 ` David Hildenbrand
@ 2025-08-26  9:07 ` Lorenzo Stoakes
  4 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Stoakes @ 2025-08-26  9:07 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, david, ziy, baolin.wang, npache, ryan.roberts, dev.jain,
	baohua, linux-mm, Liam R . Howlett, stable

On Fri, Aug 22, 2025 at 06:33:18AM +0000, Wei Yang wrote:
> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
> mmu_notifier_test_young(), but we should pass the address need to test.
> In xxx_scan_pmd(), the actual iteration address is "_address" not
> "address". We seem to misuse the variable on the very beginning.
>
> Change it to the right one.
>
> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> CC: <stable@vger.kernel.org>

Good spot. This code is beyond belief.

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

>
> ---
> The original commit 8ee53820edfd is at 2011.

Oopsies!

> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
> extract khugepaged from mm/huge_memory.c") in 2022.
> ---
>  mm/khugepaged.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 24e18a7f8a93..b000942250d1 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>  		if (cc->is_khugepaged &&
>  		    (pte_young(pteval) || folio_test_young(folio) ||
>  		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
> -								     address)))
> +								     _address)))
>  			referenced++;
>  	}
>  	if (!writable) {
> --
> 2.34.1
>


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-26  8:53 ` David Hildenbrand
  2025-08-26  9:03   ` Lorenzo Stoakes
@ 2025-08-26 12:49   ` Wei Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-26 12:49 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, npache,
	ryan.roberts, dev.jain, baohua, linux-mm, Liam R . Howlett,
	stable

On Tue, Aug 26, 2025 at 10:53:45AM +0200, David Hildenbrand wrote:
>On 22.08.25 08:33, Wei Yang wrote:
>> Commit 8ee53820edfd ("thp: mmu_notifier_test_young") introduced
>> mmu_notifier_test_young(), but we should pass the address need to test.
>
>... "but we are passing the wrong address".
>
>> In xxx_scan_pmd(), the actual iteration address is "_address" not
>> "address". We seem to misuse the variable on the very beginning.
>> 
>> Change it to the right one.
>> 
>> Fixes: 8ee53820edfd ("thp: mmu_notifier_test_young")
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
>> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
>> Cc: Nico Pache <npache@redhat.com>
>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>> Cc: Dev Jain <dev.jain@arm.com>
>> Cc: Barry Song <baohua@kernel.org>
>> CC: <stable@vger.kernel.org>
>> 
>> ---
>> The original commit 8ee53820edfd is at 2011.
>> Then the code is moved to khugepaged.c in commit b46e756f5e470 ("thp:
>> extract khugepaged from mm/huge_memory.c") in 2022.
>> ---
>>   mm/khugepaged.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index 24e18a7f8a93..b000942250d1 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -1418,7 +1418,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
>>   		if (cc->is_khugepaged &&
>>   		    (pte_young(pteval) || folio_test_young(folio) ||
>>   		     folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
>> -								     address)))
>> +								     _address)))
>
>Please just put that into a single line, that's a perfectly reasonable case
>to exceed 80 chars.
>
>
>Acked-by: David Hildenbrand <david@redhat.com>

Thanks.

@Andrew

Would you mind adjust the changelog and put it into one line?

>
>>   			referenced++;
>>   	}
>>   	if (!writable) {
>
>Maybe, just maybe, it's because of *horrible* variable naming.
>
>Can someone please send a cleanup to rename address -> pmd_addr and
>_address -> pte_addr or sth like that?
>
>pretty much any naming is better than this.
>
>-- 
>Cheers
>
>David / dhildenb

-- 
Wei Yang
Help you, Help me


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

* Re: [PATCH] mm/khugepaged: fix the address passed to notifier on testing young
  2025-08-26  9:03   ` Lorenzo Stoakes
@ 2025-08-26 12:51     ` Wei Yang
  0 siblings, 0 replies; 12+ messages in thread
From: Wei Yang @ 2025-08-26 12:51 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: David Hildenbrand, Wei Yang, akpm, ziy, baolin.wang, npache,
	ryan.roberts, dev.jain, baohua, linux-mm, Liam R . Howlett,
	stable

On Tue, Aug 26, 2025 at 10:03:27AM +0100, Lorenzo Stoakes wrote:
[...]
>> >   			referenced++;
>> >   	}
>> >   	if (!writable) {
>>
>> Maybe, just maybe, it's because of *horrible* variable naming.
>>
>> Can someone please send a cleanup to rename address -> pmd_addr and
>> _address -> pte_addr or sth like that?
>
>YES THIS.
>
>>
>> pretty much any naming is better than this.
>
>I despise it, and I realyl underlined this on review in Nico's series because
>it's just beyond belief.
>

I see your comment to Nico's series.

>It's terrible. I mean maybe even I will do something about this, if my review
>load eases up at some point...
>

If you are fine, I could help to do the renaming.

>
>Cheers, Lorenzo

-- 
Wei Yang
Help you, Help me


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

end of thread, other threads:[~2025-08-26 12:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  6:33 [PATCH] mm/khugepaged: fix the address passed to notifier on testing young Wei Yang
2025-08-22  7:34 ` Dev Jain
2025-08-23  1:32   ` Wei Yang
2025-08-22  7:38 ` Dev Jain
2025-08-22  7:48   ` Greg KH
2025-08-23  1:29   ` Wei Yang
2025-08-22 17:19 ` Zi Yan
2025-08-26  8:53 ` David Hildenbrand
2025-08-26  9:03   ` Lorenzo Stoakes
2025-08-26 12:51     ` Wei Yang
2025-08-26 12:49   ` Wei Yang
2025-08-26  9:07 ` 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).