To migrate unmapped pagecache folios, migrate_misplaced_folio and
migrate_misplaced_folio_prepare must handle folios without VMAs.
migrate_misplaced_folio_prepare checks VMA for exec bits, so allow
a NULL VMA when it does not have a mapping.
migrate_misplaced_folio must call migrate_pages with MIGRATE_SYNC
when in the pagecache path because it is a synchronous context.
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(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index dfb5eba3c522..3b0bd3f21ac3 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2632,7 +2632,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio,
* See folio_likely_mapped_shared() on possible imprecision
* when we cannot easily detect if a folio is shared.
*/
- if ((vma->vm_flags & VM_EXEC) &&
+ if (vma && (vma->vm_flags & VM_EXEC) &&
folio_likely_mapped_shared(folio))
return -EACCES;
--
2.43.0
On 11/27/2024 1:51 PM, Gregory Price wrote: > To migrate unmapped pagecache folios, migrate_misplaced_folio and > migrate_misplaced_folio_prepare must handle folios without VMAs. > > migrate_misplaced_folio_prepare checks VMA for exec bits, so allow > a NULL VMA when it does not have a mapping. > > migrate_misplaced_folio must call migrate_pages with MIGRATE_SYNC > when in the pagecache path because it is a synchronous context. > > 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(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index dfb5eba3c522..3b0bd3f21ac3 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2632,7 +2632,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio, > * See folio_likely_mapped_shared() on possible imprecision > * when we cannot easily detect if a folio is shared. > */ > - if ((vma->vm_flags & VM_EXEC) && > + if (vma && (vma->vm_flags & VM_EXEC) && > folio_likely_mapped_shared(folio)) > return -EACCES; > Thanks for this patch. This would be helpful in the cases of independent page scanning algorithms where we do not have a VMA associated with that. Hopefully it can be taken to tree independently. Feel free to add. Reviewed-by: Raghavendra K T <raghavendra.kt@amd.com>
Hi, Gregory, Gregory Price <gourry@gourry.net> writes: > To migrate unmapped pagecache folios, migrate_misplaced_folio and > migrate_misplaced_folio_prepare must handle folios without VMAs. IMHO, it's better to use migrate_misplaced_folio() instead of migrate_misplaced_folio for readability in patch title and description. > migrate_misplaced_folio_prepare checks VMA for exec bits, so allow > a NULL VMA when it does not have a mapping. > > migrate_misplaced_folio must call migrate_pages with MIGRATE_SYNC > when in the pagecache path because it is a synchronous context. I don't find the corresponding implementation for this. And, I don't think it's a good idea to change from MIGRATE_ASYNC to MIGRATE_SYNC. This may cause too long page access latency for page placement optimization. The downside may offset the benefit. And, it appears that we can delete the "vma" parameter of migrate_misplaced_folio() because it's not used now. This is a trivial code cleanup. > 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(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index dfb5eba3c522..3b0bd3f21ac3 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2632,7 +2632,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio, > * See folio_likely_mapped_shared() on possible imprecision > * when we cannot easily detect if a folio is shared. > */ > - if ((vma->vm_flags & VM_EXEC) && > + if (vma && (vma->vm_flags & VM_EXEC) && > folio_likely_mapped_shared(folio)) > return -EACCES; --- Best Regards, Huang, Ying
On Thu, Nov 28, 2024 at 07:12:11PM +0800, Huang, Ying wrote: > Hi, Gregory, > > Gregory Price <gourry@gourry.net> writes: > > > To migrate unmapped pagecache folios, migrate_misplaced_folio and > > migrate_misplaced_folio_prepare must handle folios without VMAs. > > IMHO, it's better to use migrate_misplaced_folio() instead of > migrate_misplaced_folio for readability in patch title and description. > > > migrate_misplaced_folio_prepare checks VMA for exec bits, so allow > > a NULL VMA when it does not have a mapping. > > > > migrate_misplaced_folio must call migrate_pages with MIGRATE_SYNC > > when in the pagecache path because it is a synchronous context. > > I don't find the corresponding implementation for this. And, I don't > think it's a good idea to change from MIGRATE_ASYNC to MIGRATE_SYNC. > This may cause too long page access latency for page placement > optimization. The downside may offset the benefit. > > And, it appears that we can delete the "vma" parameter of > migrate_misplaced_folio() because it's not used now. This is a trivial > code cleanup. > This patch apparently got a bit away from me and was heavily reduced from its initial form. This commit message is just wrong now. I will update this and the 2nd commit and probably submit them separately. ~Gregory
© 2016 - 2026 Red Hat, Inc.