]> Git Repo - linux.git/commitdiff
mm: mlock: avoid folio_within_range() on KSM pages
authorHugh Dickins <[email protected]>
Tue, 24 Oct 2023 06:38:41 +0000 (23:38 -0700)
committerAndrew Morton <[email protected]>
Wed, 25 Oct 2023 23:47:14 +0000 (16:47 -0700)
Since commit dc68badcede4 ("mm: mlock: update mlock_pte_range to handle
large folio") I've just occasionally seen VM_WARN_ON_FOLIO(folio_test_ksm)
warnings from folio_within_range(), in a splurge after testing with KSM
hyperactive.

folio_referenced_one()'s use of folio_within_vma() is safe because it
checks folio_test_large() first; but allow_mlock_munlock() needs to do the
same to avoid those warnings (or check !folio_test_ksm() itself?  Or move
either check into folio_within_range()?  Hard to tell without more
examples of its use).

Link: https://lkml.kernel.org/r/[email protected]
Fixes: dc68badcede4 ("mm: mlock: update mlock_pte_range to handle large folio")
Signed-off-by: Hugh Dickins <[email protected]>
Reviewed-by: Yin Fengwei <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Stefan Roesch <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/mlock.c

index aa44456200e3432da5ef1befd96695125bc8937b..086546ac5766db712752fa79a9e8dabb1a81cc71 100644 (file)
@@ -346,6 +346,10 @@ static inline bool allow_mlock_munlock(struct folio *folio,
        if (!(vma->vm_flags & VM_LOCKED))
                return true;
 
+       /* folio_within_range() cannot take KSM, but any small folio is OK */
+       if (!folio_test_large(folio))
+               return true;
+
        /* folio not in range [start, end), skip mlock */
        if (!folio_within_range(folio, vma, start, end))
                return false;
This page took 0.06498 seconds and 4 git commands to generate.