mm/khugepaged: fix the address passed to notifier on testing young
Subsystems (3)
PATCH 1/1 mm/khugepaged: fix the address passed to notifier on testing young
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.
---
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(-)
mm/khugepaged.c +1 -1
@@ -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) {
Signature · 1 line
2.34.1
Quoted 33 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +0
-0
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1424
Quoted 8 lines
mm/khugepaged.c +1
-1@@ -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.
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.
Quoted 30 lines · Dev Jain
Quoted 28 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1424
Quoted 13 lines
mm/khugepaged.c +1
-1@@ -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.
Signature · 2 lines
Wei Yang Help you, Help me
Dev Jain
reviewerQuoted 20 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>
Quoted 1 line
---
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.
Greg KH
maintainerQuoted 1 line · Dev Jain
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.
Quoted 22 lines · Dev Jain
Quoted 20 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>
Quoted 5 lines
Quoted 1 line
---
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.
Signature · 2 lines
Wei Yang Help you, Help me
Zi Yan
reviewerQuoted 43 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +1
-1@@ -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) {Signature · 1 line
2.34.1
LGTM. Reviewed-by: Zi Yan <[email protected]>
--
Best Regards,
Yan, Zi
Quoted 2 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test.
... "but we are passing the wrong address".
Quoted 31 lines
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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +0
-0
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1421
Quoted 5 lines
mm/khugepaged.c +1
-1@@ -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.
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1424
Quoted 3 lines
mm/khugepaged.c +0
-0referenced++; }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.
Signature · 3 lines
Cheers David / dhildenb
Quoted 49 lines · David Hildenbrand
Quoted 2 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test.... "but we are passing the wrong address".
Quoted 31 lines
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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +0
-0mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1421
Quoted 5 lines
mm/khugepaged.c +1
-1@@ -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.
Quoted 8 lines
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1424
Quoted 3 lines
mm/khugepaged.c +0
-0referenced++; }if (!writable) {Maybe, just maybe, it's because of *horrible* variable naming.
Can someone please send a cleanup to rename address ->
pmd_addrand_address->pte_addror sth like that?
YES THIS.
Quoted 2 lines
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...
Quoted 6 lines
--
CheersDavid / dhildenb
Cheers, Lorenzo
On Tue, Aug 26, 2025 at 10:03:27AM +0100, Lorenzo Stoakes wrote:
[...]
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
referenced++; } if (!writable) {Maybe, just maybe, it's because of *horrible* variable naming.
Can someone please send a cleanup to rename address ->
pmd_addrand_address->pte_addror sth like that?
Quoted 8 lines
YES THIS.
Quoted 2 lines
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.
Quoted 3 lines
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.
Quoted 2 lines
Cheers, Lorenzo
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 47 lines · David Hildenbrand
Quoted 2 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test.... "but we are passing the wrong address".
Quoted 31 lines
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 <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>---
The original commit8ee53820edfdis at 2011.
Then the code is moved tokhugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +0
-0mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1421
Quoted 5 lines
mm/khugepaged.c +1
-1@@ -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.
Quoted 1 line
Thanks.
@Andrew
Would you mind adjust the changelog and put it into one line?
Quoted 16 lines
mm/khugepaged.c static int hpage_collapse_scan_pmd(struct mm_struct *mm, · line 1424
Quoted 4 lines
mm/khugepaged.c +0
-0referenced++; }if (!writable) {Maybe, just maybe, it's because of *horrible* variable naming.
Can someone please send a cleanup to rename address ->
pmd_addrand_address->pte_addror sth like that?pretty much any naming is better than this.
Signature · 3 lines
Cheers David / dhildenb
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 7 lines · Wei Yang
Commit
8ee53820edfd("thp:mmu_notifier_test_young") introducedmmu_notifier_test_young(), but we should pass the address need to test. Inxxx_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.
Quoted 12 lines
Fixes 8ee53820edfd ("thp: mmu_notifier_test_young")Signed-off-by Wei Yang <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Zi Yan <[email protected]>Cc Baolin Wang <[email protected]>Cc Liam R. Howlett <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>CC <[email protected]>
Good spot. This code is beyond belief.
Quoted 3 lines
---
The original commit8ee53820edfdis at 2011.
Oopsies!
Quoted 22 lines
Then the code is moved to
khugepaged.cin commitb46e756f5e470("thp:
extract khugepaged frommm/huge_memory.c") in 2022.--- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/khugepaged.c +1
-2@@ -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