Commit 19979497 authored by Vishal Moola (Oracle)'s avatar Vishal Moola (Oracle) Committed by Andrew Morton

mm/migrate: convert isolate_movable_page() to use folios

Removes 6 calls to compound_head() and prepares the function to take in a
folio instead of page argument.

Link: https://lkml.kernel.org/r/20230130214352.40538-4-vishal.moola@gmail.comSigned-off-by: default avatarVishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent da707a6d
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
int isolate_movable_page(struct page *page, isolate_mode_t mode) int isolate_movable_page(struct page *page, isolate_mode_t mode)
{ {
struct folio *folio = folio_get_nontail_page(page);
const struct movable_operations *mops; const struct movable_operations *mops;
/* /*
...@@ -71,11 +72,11 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) ...@@ -71,11 +72,11 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode)
* the put_page() at the end of this block will take care of * the put_page() at the end of this block will take care of
* release this page, thus avoiding a nasty leakage. * release this page, thus avoiding a nasty leakage.
*/ */
if (unlikely(!get_page_unless_zero(page))) if (!folio)
goto out; goto out;
if (unlikely(PageSlab(page))) if (unlikely(folio_test_slab(folio)))
goto out_putpage; goto out_putfolio;
/* Pairs with smp_wmb() in slab freeing, e.g. SLUB's __free_slab() */ /* Pairs with smp_wmb() in slab freeing, e.g. SLUB's __free_slab() */
smp_rmb(); smp_rmb();
/* /*
...@@ -83,12 +84,12 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) ...@@ -83,12 +84,12 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode)
* we use non-atomic bitops on newly allocated page flags so * we use non-atomic bitops on newly allocated page flags so
* unconditionally grabbing the lock ruins page's owner side. * unconditionally grabbing the lock ruins page's owner side.
*/ */
if (unlikely(!__PageMovable(page))) if (unlikely(!__folio_test_movable(folio)))
goto out_putpage; goto out_putfolio;
/* Pairs with smp_wmb() in slab allocation, e.g. SLUB's alloc_slab_page() */ /* Pairs with smp_wmb() in slab allocation, e.g. SLUB's alloc_slab_page() */
smp_rmb(); smp_rmb();
if (unlikely(PageSlab(page))) if (unlikely(folio_test_slab(folio)))
goto out_putpage; goto out_putfolio;
/* /*
* As movable pages are not isolated from LRU lists, concurrent * As movable pages are not isolated from LRU lists, concurrent
...@@ -101,29 +102,29 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) ...@@ -101,29 +102,29 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode)
* lets be sure we have the page lock * lets be sure we have the page lock
* before proceeding with the movable page isolation steps. * before proceeding with the movable page isolation steps.
*/ */
if (unlikely(!trylock_page(page))) if (unlikely(!folio_trylock(folio)))
goto out_putpage; goto out_putfolio;
if (!PageMovable(page) || PageIsolated(page)) if (!folio_test_movable(folio) || folio_test_isolated(folio))
goto out_no_isolated; goto out_no_isolated;
mops = page_movable_ops(page); mops = folio_movable_ops(folio);
VM_BUG_ON_PAGE(!mops, page); VM_BUG_ON_FOLIO(!mops, folio);
if (!mops->isolate_page(page, mode)) if (!mops->isolate_page(&folio->page, mode))
goto out_no_isolated; goto out_no_isolated;
/* Driver shouldn't use PG_isolated bit of page->flags */ /* Driver shouldn't use PG_isolated bit of page->flags */
WARN_ON_ONCE(PageIsolated(page)); WARN_ON_ONCE(folio_test_isolated(folio));
SetPageIsolated(page); folio_set_isolated(folio);
unlock_page(page); folio_unlock(folio);
return 0; return 0;
out_no_isolated: out_no_isolated:
unlock_page(page); folio_unlock(folio);
out_putpage: out_putfolio:
put_page(page); folio_put(folio);
out: out:
return -EBUSY; return -EBUSY;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment