Message ID | 20241205175000.3187069-12-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add zpdesc memory descriptor for zswap.zpool | expand |
On Thu, Dec 05, 2024 at 05:49:48PM +0000, Matthew Wilcox (Oracle) wrote: > From: Alex Shi <alexs@kernel.org> > > zpdesc.zspage matches with page.private, zpdesc.next matches with > page.index. They will be reset in reset_page() which is called prior to > free base pages of a zspage. > Use zpdesc to replace page struct and rename it to reset_zpdesc(), few > page helper still left since they are used too widely. > > Signed-off-by: Alex Shi <alexs@kernel.org> > --- Looks good to me, Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > mm/zsmalloc.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index d8f2f8e5c877..87b2b100782f 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -861,12 +861,14 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, > return true; > } > > -static void reset_page(struct page *page) > +static void reset_zpdesc(struct zpdesc *zpdesc) > { > + struct page *page = zpdesc_page(zpdesc); > + > __ClearPageMovable(page); > ClearPagePrivate(page); > - set_page_private(page, 0); > - page->index = 0; > + zpdesc->zspage = NULL; > + zpdesc->next = NULL; > __ClearPageZsmalloc(page); > } > > @@ -905,7 +907,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_zpdesc(page_zpdesc(page)); > unlock_page(page); > dec_zone_page_state(page, NR_ZSPAGES); > put_page(page); > @@ -1884,7 +1886,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, > zpdesc_inc_zone_page_state(newzpdesc); > } > > - reset_page(page); > + reset_zpdesc(zpdesc); > zpdesc_put(zpdesc); > > return MIGRATEPAGE_SUCCESS; > -- > 2.45.2 > >
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index d8f2f8e5c877..87b2b100782f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -861,12 +861,14 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, return true; } -static void reset_page(struct page *page) +static void reset_zpdesc(struct zpdesc *zpdesc) { + struct page *page = zpdesc_page(zpdesc); + __ClearPageMovable(page); ClearPagePrivate(page); - set_page_private(page, 0); - page->index = 0; + zpdesc->zspage = NULL; + zpdesc->next = NULL; __ClearPageZsmalloc(page); } @@ -905,7 +907,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_zpdesc(page_zpdesc(page)); unlock_page(page); dec_zone_page_state(page, NR_ZSPAGES); put_page(page); @@ -1884,7 +1886,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, zpdesc_inc_zone_page_state(newzpdesc); } - reset_page(page); + reset_zpdesc(zpdesc); zpdesc_put(zpdesc); return MIGRATEPAGE_SUCCESS;