Skip to content

Commit df5c32a

Browse files
davidhildenbrandgregkh
authored andcommitted
treewide: remove MIGRATEPAGE_SUCCESS
[ Upstream commit fb49a4425cfa163faccd91f913773d3401d3a7d4 ] At this point MIGRATEPAGE_SUCCESS is misnamed for all folio users, and now that we remove MIGRATEPAGE_UNMAP, it's really the only "success" return value that the code uses and expects. Let's just get rid of MIGRATEPAGE_SUCCESS completely and just use "0" for success. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Zi Yan <[email protected]> [mm] Acked-by: Dave Kleikamp <[email protected]> [jfs] Acked-by: David Sterba <[email protected]> [btrfs] Acked-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Byungchul Park <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Al Viro <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Benjamin LaHaise <[email protected]> Cc: Chris Mason <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Dave Kleikamp <[email protected]> Cc: Eugenio Pé rez <[email protected]> Cc: Gregory Price <[email protected]> Cc: "Huang, Ying" <[email protected]> Cc: Jan Kara <[email protected]> Cc: Jason Wang <[email protected]> Cc: Jerrin Shaji George <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Joshua Hahn <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Mathew Brost <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Muchun Song <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Rakie Kim <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Xuan Zhuo <[email protected]> Cc: Lance Yang <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Stable-dep-of: 4ba5a8a7faa6 ("vmw_balloon: indicate success when effectively deflating during migration") Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fa81416 commit df5c32a

11 files changed

Lines changed: 36 additions & 46 deletions

File tree

arch/powerpc/platforms/pseries/cmm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static int cmm_migratepage(struct balloon_dev_info *b_dev_info,
545545
/* balloon page list reference */
546546
put_page(page);
547547

548-
return MIGRATEPAGE_SUCCESS;
548+
return 0;
549549
}
550550

551551
static void cmm_balloon_compaction_init(void)

drivers/misc/vmw_balloon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
18061806
* the list after acquiring the lock.
18071807
*/
18081808
get_page(newpage);
1809-
ret = MIGRATEPAGE_SUCCESS;
1809+
ret = 0;
18101810
}
18111811

18121812
/* Update the balloon list under the @pages_lock */
@@ -1817,7 +1817,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
18171817
* If we succeed just insert it to the list and update the statistics
18181818
* under the lock.
18191819
*/
1820-
if (ret == MIGRATEPAGE_SUCCESS) {
1820+
if (!ret) {
18211821
balloon_page_insert(&b->b_dev_info, newpage);
18221822
__count_vm_event(BALLOON_MIGRATE);
18231823
}

drivers/virtio/virtio_balloon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
875875
balloon_page_finalize(page);
876876
put_page(page); /* balloon reference */
877877

878-
return MIGRATEPAGE_SUCCESS;
878+
return 0;
879879
}
880880
#endif /* CONFIG_BALLOON_COMPACTION */
881881

fs/aio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst,
445445
folio_get(dst);
446446

447447
rc = folio_migrate_mapping(mapping, dst, src, 1);
448-
if (rc != MIGRATEPAGE_SUCCESS) {
448+
if (rc) {
449449
folio_put(dst);
450450
goto out_unlock;
451451
}

fs/btrfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7430,15 +7430,15 @@ static int btrfs_migrate_folio(struct address_space *mapping,
74307430
{
74317431
int ret = filemap_migrate_folio(mapping, dst, src, mode);
74327432

7433-
if (ret != MIGRATEPAGE_SUCCESS)
7433+
if (ret)
74347434
return ret;
74357435

74367436
if (folio_test_ordered(src)) {
74377437
folio_clear_ordered(src);
74387438
folio_set_ordered(dst);
74397439
}
74407440

7441-
return MIGRATEPAGE_SUCCESS;
7441+
return 0;
74427442
}
74437443
#else
74447444
#define btrfs_migrate_folio NULL

fs/hugetlbfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
10541054
int rc;
10551055

10561056
rc = migrate_huge_page_move_mapping(mapping, dst, src);
1057-
if (rc != MIGRATEPAGE_SUCCESS)
1057+
if (rc)
10581058
return rc;
10591059

10601060
if (hugetlb_folio_subpool(src)) {
@@ -1065,7 +1065,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
10651065

10661066
folio_migrate_flags(dst, src);
10671067

1068-
return MIGRATEPAGE_SUCCESS;
1068+
return 0;
10691069
}
10701070
#else
10711071
#define hugetlbfs_migrate_folio NULL

fs/jfs/jfs_metapage.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
169169
}
170170

171171
rc = filemap_migrate_folio(mapping, dst, src, mode);
172-
if (rc != MIGRATEPAGE_SUCCESS)
172+
if (rc)
173173
return rc;
174174

175175
for (i = 0; i < MPS_PER_PAGE; i++) {
@@ -199,7 +199,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
199199
}
200200
}
201201

