diff mbox series

[RFC,v4,1/6] migrate: Allow migrate_misplaced_folio_prepare() to accept a NULL VMA.

Message ID 20250411221111.493193-2-gourry@gourry.net (mailing list archive)
State New
Headers show
Series Promotion of Unmapped Page Cache Folios. | expand

Commit Message

Gregory Price April 11, 2025, 10:11 p.m. UTC
migrate_misplaced_folio_prepare() may be called on a folio without
a VMA, and so it must be made to accept a NULL VMA.

Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Gregory Price <gourry@gourry.net>
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

SeongJae Park April 15, 2025, 12:12 a.m. UTC | #1
On Fri, 11 Apr 2025 18:11:06 -0400 Gregory Price <gourry@gourry.net> wrote:

> migrate_misplaced_folio_prepare() may be called on a folio without
> a VMA, and so it must be made to accept a NULL VMA.

The comment of the function says "Must be called with the PTL still held".  I
understand it is not needed for NULL VMA case because it is for unmapped
folios?  If I'm understanding correctly, could you please also clarify such
details including when NULL VMA case happens and if locking requirement is
changed, on the comment?


Thanks,
SJ

[...]
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index f3ee6d8d5e2e..047131f6c839 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2654,7 +2654,7 @@  int migrate_misplaced_folio_prepare(struct folio *folio,
 		 * See folio_maybe_mapped_shared() on possible imprecision
 		 * when we cannot easily detect if a folio is shared.
 		 */
-		if ((vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio))
+		if (vma && (vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio))
 			return -EACCES;
 
 		/*