diff options
| author | xu xin <xu.xin16@zte.com.cn> | 2026-07-09 17:33:12 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-08-04 19:18:46 -0700 |
| commit | 0471cade0a272803d192cbd8d8523e93e429ff1d (patch) | |
| tree | e8d32f3d6889411175a4dfdb58b3750851878e09 | |
| parent | 887311e5cd67566a21ac8c70b9545bcc449714a8 (diff) | |
| download | linux-0471cade0a272803d192cbd8d8523e93e429ff1d.tar.gz linux-0471cade0a272803d192cbd8d8523e93e429ff1d.zip | |
ksm: use precise linear_page_index instead of the whole address space
Since we now have linear_page_index available that we can use here,
allowing for optimizing the RMAP walk, we can also use it to locate more
precisely all related-processes when error hits the KSM page, which will
decrease a lot of invalid iterations.
Link: https://lore.kernel.org/20260709173312403qgj1Af6pRkFMDSsmc19sM@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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
| -rw-r--r-- | mm/ksm.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3290,12 +3290,13 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page, for_each_process(tsk) { struct anon_vma_chain *vmac; const unsigned long addr = rmap_item->address & PAGE_MASK; + const unsigned long index = rmap_item->linear_page_index; struct task_struct *t = task_early_kill(tsk, force_early); if (!t) continue; - anon_vma_interval_tree_foreach(vmac, &av->rb_root, 0, - ULONG_MAX) + anon_vma_interval_tree_foreach(vmac, &av->rb_root, index, + index) { vma = vmac->vma; if (vma->vm_mm == t->mm) { |