202-
return MIGRATEPAGE_SUCCESS;
202+
return 0;
203203
}
204204
#endif /* CONFIG_MIGRATION */
205205

@@ -242,7 +242,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
242242
return -EAGAIN;
243243

244244
rc = filemap_migrate_folio(mapping, dst, src, mode);
245-
if (rc != MIGRATEPAGE_SUCCESS)
245+
if (rc)
246246
return rc;
247247

248248
if (unlikely(insert_metapage(dst, mp)))
@@ -253,7 +253,7 @@ static int __metapage_migrate_folio(struct address_space *mapping,
253253
mp->folio = dst;
254254
remove_metapage(src, mp);
255255

256-
return MIGRATEPAGE_SUCCESS;
256+
return 0;
257257
}
258258
#endif /* CONFIG_MIGRATION */
259259

include/linux/migrate.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ typedef void free_folio_t(struct folio *folio, unsigned long private);
1212

1313
struct migration_target_control;
1414

15-
/*
16-
* Return values from addresss_space_operations.migratepage():
17-
* - negative errno on page migration failure;
18-
* - zero on page migration success;
19-
*/
20-
#define MIGRATEPAGE_SUCCESS 0
21-
2215
/**
2316
* struct movable_operations - Driver page migration
2417
* @isolate_page:
@@ -34,8 +27,7 @@ struct migration_target_control;
3427
* @src page. The driver should copy the contents of the
3528
* @src page to the @dst page and set up the fields of @dst page.
3629
* Both pages are locked.
37-
* If page migration is successful, the driver should
38-
* return MIGRATEPAGE_SUCCESS.
30+
* If page migration is successful, the driver should return 0.
3931
* If the driver cannot migrate the page at the moment, it can return
4032
* -EAGAIN. The VM interprets this as a temporary migration failure and
4133
* will retry it later. Any other error value is a permanent migration

mm/migrate.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,17 @@ static void putback_movable_ops_page(struct page *page)
231231
* src and dst are also released by migration core. These pages will not be
232232
* folios in the future, so that must be reworked.
233233
*
234-
* Returns MIGRATEPAGE_SUCCESS on success, otherwise a negative error
235-
* code.
234+
* Returns 0 on success, otherwise a negative error code.
236235
*/
237236
static int migrate_movable_ops_page(struct page *dst, struct page *src,
238237
enum migrate_mode mode)
239238
{
240-
int rc = MIGRATEPAGE_SUCCESS;
239+
int rc;
241240

242241
VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(src), src);
243242
VM_WARN_ON_ONCE_PAGE(!PageMovableOpsIsolated(src), src);
244243
rc = page_movable_ops(src)->migrate_page(dst, src, mode);
245-
if (rc == MIGRATEPAGE_SUCCESS)
244+
if (!rc)
246245
ClearPageMovableOpsIsolated(src);
247246
return rc;
248247
}
@@ -587,7 +586,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
587586
if (folio_test_swapbacked(folio))
588587
__folio_set_swapbacked(newfolio);
589588

590-
return MIGRATEPAGE_SUCCESS;
589+
return 0;
591590
}
592591

593592
oldzone = folio_zone(folio);
@@ -688,7 +687,7 @@ static int __folio_migrate_mapping(struct address_space *mapping,
688687
}
689688
local_irq_enable();
690689

691-
return MIGRATEPAGE_SUCCESS;
690+
return 0;
692691
}
693692

694693
int folio_migrate_mapping(struct address_space *mapping,
@@ -737,7 +736,7 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
737736

738737
xas_unlock_irq(&xas);
739738

740-
return MIGRATEPAGE_SUCCESS;
739+
return 0;
741740
}
742741

