mm/khugepaged: drain lru after swapping in shmem

JIRA: https://issues.redhat.com/browse/RHEL-27741

commit efa3d814fad151ed5209539ecc1fc2880f7680b2
Author: David Stevens <stevensd@chromium.org>
Date:   Tue Apr 4 21:01:14 2023 +0900

    mm/khugepaged: drain lru after swapping in shmem

    Patch series "mm/khugepaged: fixes for khugepaged+shmem", v6.

    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.

    This patch (of 4):

    Call lru_add_drain after swapping in shmem pages so that isolate_lru_page
    is more likely to succeed.

    Link: https://lkml.kernel.org/r/20230404120117.2562166-1-stevensd@google.com
    Link: https://lkml.kernel.org/r/20230404120117.2562166-2-stevensd@google.com
    Signed-off-by: David Stevens <stevensd@chromium.org>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Jiaqi Yan <jiaqiyan@google.com>
    Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Yang Shi <shy828301@gmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
This commit is contained in:
Chris von Recklinghausen 2024-04-12 15:16:44 -04:00
parent aea06a4977
commit ee390e7f13
1 changed files with 2 additions and 0 deletions

View File

@ -1985,6 +1985,8 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
result = SCAN_FAIL;
goto xa_unlocked;
}
/* drain pagevecs to help isolate_lru_page() */
lru_add_drain();
page = folio_file_page(folio, index);
} else if (trylock_page(page)) {
get_page(page);