Skip to content

Commit b1454b4

Browse files
Hugh Dickinsakpm00
authored andcommitted
mm: mlock: avoid folio_within_range() on KSM pages
Since commit dc68bad ("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: dc68bad ("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]>
1 parent 1cbf0a5 commit b1454b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/mlock.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ static inline bool allow_mlock_munlock(struct folio *folio,
346346
if (!(vma->vm_flags & VM_LOCKED))
347347
return true;
348348

349+
/* folio_within_range() cannot take KSM, but any small folio is OK */
350+
if (!folio_test_large(folio))
351+
return true;
352+
349353
/* folio not in range [start, end), skip mlock */
350354
if (!folio_within_range(folio, vma, start, end))
351355
return false;

0 commit comments

Comments
 (0)