[PATCH 0/2] mm/ksm: optimize unstable_tree_search_insert()
From: Chengming Zhou
Date: Wed May 08 2024 - 07:38:03 EST
We use unstable_tree_search_insert() to find matched page or insert our
rmap_item into the unstable tree if no matched found.
Now it may return NULL too early in which cases we can do better:
1. get_mergeable_page() return NULL: which means tree_rmap_item is stale.
2. tree_page is migrated to another node and !ksm_merge_across_nodes.
In both cases, we can just remove the staled or migrated one out of the
unstable tree, so our rmap_item can be inserted successfully. The code
flow becomes clearer and may increase the merge possibility too.
Thanks for review and comments!
Signed-off-by: Chengming Zhou <chengming.zhou@xxxxxxxxx>
---
Chengming Zhou (2):
mm/ksm: re-search unstable tree when tree_rmap_item is stale
mm/ksm: flush out migrated rmap_item to insert our rmap_item
mm/ksm.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
---
base-commit: fb0f40125feec3de7ef4524600ac83946207117e
change-id: 20240508-b4-ksm-unstable-insert-0329446317e1
Best regards,
--
Chengming Zhou <chengming.zhou@xxxxxxxxx>