[PATCH v6 0/4] mm/khugepaged: fixes for khugepaged+shmem
From: David Stevens
Date: Tue Apr 04 2023 - 08:01:29 EST
From: David Stevens <stevensd@xxxxxxxxxxxx>
This series reworks collapse_file so that the intermediate state of the
collapse does not leak out of collapse_file. Although this makes
collapse_file a bit more complicated, it means that the rest of the
kernel doesn't have to deal with the unusual state. This directly fixes
races with both lseek and mincore.
This series also fixes the fact that khugepaged completely breaks
userfaultfd+shmem. The rework of collapse_file provides a convenient
place to check for registered userfaultfds without making the shmem
userfaultfd implementation care about khugepaged.
Finally, this series adds a lru_add_drain after swapping in shmem pages,
which makes the subsequent folio_isolate_lru significantly more likely
to succeed.
v5 -> v6:
- Stop freezing the old pages so that we don't deadlock with
mc_handle_file_pte and mincore.
- Add missing locking around shmem charge rollback.
- Rebase on mm-unstable (f01f73d64cb5). Beyond straightfoward
conflicts, this involves adapting the fix for f520a742287e (i.e. an
unhandled ENOMEM).
- Fix bug with bounds used with vma_interval_tree_foreach.
- Add a patch doing lru_add_drain after swapping in the shmem case.
- Update/clarify some comments.
- Drop ack on final patch
v4 -> v5:
- Rebase on mm-unstable (9caa15b8a499)
- Gather acks
v3 -> v4:
- Base changes on mm-everything (fba720cb4dc0)
- Add patch to refactor error handling control flow in collapse_file
- Rebase userfaultfd patch with no significant logic changes
- Different approach for fixing lseek race
v2 -> v3:
- Use XA_RETRY_ENTRY to synchronize with reads from the page cache
under the RCU read lock in userfaultfd fix
- Add patch to fix lseek race
v1 -> v2:
- Different approach for userfaultfd fix
*** BLURB HERE ***
David Stevens (4):
mm/khugepaged: drain lru after swapping in shmem
mm/khugepaged: refactor collapse_file control flow
mm/khugepaged: skip shmem with userfaultfd
mm/khugepaged: maintain page cache uptodate flag
include/trace/events/huge_memory.h | 3 +-
mm/khugepaged.c | 312 ++++++++++++++++-------------
2 files changed, 171 insertions(+), 144 deletions(-)
--
2.40.0.348.gf938b09366-goog