Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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/20220902194653.1739778-52-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
c33db292 682a71a1

+14 -14
+14 -14
mm/migrate.c
··· 1263 1263 if (!hugepage_migration_supported(page_hstate(hpage))) 1264 1264 return -ENOSYS; 1265 1265 1266 - if (page_count(hpage) == 1) { 1266 + if (folio_ref_count(src) == 1) { 1267 1267 /* page was freed from under us. So we are done. */ 1268 1268 putback_active_hugepage(hpage); 1269 1269 return MIGRATEPAGE_SUCCESS; ··· 1274 1274 return -ENOMEM; 1275 1275 dst = page_folio(new_hpage); 1276 1276 1277 - if (!trylock_page(hpage)) { 1277 + if (!folio_trylock(src)) { 1278 1278 if (!force) 1279 1279 goto out; 1280 1280 switch (mode) { ··· 1284 1284 default: 1285 1285 goto out; 1286 1286 } 1287 - lock_page(hpage); 1287 + folio_lock(src); 1288 1288 } 1289 1289 1290 1290 /* 1291 1291 * 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 1293 1293 * be called and we could leak usage counts for subpools. 1294 1294 */ 1295 - if (hugetlb_page_subpool(hpage) && !page_mapping(hpage)) { 1295 + if (hugetlb_page_subpool(hpage) && !folio_mapping(src)) { 1296 1296 rc = -EBUSY; 1297 1297 goto out_unlock; 1298 1298 } 1299 1299 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); 1302 1302 1303 - if (unlikely(!trylock_page(new_hpage))) 1303 + if (unlikely(!folio_trylock(dst))) 1304 1304 goto put_anon; 1305 1305 1306 - if (page_mapped(hpage)) { 1306 + if (folio_mapped(src)) { 1307 1307 enum ttu_flags ttu = 0; 1308 1308 1309 - if (!PageAnon(hpage)) { 1309 + if (!folio_test_anon(src)) { 1310 1310 /* 1311 1311 * In shared mappings, try_to_unmap could potentially 1312 1312 * call huge_pmd_unshare. Because of this, take ··· 1327 1327 i_mmap_unlock_write(mapping); 1328 1328 } 1329 1329 1330 - if (!page_mapped(hpage)) 1330 + if (!folio_mapped(src)) 1331 1331 rc = move_to_new_folio(dst, src, mode); 1332 1332 1333 1333 if (page_was_mapped) ··· 1335 1335 rc == MIGRATEPAGE_SUCCESS ? dst : src, false); 1336 1336 1337 1337 unlock_put_anon: 1338 - unlock_page(new_hpage); 1338 + folio_unlock(dst); 1339 1339 1340 1340 put_anon: 1341 1341 if (anon_vma) ··· 1347 1347 } 1348 1348 1349 1349 out_unlock: 1350 - unlock_page(hpage); 1350 + folio_unlock(src); 1351 1351 out: 1352 1352 if (rc == MIGRATEPAGE_SUCCESS) 1353 1353 putback_active_hugepage(hpage); 1354 1354 else if (rc != -EAGAIN) 1355 - list_move_tail(&hpage->lru, ret); 1355 + list_move_tail(&src->lru, ret); 1356 1356 1357 1357 /* 1358 1358 * If migration was not successful and there's a freeing callback, use