Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ksm: initialize the addr only once in rmap_walk_ksm

This is a minor performance optimization, especially when there are many
for-loop iterations, because the addr variable doesn't change across
iterations.

Therefore, it only needs to be initialized once before the loop.

Link: https://lkml.kernel.org/r/20260212192820223O_r2NQzSEPG_C56cs-z4l@zte.com.cn
Link: https://lkml.kernel.org/r/20260212192932941MSsJEAyoRW4YdLBN7_myn@zte.com.cn
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Hugh Dickins <hughd@google.com>
Cc: Wang Yaxin <wang.yaxin@zte.com.cn>
Cc: Yang Yang <yang.yang29@zte.com.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

xu xin and committed by
Andrew Morton
318d87b8 34ca46cc

+3 -4
+3 -4
mm/ksm.c
··· 3168 3168 return; 3169 3169 again: 3170 3170 hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) { 3171 + /* Ignore the stable/unstable/sqnr flags */ 3172 + const unsigned long addr = rmap_item->address & PAGE_MASK; 3171 3173 struct anon_vma *anon_vma = rmap_item->anon_vma; 3172 3174 struct anon_vma_chain *vmac; 3173 3175 struct vm_area_struct *vma; ··· 3182 3180 } 3183 3181 anon_vma_lock_read(anon_vma); 3184 3182 } 3183 + 3185 3184 anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, 3186 3185 0, ULONG_MAX) { 3187 - unsigned long addr; 3188 3186 3189 3187 cond_resched(); 3190 3188 vma = vmac->vma; 3191 - 3192 - /* Ignore the stable/unstable/sqnr flags */ 3193 - addr = rmap_item->address & PAGE_MASK; 3194 3189 3195 3190 if (addr < vma->vm_start || addr >= vma->vm_end) 3196 3191 continue;