[PATCH] dbg, migrate_pages: don't batch flushing for single page migration

From: Huang Ying
Date: Mon Mar 20 2023 - 03:38:12 EST


---
mm/migrate.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 98f1c11197a8..7271209c1a03 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1113,8 +1113,8 @@ static void migrate_folio_done(struct folio *src,
static int migrate_folio_unmap(new_page_t get_new_page, free_page_t put_ne=
w_page,
unsigned long private, struct folio *src,
struct folio **dstp, int force, bool avoid_force_lock,
- enum migrate_mode mode, enum migrate_reason reason,
- struct list_head *ret)
+ bool batch_flush, enum migrate_mode mode,
+ enum migrate_reason reason, struct list_head *ret)
{
struct folio *dst;
int rc =3D -EAGAIN;
@@ -1253,7 +1253,7 @@ static int migrate_folio_unmap(new_page_t get_new_pag=
e, free_page_t put_new_page
/* Establish migration ptes */
VM_BUG_ON_FOLIO(folio_test_anon(src) &&
!folio_test_ksm(src) && !anon_vma, src);
- try_to_migrate(src, TTU_BATCH_FLUSH);
+ try_to_migrate(src, batch_flush ? TTU_BATCH_FLUSH : 0);
page_was_mapped =3D 1;
}
=20
@@ -1641,6 +1641,7 @@ static int migrate_pages_batch(struct list_head *from=
, new_page_t get_new_page,
bool nosplit =3D (reason =3D=3D MR_NUMA_MISPLACED);
bool no_split_folio_counting =3D false;
bool avoid_force_lock;
+ bool batch_flush =3D !list_is_singular(from);
=20
retry:
rc_saved =3D 0;
@@ -1690,7 +1691,7 @@ static int migrate_pages_batch(struct list_head *from=
, new_page_t get_new_page,
=20
rc =3D migrate_folio_unmap(get_new_page, put_new_page, private,
folio, &dst, pass > 2, avoid_force_lock,
- mode, reason, ret_folios);
+ batch_flush, mode, reason, ret_folios);
/*
* The rules are:
* Success: folio will be freed
@@ -1804,7 +1805,8 @@ static int migrate_pages_batch(struct list_head *from=
, new_page_t get_new_page,
stats->nr_failed_pages +=3D nr_retry_pages;
move:
/* Flush TLBs for all unmapped folios */
- try_to_unmap_flush();
+ if (batch_flush)
+ try_to_unmap_flush();
=20
retry =3D 1;
for (pass =3D 0;
--=20
2.30.2