Skip to content

Commit fa1df3f

Browse files
Kefeng Wangakpm00
authored andcommitted
mm: migrate: remove isolated variable in add_page_for_migration()
Directly check the return of isolate_hugetlb() and folio_isolate_lru() to remove isolated variable, also setup err = -EBUSY in advance before isolation, and update err only when successfully queued for migration, which could help us to unify and simplify code a bit. Link: https://lkml.kernel.org/r/20230913095131.2426871-9-wangkefeng.wang@huawei.com Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Reviewed-by: Zi Yan <ziy@nvidia.com> Cc: David Hildenbrand <david@redhat.com> Cc: "Huang, Ying" <ying.huang@intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent b426ed7 commit fa1df3f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

mm/migrate.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,6 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p,
20622062
struct page *page;
20632063
struct folio *folio;
20642064
int err;
2065-
bool isolated;
20662065

20672066
mmap_read_lock(mm);
20682067
addr = (unsigned long)untagged_addr_remote(mm, p);
@@ -2095,15 +2094,13 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p,
20952094
if (page_mapcount(page) > 1 && !migrate_all)
20962095
goto out_putfolio;
20972096

2097+
err = -EBUSY;
20982098
if (folio_test_hugetlb(folio)) {
2099-
isolated = isolate_hugetlb(folio, pagelist);
2100-
err = isolated ? 1 : -EBUSY;
2099+
if (isolate_hugetlb(folio, pagelist))
2100+
err = 1;
21012101
} else {
2102-
isolated = folio_isolate_lru(folio);
2103-
if (!isolated) {
2104-
err = -EBUSY;
2102+
if (!folio_isolate_lru(folio))
21052103
goto out_putfolio;
2106-
}
21072104

21082105
err = 1;
21092106
list_add_tail(&folio->lru, pagelist);

0 commit comments

Comments
 (0)