743742
/*
@@ -853,14 +852,14 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
853852
return rc;
854853

855854
rc = __folio_migrate_mapping(mapping, dst, src, expected_count);
856-
if (rc != MIGRATEPAGE_SUCCESS)
855+
if (rc)
857856
return rc;
858857

859858
if (src_private)
860859
folio_attach_private(dst, folio_detach_private(src));
861860

862861
folio_migrate_flags(dst, src);
863-
return MIGRATEPAGE_SUCCESS;
862+
return 0;
864863
}
865864

866865
/**
@@ -967,7 +966,7 @@ static int __buffer_migrate_folio(struct address_space *mapping,
967966
}
968967

969968
rc = filemap_migrate_folio(mapping, dst, src, mode);
970-
if (rc != MIGRATEPAGE_SUCCESS)
969+
if (rc)
971970
goto unlock_buffers;
972971

973972
bh = head;
@@ -1071,7 +1070,7 @@ static int fallback_migrate_folio(struct address_space *mapping,
10711070
*
10721071
* Return value:
10731072
* < 0 - error code
1074-
* MIGRATEPAGE_SUCCESS - success
1073+
* 0 - success
10751074
*/
10761075
static int move_to_new_folio(struct folio *dst, struct folio *src,
10771076
enum migrate_mode mode)
@@ -1099,7 +1098,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
10991098
else
11001099
rc = fallback_migrate_folio(mapping, dst, src, mode);
11011100

1102-
if (rc == MIGRATEPAGE_SUCCESS) {
1101+
if (!rc) {
11031102
/*
11041103
* For pagecache folios, src->mapping must be cleared before src
11051104
* is freed. Anonymous folios must stay anonymous until freed.
@@ -1449,7 +1448,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
14491448
if (folio_ref_count(src) == 1) {
14501449
/* page was freed from under us. So we are done. */
14511450
folio_putback_hugetlb(src);
1452-
return MIGRATEPAGE_SUCCESS;
1451+
return 0;
14531452
}
14541453

14551454
dst = get_new_folio(src, private);
@@ -1512,8 +1511,7 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
15121511
rc = move_to_new_folio(dst, src, mode);
15131512

15141513
if (page_was_mapped)
1515-
remove_migration_ptes(src,
1516-
rc == MIGRATEPAGE_SUCCESS ? dst : src, 0);
1514+
remove_migration_ptes(src, !rc ? dst : src, 0);
15171515

15181516
unlock_put_anon:
15191517
folio_unlock(dst);
@@ -1522,15 +1520,15 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio,
15221520
if (anon_vma)
15231521
put_anon_vma(anon_vma);
15241522

1525-
if (rc == MIGRATEPAGE_SUCCESS) {
1523+
if (!rc) {
15261524
move_hugetlb_state(src, dst, reason);
15271525
put_new_folio = NULL;
15281526
}
15291527

15301528
out_unlock:
15311529
folio_unlock(src);
15321530
out:
1533-
if (rc == MIGRATEPAGE_SUCCESS)
1531+
if (!rc)
15341532
folio_putback_hugetlb(src);
15351533
else if (rc != -EAGAIN)
15361534
list_move_tail(&src->lru, ret);
@@ -1640,7 +1638,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
16401638
reason, ret_folios);
16411639
/*
16421640
* The rules are:
1643-
* Success: hugetlb folio will be put back
1641+
* 0: hugetlb folio will be put back
16441642
* -EAGAIN: stay on the from list
16451643
* -ENOMEM: stay on the from list
16461644
* Other errno: put on ret_folios list
@@ -1657,7 +1655,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio,
16571655
retry++;
16581656
nr_retry_pages += nr_pages;
16591657
break;
1660-
case MIGRATEPAGE_SUCCESS:
1658+
case 0:
16611659
stats->nr_succeeded += nr_pages;
16621660
break;
16631661
default:
@@ -1711,7 +1709,7 @@ static void migrate_folios_move(struct list_head *src_folios,
17111709
reason, ret_folios);
17121710
/*
17131711
* The rules are:
1714-
* Success: folio will be freed
1712+
* 0: folio will be freed
17151713
* -EAGAIN: stay on the unmap_folios list
17161714
* Other errno: put on ret_folios list
17171715
*/
@@ -1721,7 +1719,7 @@ static void migrate_folios_move(struct list_head *src_folios,
17211719
*thp_retry += is_thp;
17221720
*nr_retry_pages += nr_pages;
17231721
break;
1724-
case MIGRATEPAGE_SUCCESS:
1722+
case 0:
17251723
stats->nr_succeeded += nr_pages;
17261724
stats->nr_thp_succeeded += is_thp;
17271725
break;

mm/migrate_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
778778
if (migrate && migrate->fault_page == page)
779779
extra_cnt = 1;
780780
r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
781-
if (r != MIGRATEPAGE_SUCCESS)
781+
if (r)
782782
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
783783
else
784784
folio_migrate_flags(newfolio, folio);

0 commit comments

Comments
 (0)