Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/zsmalloc: stop using __ClearPageMovable()

Instead, let's check in the callbacks if the page was already destroyed,
which can be checked by looking at zpdesc->zspage (see reset_zpdesc()).

If we detect that the page was destroyed:

(1) Fail isolation, just like the migration core would

(2) Fake migration success just like the migration core would

In the putback case there is nothing to do, as we don't do anything just
like the migration core would do.

In the future, we should look into not letting these pages get destroyed
while they are isolated -- and instead delaying that to the
putback/migration call. Add a TODO for that.

Link: https://lkml.kernel.org/r/20250704102524.326966-13-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Eugenio Pé rez <eperezma@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jerrin Shaji George <jerrin.shaji-george@broadcom.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: xu xin <xu.xin16@zte.com.cn>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
a1092627 be4a3e9c

+14 -4
+14 -4
mm/zsmalloc.c
··· 877 877 { 878 878 struct page *page = zpdesc_page(zpdesc); 879 879 880 - __ClearPageMovable(page); 881 880 ClearPagePrivate(page); 882 881 zpdesc->zspage = NULL; 883 882 zpdesc->next = NULL; ··· 1715 1716 static bool zs_page_isolate(struct page *page, isolate_mode_t mode) 1716 1717 { 1717 1718 /* 1718 - * Page is locked so zspage couldn't be destroyed. For detail, look at 1719 - * lock_zspage in free_zspage. 1719 + * Page is locked so zspage can't be destroyed concurrently 1720 + * (see free_zspage()). But if the page was already destroyed 1721 + * (see reset_zpdesc()), refuse isolation here. 1720 1722 */ 1721 - return true; 1723 + return page_zpdesc(page)->zspage; 1722 1724 } 1723 1725 1724 1726 static int zs_page_migrate(struct page *newpage, struct page *page, ··· 1736 1736 unsigned long handle; 1737 1737 unsigned long old_obj, new_obj; 1738 1738 unsigned int obj_idx; 1739 + 1740 + /* 1741 + * TODO: nothing prevents a zspage from getting destroyed while 1742 + * it is isolated for migration, as the page lock is temporarily 1743 + * dropped after zs_page_isolate() succeeded: we should rework that 1744 + * and defer destroying such pages once they are un-isolated (putback) 1745 + * instead. 1746 + */ 1747 + if (!zpdesc->zspage) 1748 + return MIGRATEPAGE_SUCCESS; 1739 1749 1740 1750 /* The page is locked, so this pointer must remain valid */ 1741 1751 zspage = get_zspage(zpdesc);