Skip to content

Commit

Permalink
mm: migrate: simplify the file-backed pages validation when migrating…
Browse files Browse the repository at this point in the history
… its mapping

There is no need to validate the file-backed page's refcount before
trying to freeze the page's expected refcount, instead we can rely on
the folio_ref_freeze() to validate if the page has the expected refcount
before migrating its mapping.

Moreover we are always under the page lock when migrating the page
mapping, which means nowhere else can remove it from the page cache, so
we can remove the xas_load() validation under the i_pages lock.

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/df4c129fd8e86a95dbc55f4663d77441cc0d3bd1.1629447552.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <[email protected]>
Suggested-by: Matthew Wilcox <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Alistair Popple <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Baolin Wang authored and torvalds committed Nov 11, 2021
1 parent 252220d commit 0ef0246
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ int folio_migrate_mapping(struct address_space *mapping,
newzone = folio_zone(newfolio);

xas_lock_irq(&xas);
if (folio_ref_count(folio) != expected_count ||
xas_load(&xas) != folio) {
xas_unlock_irq(&xas);
return -EAGAIN;
}

if (!folio_ref_freeze(folio, expected_count)) {
xas_unlock_irq(&xas);
return -EAGAIN;
Expand Down

0 comments on commit 0ef0246

Please sign in to comment.