Skip to content

Commit

Permalink
migrate_pages: move migrate_folio_unmap()
Browse files Browse the repository at this point in the history
Just move the position of the functions.  There's no any functionality
change.  This is to make it easier to review the next patch via putting
code near its position in the next patch.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: "Huang, Ying" <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Bharata B Rao <[email protected]>
Cc: Alistair Popple <[email protected]>
Cc: Xin Hao <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Hyeonggon Yoo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
yhuang-intel authored and akpm00 committed Feb 17, 2023
1 parent 5dfab10 commit 80562ba
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,56 @@ static int __migrate_folio_unmap(struct folio *src, struct folio *dst, int force
return rc;
}

/* Obtain the lock on page, remove all ptes. */
static int migrate_folio_unmap(new_page_t get_new_page, free_page_t put_new_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)
{
struct folio *dst;
int rc = MIGRATEPAGE_UNMAP;
struct page *newpage = NULL;

if (!thp_migration_supported() && folio_test_transhuge(src))
return -ENOSYS;

if (folio_ref_count(src) == 1) {
/* Folio was freed from under us. So we are done. */
folio_clear_active(src);
folio_clear_unevictable(src);
/* free_pages_prepare() will clear PG_isolated. */
list_del(&src->lru);
migrate_folio_done(src, reason);
return MIGRATEPAGE_SUCCESS;
}

newpage = get_new_page(&src->page, private);
if (!newpage)
return -ENOMEM;
dst = page_folio(newpage);
*dstp = dst;

dst->private = NULL;
rc = __migrate_folio_unmap(src, dst, force, avoid_force_lock, mode);
if (rc == MIGRATEPAGE_UNMAP)
return rc;

/*
* A folio that has not been unmapped will be restored to
* right list unless we want to retry.
*/
if (rc != -EAGAIN && rc != -EDEADLOCK)
list_move_tail(&src->lru, ret);

if (put_new_page)
put_new_page(&dst->page, private);
else
folio_put(dst);

return rc;
}

static int __migrate_folio_move(struct folio *src, struct folio *dst,
enum migrate_mode mode)
{
Expand Down Expand Up @@ -1296,56 +1346,6 @@ static int __migrate_folio_move(struct folio *src, struct folio *dst,
return rc;
}

/* Obtain the lock on page, remove all ptes. */
static int migrate_folio_unmap(new_page_t get_new_page, free_page_t put_new_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)
{
struct folio *dst;
int rc = MIGRATEPAGE_UNMAP;
struct page *newpage = NULL;

if (!thp_migration_supported() && folio_test_transhuge(src))
return -ENOSYS;

if (folio_ref_count(src) == 1) {
/* Folio was freed from under us. So we are done. */
folio_clear_active(src);
folio_clear_unevictable(src);
/* free_pages_prepare() will clear PG_isolated. */
list_del(&src->lru);
migrate_folio_done(src, reason);
return MIGRATEPAGE_SUCCESS;
}

newpage = get_new_page(&src->page, private);
if (!newpage)
return -ENOMEM;
dst = page_folio(newpage);
*dstp = dst;

dst->private = NULL;
rc = __migrate_folio_unmap(src, dst, force, avoid_force_lock, mode);
if (rc == MIGRATEPAGE_UNMAP)
return rc;

/*
* A folio that has not been unmapped will be restored to
* right list unless we want to retry.
*/
if (rc != -EAGAIN && rc != -EDEADLOCK)
list_move_tail(&src->lru, ret);

if (put_new_page)
put_new_page(&dst->page, private);
else
folio_put(dst);

return rc;
}

/* Migrate the folio to the newly allocated folio in dst. */
static int migrate_folio_move(free_page_t put_new_page, unsigned long private,
struct folio *src, struct folio *dst,
Expand Down

0 comments on commit 80562ba

Please sign in to comment.