Re: [PATCH 1/2] mm/ksm: Initialize the addr only once in collect_procs_ksm

From: David Hildenbrand (Arm)

Date: Wed Jul 08 2026 - 04:11:28 EST


On 7/8/26 06:19, xu.xin16@xxxxxxxxxx wrote:
> From: xu xin <xu.xin16@xxxxxxxxxx>
>
> Similar with 318d87b8fa7 ("ksm: initialize the addr only once in rmap_walk_ksm"),

checkpatch.pl should complain here

"Similar as commit 318d87b8fa7 ("ksm: initialize the addr only once in
rmap_walk_ksm")," ...

> Only initialize the addr only once in rmap_walk_ksm because the addr variable

s/Only/only/, but you une one "only" too much here.

> doesn't change across iterations.
>
> Signed-off-by: Xu Xin <xu.xin16@xxxxxxx>
> ---
> mm/ksm.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/ksm.c b/mm/ksm.c
> index c1dcc3cb4831..337eb04a9340 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -3289,7 +3289,7 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page,
> rcu_read_lock();
> for_each_process(tsk) {
> struct anon_vma_chain *vmac;
> - unsigned long addr;
> + const unsigned long addr = rmap_item->address & PAGE_MASK;
> struct task_struct *t =
> task_early_kill(tsk, force_early);
> if (!t)
> @@ -3299,7 +3299,6 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page,
> {
> vma = vmac->vma;
> if (vma->vm_mm == t->mm) {
> - addr = rmap_item->address & PAGE_MASK;
> add_to_kill_ksm(t, page, vma, to_kill,
> addr);
> }


--
Cheers,

David