Skip to content

Commit c33db29

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
migrate: convert unmap_and_move_huge_page() to use folios
Saves several calls to compound_head() and removes a couple of uses of page->lru. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 682a71a commit c33db29

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

mm/migrate.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
12631263
if (!hugepage_migration_supported(page_hstate(hpage)))
12641264
return -ENOSYS;
12651265

1266-
if (page_count(hpage) == 1) {
1266+
if (folio_ref_count(src) == 1) {
12671267
/* page was freed from under us. So we are done. */
12681268
putback_active_hugepage(hpage);
12691269
return MIGRATEPAGE_SUCCESS;
@@ -1274,7 +1274,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
12741274
return -ENOMEM;
12751275
dst = page_folio(new_hpage);
12761276

1277-
if (!trylock_page(hpage)) {
1277+
if (!folio_trylock(src)) {
12781278
if (!force)
12791279
goto out;
12801280
switch (mode) {
@@ -1284,29 +1284,29 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
12841284
default:
12851285
goto out;
12861286
}
1287-
lock_page(hpage);
1287+
folio_lock(src);
12881288
}
12891289

12901290
/*
12911291
* Check for pages which are in the process of being freed. Without
1292-
* page_mapping() set, hugetlbfs specific move page routine will not
1292+
* folio_mapping() set, hugetlbfs specific move page routine will not
12931293
* be called and we could leak usage counts for subpools.
12941294
*/
1295-
if (hugetlb_page_subpool(hpage) && !page_mapping(hpage)) {
1295+
if (hugetlb_page_subpool(hpage) && !folio_mapping(src)) {
12961296
rc = -EBUSY;
12971297
goto out_unlock;
12981298
}
12991299

1300-
if (PageAnon(hpage))
1301-
anon_vma = page_get_anon_vma(hpage);
1300+
if (folio_test_anon(src))
1301+
anon_vma = page_get_anon_vma(&src->page);
13021302

1303-
if (unlikely(!trylock_page(new_hpage)))
1303+
if (unlikely(!folio_trylock(dst)))
13041304
goto put_anon;
13051305

1306-
if (page_mapped(hpage)) {
1306+
if (folio_mapped(src)) {
13071307
enum ttu_flags ttu = 0;
13081308

1309-
if (!PageAnon(hpage)) {
1309+
if (!folio_test_anon(src)) {
13101310
/*
13111311
* In shared mappings, try_to_unmap could potentially
13121312
* call huge_pmd_unshare. Because of this, take
@@ -1327,15 +1327,15 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
13271327
i_mmap_unlock_write(mapping);
13281328
}
13291329

1330-
if (!page_mapped(hpage))
1330+
if (!folio_mapped(src))
13311331
rc = move_to_new_folio(dst, src, mode);
13321332

13331333
if (page_was_mapped)
13341334
remove_migration_ptes(src,
13351335
rc == MIGRATEPAGE_SUCCESS ? dst : src, false);
13361336

13371337
unlock_put_anon:
1338-
unlock_page(new_hpage);
1338+
folio_unlock(dst);
13391339

13401340
put_anon:
13411341
if (anon_vma)
@@ -1347,12 +1347,12 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
13471347
}
13481348

13491349
out_unlock:
1350-
unlock_page(hpage);
1350+
folio_unlock(src);
13511351
out:
13521352
if (rc == MIGRATEPAGE_SUCCESS)
13531353
putback_active_hugepage(hpage);
13541354
else if (rc != -EAGAIN)
1355-
list_move_tail(&hpage->lru, ret);
1355+
list_move_tail(&src->lru, ret);
13561356

13571357
/*
13581358
* If migration was not successful and there's a freeing callback, use

0 commit comments

Comments
 (0)