summaryrefslogtreecommitdiff
path: root/mm/migrate_device.c
diff options
context:
space:
mode:
authorAlistair Popple <apopple@nvidia.com>2022-08-30 05:01:38 +0300
committerAndrew Morton <akpm@linux-foundation.org>2022-09-12 06:26:05 +0300
commit0742e49026121371c7ce1f640628c68c7da175d6 (patch)
tree7f4d5dab1a38219ff04aed245eb73a3b3eed3f0c /mm/migrate_device.c
parent663d0cfd2e77aa3ed170df76d441c8f07efa3cf6 (diff)
downloadlinux-0742e49026121371c7ce1f640628c68c7da175d6.tar.xz
mm/migrate_device.c: fix a misleading and outdated comment
Commit ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") changed the way trylock_page() in migrate_vma_collect_pmd() works without updating the comment. Reword the comment to be less misleading and a better reflection of what happens. Link: https://lkml.kernel.org/r/20220830020138.497063-1-apopple@nvidia.com Fixes: ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") Signed-off-by: Alistair Popple <apopple@nvidia.com> Reported-by: Peter Xu <peterx@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/migrate_device.c')
-rw-r--r--mm/migrate_device.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 27fb37d65476..72354248dde9 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -185,9 +185,16 @@ again:
get_page(page);
/*
- * Optimize for the common case where page is only mapped once
- * in one process. If we can lock the page, then we can safely
- * set up a special migration page table entry now.
+ * We rely on trylock_page() to avoid deadlock between
+ * concurrent migrations where each is waiting on the others
+ * page lock. If we can't immediately lock the page we fail this
+ * migration as it is only best effort anyway.
+ *
+ * If we can lock the page it's safe to set up a migration entry
+ * now. In the common case where the page is mapped once in a
+ * single process setting up the migration entry now is an
+ * optimisation to avoid walking the rmap later with
+ * try_to_migrate().
*/
if (trylock_page(page)) {
bool anon_exclusive;