[PATCH v2 0/2] KSM: use linear_page_index in collect_procs_ksm()

From: xu.xin16

Date: Thu Jul 09 2026 - 05:32:37 EST


From: xu xin <xu.xin16@xxxxxxxxxx>

In collect_procs_ksm() which is used to collect processes when the error
hit an ksm page, there is the same issue with rmap_walk_ksm (see the
previous discussion at [1]). So we apply the similar logic changes to
the collect_procs_ksm().

The patch [1/2] move the initializaion of addr from the position inside
loop to the position before the loop, since the variable will not change
in the loop.

The patch [2/2] optimize collect_procs_ksm by passing a suitable page offset
range to the anon_vma_interval_tree_foreach loop to reduce ineffective
checks.

[1] https://lore.kernel.org/all/20260703162253688u8Str9eFLR8TGCmo7nIOF@xxxxxxxxxx/

xu xin (2):
mm/ksm: Initialize the addr only once in collect_procs_ksm
ksm: Use precise linear_page_index instead of the whole address space

mm/ksm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--
2.25.1