[PATCH v3 0/2] KSM: Optimizations for rmap_walk_ksm

From: xu.xin16

Date: Thu Feb 12 2026 - 06:28:37 EST


From: xu xin <xu.xin16@xxxxxxxxxx>

There are two performance optimization patches for rmap_walk_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 rmap_walk_ksm by passing a suitable page offset
range to the anon_vma_interval_tree_foreach loop to reduce ineffective
checks.

The metric performance and reproducer can be found at patch[2/2].

Changes in v3:
- Fix some typos in commit description
- Replace "pgoff_start" and 'pgoff_end' by 'pgoff'.

Changes in v2:
- Use const variable to initialize 'addr' "pgoff_start" and 'pgoff_end'
- Let pgoff_end = pgoff_start, since KSM folios are always order-0 (Suggested by David)

xu xin (2):
ksm: Initialize the addr only once in rmap_walk_ksm
ksm: Optimize rmap_walk_ksm by passing a suitable address range

mm/ksm.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

--
2.25.1