Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
@ 2026-11-12 11:12 Baolin Wang
  2026-11-13  5:01 ` Barry Song
  2026-11-13 11:13 ` sashiko-bot
  0 siblings, 2 replies; 6+ messages in thread
From: Baolin Wang @ 2026-11-12 11:12 UTC (permalink / raw)
  To: akpm, david, hannes, kasong
  Cc: baohua, axelrasmussen, yuanchu, weixugc, baoquan.he, qi.zheng,
	shakeel.butt, mhocko, baolin.wang, linux-mm, linux-kernel

Use pte_table_clamped_end() to clamp the range to the PTE table and VMA
boundaries when batch-checking young flags, making the code more readable.

No functional changes intended.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
Based on mm/core.git for-next branch.

Note that this was found while reviewing David's series:
https://lore.kernel.org/all/c31cc8a0-c098-4784-a843-f13f51914094@linux.alibaba.com/
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 5495d9be90e8..804d4188e7b4 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4470,7 +4470,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
 	walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
 
 	start = max(addr & PMD_MASK, vma->vm_start);
-	end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
+	end = pte_table_clamped_end(addr, vma->vm_end);
 
 	if (end - start == PAGE_SIZE)
 		return true;
-- 
2.47.3



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

* Re: [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
  2026-11-12 11:12 [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end Baolin Wang
@ 2026-11-13  5:01 ` Barry Song
  2026-11-13  5:31   ` Baolin Wang
  2026-11-13 11:13 ` sashiko-bot
  1 sibling, 1 reply; 6+ messages in thread
From: Barry Song @ 2026-11-13  5:01 UTC (permalink / raw)
  To: Baolin Wang
  Cc: akpm, david, hannes, kasong, axelrasmussen, yuanchu, weixugc,
	baoquan.he, qi.zheng, shakeel.butt, mhocko, linux-mm,
	linux-kernel

On Thu, Nov 12, 2026 at 7:13 PM Baolin Wang
<baolin.wang@linux.alibaba.com> wrote:
>
> Use pte_table_clamped_end() to clamp the range to the PTE table and VMA
> boundaries when batch-checking young flags, making the code more readable.
>
> No functional changes intended.
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> Based on mm/core.git for-next branch.
>
> Note that this was found while reviewing David's series:
> https://lore.kernel.org/all/c31cc8a0-c098-4784-a843-f13f51914094@linux.alibaba.com/
> ---
>  mm/vmscan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 5495d9be90e8..804d4188e7b4 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4470,7 +4470,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
>         walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
>
>         start = max(addr & PMD_MASK, vma->vm_start);
> -       end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
> +       end = pte_table_clamped_end(addr, vma->vm_end);


We don't have pte_table_clamped_end() in Andrew's tree yet;
it's part of David's patch:

https://lore.kernel.org/all/20261111-pte_table_clamped_end-v1-1-2dbe339c487a@kernel.org/

So we're not going through Andrew's tree for this patch, right?

>
>         if (end - start == PAGE_SIZE)
>                 return true;
> --
> 2.47.3
>

Thanks,
Barry


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

* Re: [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
  2026-11-13  5:01 ` Barry Song
@ 2026-11-13  5:31   ` Baolin Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2026-11-13  5:31 UTC (permalink / raw)
  To: Barry Song
  Cc: akpm, david, hannes, kasong, axelrasmussen, yuanchu, weixugc,
	baoquan.he, qi.zheng, shakeel.butt, mhocko, linux-mm,
	linux-kernel



On 11/13/26 1:01 PM, Barry Song wrote:
> On Thu, Nov 12, 2026 at 7:13 PM Baolin Wang
> <baolin.wang@linux.alibaba.com> wrote:
>>
>> Use pte_table_clamped_end() to clamp the range to the PTE table and VMA
>> boundaries when batch-checking young flags, making the code more readable.
>>
>> No functional changes intended.
>>
>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
>> ---
>> Based on mm/core.git for-next branch.
>>
>> Note that this was found while reviewing David's series:
>> https://lore.kernel.org/all/c31cc8a0-c098-4784-a843-f13f51914094@linux.alibaba.com/
>> ---
>>   mm/vmscan.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 5495d9be90e8..804d4188e7b4 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -4470,7 +4470,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
>>          walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
>>
>>          start = max(addr & PMD_MASK, vma->vm_start);
>> -       end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
>> +       end = pte_table_clamped_end(addr, vma->vm_end);
> 
> 
> We don't have pte_table_clamped_end() in Andrew's tree yet;
> it's part of David's patch:
> 
> https://lore.kernel.org/all/20261111-pte_table_clamped_end-v1-1-2dbe339c487a@kernel.org/
> 
> So we're not going through Andrew's tree for this patch, right?

Yes. I think David will pick up this follow-up.


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

* Re: [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
  2026-11-12 11:12 [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end Baolin Wang
  2026-11-13  5:01 ` Barry Song
@ 2026-11-13 11:13 ` sashiko-bot
  2026-11-13 11:54   ` Baolin Wang
  1 sibling, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-11-13 11:13 UTC (permalink / raw)
  To: Baolin Wang, akpm, david, hannes, kasong
  Cc: baohua, axelrasmussen, yuanchu, weixugc, baoquan.he, qi.zheng,
	shakeel.butt, mhocko, linux-mm

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mm: mglru: call to undeclared pte_table_clamped_end() in
  lru_gen_look_around()
--

commit 921adf1dcfd3cc8b15e0745e6085a76a09ac3fb5
Author: Baolin Wang <baolin.wang@linux.alibaba.com>

mm: mglru: use pte_table_clamped_end() helper to calculate the end

This commit replaces the open-coded PTE table and VMA end address
calculation in lru_gen_look_around() with pte_table_clamped_end().

> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 25a224746c36d..cb8635e41a38a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4340,7 +4340,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
>  	walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
>  
>  	start = max(addr & PMD_MASK, vma->vm_start);
> -	end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
> +	end = pte_table_clamped_end(addr, vma->vm_end);

[Severity: High]
Does this break the build when CONFIG_LRU_GEN is enabled?
pte_table_clamped_end() is not declared or defined anywhere in the tree,
so compiling mm/vmscan.c fails with an implicit function declaration
error.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/b2386c5da61f9a15e60daa421b033bc1e0bcdd41.1794481498.git.baolin.wang@linux.alibaba.com?part=1


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

* Re: [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
  2026-11-13 11:13 ` sashiko-bot
@ 2026-11-13 11:54   ` Baolin Wang
  2026-11-13 13:16     ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 6+ messages in thread
From: Baolin Wang @ 2026-11-13 11:54 UTC (permalink / raw)
  To: sashiko-reviews, akpm, david, hannes, kasong
  Cc: baohua, axelrasmussen, yuanchu, weixugc, baoquan.he, qi.zheng,
	shakeel.butt, mhocko, linux-mm



On 11/13/26 7:13 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] mm: mglru: call to undeclared pte_table_clamped_end() in
>    lru_gen_look_around()
> --
> 
> commit 921adf1dcfd3cc8b15e0745e6085a76a09ac3fb5
> Author: Baolin Wang <baolin.wang@linux.alibaba.com>
> 
> mm: mglru: use pte_table_clamped_end() helper to calculate the end
> 
> This commit replaces the open-coded PTE table and VMA end address
> calculation in lru_gen_look_around() with pte_table_clamped_end().
> 
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 25a224746c36d..cb8635e41a38a 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -4340,7 +4340,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
>>   	walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
>>   
>>   	start = max(addr & PMD_MASK, vma->vm_start);
>> -	end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
>> +	end = pte_table_clamped_end(addr, vma->vm_end);
> 
> [Severity: High]
> Does this break the build when CONFIG_LRU_GEN is enabled?
> pte_table_clamped_end() is not declared or defined anywhere in the tree,
> so compiling mm/vmscan.c fails with an implicit function declaration
> error.

No. Because you applied the patch to the wrong tree (mm/mm-new). The 
helper has already been picked up in David's mm/core.git tree.


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

* Re: [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end
  2026-11-13 11:54   ` Baolin Wang
@ 2026-11-13 13:16     ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-13 13:16 UTC (permalink / raw)
  To: Baolin Wang, sashiko-reviews, akpm, hannes, kasong
  Cc: baohua, axelrasmussen, yuanchu, weixugc, baoquan.he, qi.zheng,
	shakeel.butt, mhocko, linux-mm

On 11/13/26 12:54, Baolin Wang wrote:
> 
> 
> On 11/13/26 7:13 PM, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue to consider:
>> - [High] mm: mglru: call to undeclared pte_table_clamped_end() in
>>    lru_gen_look_around()
>> -- 
>>
>> commit 921adf1dcfd3cc8b15e0745e6085a76a09ac3fb5
>> Author: Baolin Wang <baolin.wang@linux.alibaba.com>
>>
>> mm: mglru: use pte_table_clamped_end() helper to calculate the end
>>
>> This commit replaces the open-coded PTE table and VMA end address
>> calculation in lru_gen_look_around() with pte_table_clamped_end().
>>
>>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>>> index 25a224746c36d..cb8635e41a38a 100644
>>> --- a/mm/vmscan.c
>>> +++ b/mm/vmscan.c
>>> @@ -4340,7 +4340,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk
>>> *pvmw, unsigned int nr)
>>>       walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL;
>>>         start = max(addr & PMD_MASK, vma->vm_start);
>>> -    end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1;
>>> +    end = pte_table_clamped_end(addr, vma->vm_end);
>>
>> [Severity: High]
>> Does this break the build when CONFIG_LRU_GEN is enabled?
>> pte_table_clamped_end() is not declared or defined anywhere in the tree,
>> so compiling mm/vmscan.c fails with an implicit function declaration
>> error.
> 
> No. Because you applied the patch to the wrong tree (mm/mm-new). The helper has
> already been picked up in David's mm/core.git tree.

I'll get the relevant fix upstream next week. Once Andrew rebases he will be
able to pick this patch up :)

-- 
Cheers,

David


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

end of thread, other threads:[~2026-11-13 13:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 11:12 [PATCH] mm: mglru: use pte_table_clamped_end() helper to calculate the end Baolin Wang
2026-11-13  5:01 ` Barry Song
2026-11-13  5:31   ` Baolin Wang
2026-11-13 11:13 ` sashiko-bot
2026-11-13 11:54   ` Baolin Wang
2026-11-13 13:16     ` David Hildenbrand (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox