[PATCH v2 0/3] Optimizations for khugepaged

From: Dev Jain
Date: Wed Jun 25 2025 - 01:58:30 EST


This patch series uses PTE batching to optimize two functions, and
also addresses a race condition.

---
@David I did not make the clear_full_ptes clean up since that will require
some more work than I originally thought :)

v1->v2:
- Use for loop instead of do-while loop (Lorenzo)
- Remove folio_test_large check since the subpage-check condition
will imply that (Baolin)
- Combine patch 1 and 2 into this series, add new patch 3

Dev Jain (3):
khugepaged: Optimize __collapse_huge_page_copy_succeeded() by PTE
batching
khugepaged: Optimize collapse_pte_mapped_thp() for large folios by PTE
batching
khugepaged: Reduce race probability between migration and khugepaged

mm/khugepaged.c | 77 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 57 insertions(+), 20 deletions(-)

--
2.30.2