[PATCH v2 1/2] mm/ksm: Initialize the addr only once in collect_procs_ksm
From: xu.xin16
Date: Thu Jul 09 2026 - 05:42:39 EST
From: xu xin <xu.xin16@xxxxxxxxxx>
Similar as 318d87b8fa7 ("ksm: initialize the addr only once in
rmap_walk_ksm"), only initialize the addr once in rmap_walk_ksm
because the addr variable doesn't change across iterations.
Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx>
---
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);
}
--
2.25.1