reset_page() is called prior to freeing base pages of a zspage. As it's closely associated with details of struct page, convert it to reset_zsdesc() and move closer to newly added zsdesc helper functions. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx> --- mm/zsmalloc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index bbb65fb8749a..5a3948cbe06f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -450,6 +450,17 @@ static inline void zsdesc_set_movable(struct zsdesc *zsdesc) __SetPageMovable(page, &zsmalloc_mops); } +static void reset_zsdesc(struct zsdesc *zsdesc) +{ + struct page *page = zsdesc_page(zsdesc); + + __ClearPageMovable(page); + ClearPagePrivate(page); + set_page_private(page, 0); + page_mapcount_reset(page); + page->index = 0; +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -1080,15 +1091,6 @@ static bool obj_stores_deferred_handle(struct zsdesc *zsdesc, void *obj, } #endif -static void reset_page(struct page *page) -{ - __ClearPageMovable(page); - ClearPagePrivate(page); - set_page_private(page, 0); - page_mapcount_reset(page); - page->index = 0; -} - static int trylock_zspage(struct zspage *zspage) { struct zsdesc *cursor, *fail; @@ -1164,7 +1166,7 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, do { VM_BUG_ON_PAGE(!PageLocked(page), page); next = get_next_page(page); - reset_page(page); + reset_zsdesc(page_zsdesc(page)); unlock_page(page); dec_zone_page_state(page, NR_ZSPAGES); put_page(page); @@ -2269,7 +2271,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, inc_zone_page_state(newpage, NR_ZSPAGES); } - reset_page(page); + reset_zsdesc(page_zsdesc(page)); put_page(page); return MIGRATEPAGE_SUCCESS; -- 2.25.1