mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 23:59:33 -04:00
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>
This commit is contained in:
5
mm/ksm.c
5
mm/ksm.c
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user