* [PATCH] mm: mlock: avoid folio_within_range() on KSM pages
@ 2023-10-24 6:38 Hugh Dickins
2023-10-24 7:09 ` Yin Fengwei
0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2023-10-24 6:38 UTC (permalink / raw)
To: Andrew Morton
Cc: Yin Fengwei, Matthew Wilcox, Lorenzo Stoakes, Stefan Roesch,
linux-kernel, linux-mm
Since mm-hotfixes-stable 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).
Fixes: dc68badcede4 ("mm: mlock: update mlock_pte_range to handle large folio")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/mlock.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/mlock.c b/mm/mlock.c
index aa44456200e3..086546ac5766 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -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;
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: mlock: avoid folio_within_range() on KSM pages
2023-10-24 6:38 [PATCH] mm: mlock: avoid folio_within_range() on KSM pages Hugh Dickins
@ 2023-10-24 7:09 ` Yin Fengwei
0 siblings, 0 replies; 2+ messages in thread
From: Yin Fengwei @ 2023-10-24 7:09 UTC (permalink / raw)
To: Hugh Dickins, Andrew Morton
Cc: Matthew Wilcox, Lorenzo Stoakes, Stefan Roesch, linux-kernel, linux-mm
Hi Huge,
On 10/24/23 14:38, Hugh Dickins wrote:
> Since mm-hotfixes-stable 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).
Checking folio_test_large() here looks fine to me now. If KSM could support
large folio in the future (Not sure whether this will happen in the future),
we could revise.
>
> Fixes: dc68badcede4 ("mm: mlock: update mlock_pte_range to handle large folio")
> Signed-off-by: Hugh Dickins <hughd@google.com>
Thanks a lot for catching this issue and fixing it.
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-24 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24 6:38 [PATCH] mm: mlock: avoid folio_within_range() on KSM pages Hugh Dickins
2023-10-24 7:09 ` Yin Fengwei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox