add zpdesc memory descriptor for zswap.zpool
Subsystems (2)
cover add zpdesc memory descriptor for zswap.zpool
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes mem_desc on destination purpose.
https://lore.kernel.org/lkml/[email protected]/
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.
For zpdesc(page), z3fold just uses the 5th member zppage_flag, which match with page.private. Potentially uses the first member flags for headless PG_locked, list_head lru and page.mapping|PAGE_MAPPING_MOVABLE for page migration.
This patachset could save 26Kbyetes z3fold.o size, basely saving come from the page to folio conversion.
Thanks a lot!
Alex
Alex Shi (15):
mm/z3fold: add zpdesc struct and helper and use them in
z3fold_page_isolate
mm/z3fold: use zpdesc in z3fold_page_migrate mm/z3fold: use zpdesc in z3fold_page_putback mm/z3fold: use zpdesc in get/put_z3fold_header funcs mm/z3fold: use zpdesc in init_z3fold_page
mm/z3fold: use zpdesc in free_z3fold_page
mm/z3fold: convert page to zpdesc in __release_z3fold_page mm/z3fold: use zpdesc free_pages_work
mm/z3fold: use zpdesc in z3fold_compact_page and do_compact_page mm/z3fold: use zpdesc in __z3fold_alloc
mm/z3fold: use zpdesc in z3fold_alloc
mm/z3fold: use zpdesc in free_z3fold_page and z3fold_free mm/z3fold: use zpdesc in z3fold_map/z3fold_unmap mm/z3fold: introduce __zpdesc_set_movable
mm/z3fold: introduce __zpdesc_clear_movable
mm/z3fold.c | 190 +++++++++++++++++++++++++++------------------------- mm/zpdesc.h | 87 ++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 93 deletions(-) create mode 100644 mm/zpdesc.h
Signature · 1 line
2.43.0
PATCH 1/15 mm/z3fold: add zpdesc struct and helper and use them in z3fold_page_isolate
From: Alex Shi <[email protected]>
The 1st patch here, we introduce some helper functions along with struct zpdesc, like zpdesc_page/zpdesc_folio/page_zpdesc and zpdesc_address similar with folio_address, and convert page to zpdesc in func z3fold_page_isolate. z3fold_page_isolate() hooked to page_isolate that the reason we could not fully remove page from its parameter for now.
--- mm/z3fold.c | 14 ++++++++------ mm/zpdesc.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 mm/zpdesc.h
mm/z3fold.c +8 -6
@@ -40,6 +40,7 @@#include <linux/spinlock.h> #include <linux/zpool.h> #include <linux/kmemleak.h> +#include "zpdesc.h" /* * NCHUNKS_ORDER determines the internal allocation granularity, effectively
@@ -1251,22 +1252,23 @@ static bool z3fold_page_isolate(struct page *page, isolate_mode_t mode) {struct z3fold_header *zhdr;struct z3fold_pool *pool; +struct zpdesc *zpdesc =page_zpdesc (page); -VM_BUG_ON_PAGE (PageIsolated (page), page); +VM_BUG_ON_PAGE (PageIsolated (zpdesc_page (zpdesc)),zpdesc_page (zpdesc)); -if (test_bit (PAGE_HEADLESS , &page->private)) +if (test_bit (PAGE_HEADLESS , &zpdesc->zppage_flag))return false; - zhdr =page_address (page); + zhdr =zpdesc_address (zpdesc);z3fold_page_lock (zhdr); -if (test_bit (NEEDS_COMPACTING , &page->private) || -test_bit (PAGE_STALE , &page->private)) +if (test_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag) || +test_bit (PAGE_STALE , &zpdesc->zppage_flag)) goto out;if (zhdr->mapped_count !=0 || zhdr->foreign_handles !=0 ) goto out; -if (test_and_set_bit (PAGE_CLAIMED , &page->private)) +if (test_and_set_bit (PAGE_CLAIMED , &zpdesc->zppage_flag)) goto out; pool =zhdr_to_pool (zhdr);spin_lock (&pool->lock);
mm/zpdesc.h new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 2/15 mm/z3fold: use zpdesc in z3fold_page_migrate
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in z3fold_page_migrate. And introduce zpdesc_get/put base on folio_get/put helpers, since z3fold only deal with single pages.
This patch could save about 12Kbytes.
--- mm/z3fold.c | 30 ++++++++++++++++-------------- mm/zpdesc.h | 10 ++++++++++ 2 files changed, 26 insertions(+), 14 deletions(-)
mm/z3fold.c +16 -14
@@ -1290,18 +1290,20 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page, {struct z3fold_header *zhdr, *new_zhdr;struct z3fold_pool *pool; +struct zpdesc *zpdesc =page_zpdesc (page); +struct zpdesc *newzpdesc =page_zpdesc (newpage); -VM_BUG_ON_PAGE (!PageIsolated (page), page); -VM_BUG_ON_PAGE (!test_bit (PAGE_CLAIMED , &page->private), page); -VM_BUG_ON_PAGE (!PageLocked (newpage), newpage); +VM_BUG_ON_PAGE (!PageIsolated (zpdesc_page (zpdesc)),zpdesc_page (zpdesc)); +VM_BUG_ON_PAGE (!test_bit (PAGE_CLAIMED , &zpdesc->zppage_flag),zpdesc_page (zpdesc)); +VM_BUG_ON_PAGE (!PageLocked (zpdesc_page (newzpdesc)),zpdesc_page (newzpdesc)); - zhdr =page_address (page); + zhdr =zpdesc_address (zpdesc); pool =zhdr_to_pool (zhdr);if (!z3fold_page_trylock (zhdr))return -EAGAIN ;if (zhdr->mapped_count !=0 || zhdr->foreign_handles !=0 ) { -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);z3fold_page_unlock (zhdr);return -EBUSY ; }
@@ -1309,10 +1311,10 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page,z3fold_page_unlock (zhdr);return -EAGAIN ; } - new_zhdr =page_address (newpage); + new_zhdr =zpdesc_address (newzpdesc);memcpy (new_zhdr, zhdr,PAGE_SIZE ); - newpage->private = page->private; -set_bit (PAGE_MIGRATED , &page->private); + newzpdesc->zppage_flag = zpdesc->zppage_flag; +set_bit (PAGE_MIGRATED , &zpdesc->zppage_flag);z3fold_page_unlock (zhdr);spin_lock_init (&new_zhdr->page_lock);INIT_WORK (&new_zhdr->work, compact_page_work);
@@ -1321,9 +1323,9 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page,* so we only have to reinitialize it. */ INIT_LIST_HEAD (&new_zhdr->buddy); -__ClearPageMovable (page); +__ClearPageMovable (zpdesc_page (zpdesc)); -get_page (newpage); +zpdesc_get (newzpdesc);z3fold_page_lock (new_zhdr);if (new_zhdr->first_chunks)encode_handle (new_zhdr,FIRST );
@@ -1331,16 +1333,16 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page,encode_handle (new_zhdr,LAST );if (new_zhdr->middle_chunks)encode_handle (new_zhdr,MIDDLE ); -set_bit (NEEDS_COMPACTING , &newpage->private); +set_bit (NEEDS_COMPACTING , &newzpdesc->zppage_flag); new_zhdr->cpu =smp_processor_id (); -__SetPageMovable (newpage, &z3fold_mops); +__SetPageMovable (zpdesc_page (newzpdesc), &z3fold_mops);z3fold_page_unlock (new_zhdr);queue_work_on (new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);/* PAGE_CLAIMED and PAGE_MIGRATED are cleared now. */ - page->private =0 ; -put_page (page); + zpdesc->zppage_flag =0 ; +zpdesc_put (zpdesc);return 0 ; }
mm/zpdesc.h +10 -0
@@ -48,4 +48,14 @@ static inline void *zpdesc_address(const struct zpdesc *zpdesc) return folio_address(zpdesc_folio(zpdesc)); } +static inline void zpdesc_get (struct zpdesc *zpdesc) +{ +folio_get (zpdesc_folio (zpdesc)); +} + +static inline void zpdesc_put (struct zpdesc *zpdesc) +{ +folio_put (zpdesc_folio (zpdesc)); +} +#endif
Signature · 1 line
2.43.0
PATCH 3/15 mm/z3fold: use zpdesc in z3fold_page_putback
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in z3fold_page_putback function, and keep the 'page' parameter since the function hooks to page_putback, which is used by other users.
--- mm/z3fold.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/z3fold.c +3 -2
@@ -1350,8 +1350,9 @@ static void z3fold_page_putback(struct page *page) {struct z3fold_header *zhdr;struct z3fold_pool *pool; +struct zpdesc *zpdesc =page_zpdesc (page); - zhdr =page_address (page); + zhdr =zpdesc_address (zpdesc); pool =zhdr_to_pool (zhdr);z3fold_page_lock (zhdr);
@@ -1362,7 +1363,7 @@ static void z3fold_page_putback(struct page *page)return ;if (list_empty (&zhdr->buddy))add_to_unbuddied (pool, zhdr); -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);z3fold_page_unlock (zhdr); }
Signature · 1 line
2.43.0
PATCH 4/15 mm/z3fold: use zpdesc in get/put_z3fold_header funcs
In reply to [email protected]From: Alex Shi <[email protected]>
Convert the get/put_z3fold_header funcs pair to use zpdesc.
--- mm/z3fold.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/z3fold.c +4 -4
@@ -254,9 +254,9 @@ static inline struct z3fold_header *get_z3fold_header(unsigned long handle) locked =z3fold_page_trylock (zhdr);read_unlock (&slots->lock);if (locked) { -struct page *page =virt_to_page (zhdr); +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr)); -if (!test_bit (PAGE_MIGRATED , &page->private)) +if (!test_bit (PAGE_MIGRATED , &zpdesc->zppage_flag))break ;z3fold_page_unlock (zhdr); }
@@ -271,9 +271,9 @@ static inline struct z3fold_header *get_z3fold_header(unsigned long handle)static inline void put_z3fold_header (struct z3fold_header *zhdr) { -struct page *page =virt_to_page (zhdr); +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr)); -if (!test_bit (PAGE_HEADLESS , &page->private)) +if (!test_bit (PAGE_HEADLESS , &zpdesc->zppage_flag))z3fold_page_unlock (zhdr); }
Signature · 1 line
2.43.0
PATCH 5/15 mm/z3fold: use zpdesc in init_z3fold_page
In reply to [email protected]From: Alex Shi <[email protected]>
The func only uses page.private member, now use zpdesc.zppage_flag to replace it.
--- mm/z3fold.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
mm/z3fold.c +8 -7
@@ -320,15 +320,16 @@ static inline void free_handle(unsigned long handle, struct z3fold_header *zhdr)static struct z3fold_header *init_z3fold_page (struct page *page,bool headless,struct z3fold_pool *pool,gfp_t gfp) { -struct z3fold_header *zhdr =page_address (page); +struct zpdesc *zpdesc =page_zpdesc (page); +struct z3fold_header *zhdr =zpdesc_address (zpdesc);struct z3fold_buddy_slots *slots; -clear_bit (PAGE_HEADLESS , &page->private); -clear_bit (MIDDLE_CHUNK_MAPPED , &page->private); -clear_bit (NEEDS_COMPACTING , &page->private); -clear_bit (PAGE_STALE , &page->private); -clear_bit (PAGE_CLAIMED , &page->private); -clear_bit (PAGE_MIGRATED , &page->private); +clear_bit (PAGE_HEADLESS , &zpdesc->zppage_flag); +clear_bit (MIDDLE_CHUNK_MAPPED , &zpdesc->zppage_flag); +clear_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag); +clear_bit (PAGE_STALE , &zpdesc->zppage_flag); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag); +clear_bit (PAGE_MIGRATED , &zpdesc->zppage_flag);if (headless)return zhdr;
Signature · 1 line
2.43.0
PATCH 6/15 mm/z3fold: use zpdesc in free_z3fold_page
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in free_z3fold_page and introduce new helper zpdesc_lock/unlock. this patch could saves about 10kbytes on object file size.
--- mm/z3fold.c | 10 ++++++---- mm/zpdesc.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-)
mm/z3fold.c +6 -4
@@ -351,12 +351,14 @@ static struct z3fold_header *init_z3fold_page(struct page *page, bool headless,/* Resets the struct page fields and frees the page */ static void free_z3fold_page (struct page *page,bool headless) { +struct zpdesc *zpdesc =page_zpdesc (page); +if (!headless) { -lock_page (page); -__ClearPageMovable (page); -unlock_page (page); +zpdesc_lock (zpdesc); +__ClearPageMovable (zpdesc_page (zpdesc)); +zpdesc_unlock (zpdesc); } -__free_page (page); +__free_page (zpdesc_page (zpdesc)); }/* Helper function to build the index */
mm/zpdesc.h +10 -0
@@ -58,4 +58,14 @@ static inline void zpdesc_put(struct zpdesc *zpdesc) folio_put(zpdesc_folio(zpdesc)); } +static inline void zpdesc_lock (struct zpdesc *zpdesc) +{ +folio_lock (zpdesc_folio (zpdesc)); +} + +static inline void zpdesc_unlock (struct zpdesc *zpdesc) +{ +folio_unlock (zpdesc_folio (zpdesc)); +} +#endif
Signature · 1 line
2.43.0
PATCH 7/15 mm/z3fold: convert page to zpdesc in __release_z3fold_page
In reply to [email protected]From: Alex Shi <[email protected]>
The main purpose is converting page->private to zpdesc->zppage_flag.
--- mm/z3fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/z3fold.c +3 -3
@@ -441,12 +441,12 @@ static inline struct z3fold_pool *zhdr_to_pool(struct z3fold_header *zhdr)static void __release_z3fold_page (struct z3fold_header *zhdr,bool locked) { -struct page *page =virt_to_page (zhdr); +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr));struct z3fold_pool *pool =zhdr_to_pool (zhdr);WARN_ON (!list_empty (&zhdr->buddy)); -set_bit (PAGE_STALE , &page->private); -clear_bit (NEEDS_COMPACTING , &page->private); +set_bit (PAGE_STALE , &zpdesc->zppage_flag); +clear_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag);spin_lock (&pool->lock);spin_unlock (&pool->lock);
Signature · 1 line
2.43.0
PATCH 8/15 mm/z3fold: use zpdesc free_pages_work
In reply to [email protected]From: Alex Shi <[email protected]>
The main purpose is converting page->private to zpdesc->zppage_flag.
--- mm/z3fold.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/z3fold.c +3 -3
@@ -501,14 +501,14 @@ static void free_pages_work(struct work_struct *w)while (!list_empty (&pool->stale)) {struct z3fold_header *zhdr =list_first_entry (&pool->stale, struct z3fold_header, buddy); -struct page *page =virt_to_page (zhdr); +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr));list_del (&zhdr->buddy); -if (WARN_ON (!test_bit (PAGE_STALE , &page->private))) +if (WARN_ON (!test_bit (PAGE_STALE , &zpdesc->zppage_flag)))continue ;spin_unlock (&pool->stale_lock);cancel_work_sync (&zhdr->work); -free_z3fold_page (page, false); +free_z3fold_page (zpdesc_page (zpdesc), false);cond_resched ();spin_lock (&pool->stale_lock); }
Signature · 1 line
2.43.0
PATCH 9/15 mm/z3fold: use zpdesc in z3fold_compact_page and do_compact_page
In reply to [email protected]From: Alex Shi <[email protected]>
The main purpose is converting page->private to zpdesc->zppage_flag too.
--- mm/z3fold.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
mm/z3fold.c +9 -10
@@ -691,12 +691,12 @@ static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)/* Has to be called with lock held */ static int z3fold_compact_page (struct z3fold_header *zhdr) { -struct page *page =virt_to_page (zhdr); +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr)); -if (test_bit (MIDDLE_CHUNK_MAPPED , &page->private)) +if (test_bit (MIDDLE_CHUNK_MAPPED , &zpdesc->zppage_flag))return 0 ;/* can't move middle chunk, it's used */ -if (unlikely (PageIsolated (page))) +if (unlikely (PageIsolated (zpdesc_page (zpdesc))))return 0 ;if (zhdr->middle_chunks ==0 )
@@ -739,14 +739,13 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)static void do_compact_page (struct z3fold_header *zhdr,bool locked) {struct z3fold_pool *pool =zhdr_to_pool (zhdr); -struct page *page; +struct zpdesc *zpdesc =page_zpdesc (virt_to_page (zhdr)); - page =virt_to_page (zhdr);if (locked)WARN_ON (z3fold_page_trylock (zhdr));else z3fold_page_lock (zhdr); -if (WARN_ON (!test_and_clear_bit (NEEDS_COMPACTING , &page->private))) { +if (WARN_ON (!test_and_clear_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag))) {z3fold_page_unlock (zhdr);return ; }
@@ -757,8 +756,8 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)if (put_z3fold_locked (zhdr))return ; -if (test_bit (PAGE_STALE , &page->private) || -test_and_set_bit (PAGE_CLAIMED , &page->private)) { +if (test_bit (PAGE_STALE , &zpdesc->zppage_flag) || +test_and_set_bit (PAGE_CLAIMED , &zpdesc->zppage_flag)) {z3fold_page_unlock (zhdr);return ; }
@@ -766,7 +765,7 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)if (!zhdr->foreign_handles &&buddy_single (zhdr) && zhdr->mapped_count ==0 &&compact_single_buddy (zhdr)) {if (!put_z3fold_locked (zhdr)) { -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);z3fold_page_unlock (zhdr); }return ;
@@ -774,7 +773,7 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)z3fold_compact_page (zhdr);add_to_unbuddied (pool, zhdr); -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);z3fold_page_unlock (zhdr); }
Signature · 1 line
2.43.0
PATCH 10/15 mm/z3fold: use zpdesc in __z3fold_alloc
In reply to [email protected]From: Alex Shi <[email protected]>
The main purpose is converting page->private to zpdesc->zppage_flag.
--- mm/z3fold.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
mm/z3fold.c +7 -7
@@ -790,7 +790,7 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool, size_t size, bool can_sleep) {struct z3fold_header *zhdr =NULL ; -struct page *page; +struct zpdesc *zpdesc;struct list_head *unbuddied;int chunks =size_to_chunks (size), i;
@@ -823,9 +823,9 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool, zhdr->cpu =-1 ;spin_unlock (&pool->lock); - page =virt_to_page (zhdr); -if (test_bit (NEEDS_COMPACTING , &page->private) || -test_bit (PAGE_CLAIMED , &page->private)) { + zpdesc =page_zpdesc (virt_to_page (zhdr)); +if (test_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag) || +test_bit (PAGE_CLAIMED , &zpdesc->zppage_flag)) {z3fold_page_unlock (zhdr); zhdr =NULL ;migrate_enable ();
@@ -868,9 +868,9 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool, zhdr->cpu =-1 ;spin_unlock (&pool->lock); - page =virt_to_page (zhdr); -if (test_bit (NEEDS_COMPACTING , &page->private) || -test_bit (PAGE_CLAIMED , &page->private)) { + zpdesc =page_zpdesc (virt_to_page (zhdr)); +if (test_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag) || +test_bit (PAGE_CLAIMED , &zpdesc->zppage_flag)) {z3fold_page_unlock (zhdr); zhdr =NULL ;if (can_sleep)
Signature · 1 line
2.43.0
PATCH 11/15 mm/z3fold: use zpdesc in z3fold_alloc
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in z3fold_alloc func. Since both func use zpdesc now, we can pass zpdesc to init_z3fold_page().
And introduce zpdesc_trylock helper. This patch could save about 12KB object file size.
--- mm/z3fold.c | 29 ++++++++++++++--------------- mm/zpdesc.h | 5 +++++ 2 files changed, 19 insertions(+), 15 deletions(-)
mm/z3fold.c +14 -15
@@ -317,10 +317,9 @@ static inline void free_handle(unsigned long handle, struct z3fold_header *zhdr) }/* Initializes the z3fold header of a newly allocated z3fold page */ -static struct z3fold_header *init_z3fold_page (struct page *page,bool headless, +static struct z3fold_header *init_z3fold_page (struct zpdesc *zpdesc,bool headless,struct z3fold_pool *pool,gfp_t gfp) { -struct zpdesc *zpdesc =page_zpdesc (page);struct z3fold_header *zhdr =zpdesc_address (zpdesc);struct z3fold_buddy_slots *slots;
@@ -1006,7 +1005,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, {int chunks =size_to_chunks (size);struct z3fold_header *zhdr =NULL ; -struct page *page =NULL ; +struct zpdesc *zpdesc =NULL ;enum buddy bud;bool can_sleep =gfpflags_allow_blocking (gfp);
@@ -1030,35 +1029,35 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,WARN_ON (1 ); goto retry; } - page =virt_to_page (zhdr); + zpdesc =page_zpdesc (virt_to_page (zhdr)); goto found; } bud =FIRST ; } - page =alloc_page (gfp); -if (!page) + zpdesc =page_zpdesc (alloc_page (gfp)); +if (!zpdesc)return -ENOMEM ; - zhdr =init_z3fold_page (page, bud ==HEADLESS , pool, gfp); + zhdr =init_z3fold_page (zpdesc, bud ==HEADLESS , pool, gfp);if (!zhdr) { -__free_page (page); +__free_page (zpdesc_page (zpdesc));return -ENOMEM ; }atomic64_inc (&pool->pages_nr);if (bud ==HEADLESS ) { -set_bit (PAGE_HEADLESS , &page->private); +set_bit (PAGE_HEADLESS , &zpdesc->zppage_flag); goto headless; }if (can_sleep) { -lock_page (page); -__SetPageMovable (page, &z3fold_mops); -unlock_page (page); +zpdesc_lock (zpdesc); +__SetPageMovable (zpdesc_page (zpdesc), &z3fold_mops); +zpdesc_unlock (zpdesc); }else { -WARN_ON (!trylock_page (page)); -__SetPageMovable (page, &z3fold_mops); -unlock_page (page); +WARN_ON (!zpdesc_trylock (zpdesc)); +__SetPageMovable (zpdesc_page (zpdesc), &z3fold_mops); +zpdesc_unlock (zpdesc); }z3fold_page_lock (zhdr);
mm/zpdesc.h +5 -0
@@ -63,6 +63,11 @@ static inline void zpdesc_lock(struct zpdesc *zpdesc)folio_lock (zpdesc_folio (zpdesc)); } +static inline bool zpdesc_trylock (struct zpdesc *zpdesc) +{ +return folio_trylock (zpdesc_folio (zpdesc)); +} +static inline void zpdesc_unlock (struct zpdesc *zpdesc) {folio_unlock (zpdesc_folio (zpdesc));
Signature · 1 line
2.43.0
PATCH 12/15 mm/z3fold: use zpdesc in free_z3fold_page and z3fold_free
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in free_z3fold_page and its caller z3fold_free, it could save 430bytes.
--- mm/z3fold.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
mm/z3fold.c +12 -14
@@ -347,11 +347,9 @@ static struct z3fold_header *init_z3fold_page(struct zpdesc *zpdesc, bool headlereturn zhdr; } -/* Resets the struct page fields and frees the page */ -static void free_z3fold_page (struct page *page,bool headless) +/* Resets the struct zpdesc fields and frees the page */ +static void free_z3fold_page (struct zpdesc *zpdesc,bool headless) { -struct zpdesc *zpdesc =page_zpdesc (page); -if (!headless) {zpdesc_lock (zpdesc);__ClearPageMovable (zpdesc_page (zpdesc));
@@ -507,7 +505,7 @@ static void free_pages_work(struct work_struct *w)continue ;spin_unlock (&pool->stale_lock);cancel_work_sync (&zhdr->work); -free_z3fold_page (zpdesc_page (zpdesc), false); +free_z3fold_page (zpdesc, false);cond_resched ();spin_lock (&pool->stale_lock); }
@@ -1095,15 +1093,15 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,static void z3fold_free (struct z3fold_pool *pool,unsigned long handle) {struct z3fold_header *zhdr; -struct page *page; +struct zpdesc *zpdesc;enum buddy bud;bool page_claimed; zhdr =get_z3fold_header (handle); - page =virt_to_page (zhdr); - page_claimed =test_and_set_bit (PAGE_CLAIMED , &page->private); + zpdesc =page_zpdesc (virt_to_page (zhdr)); + page_claimed =test_and_set_bit (PAGE_CLAIMED , &zpdesc->zppage_flag); -if (test_bit (PAGE_HEADLESS , &page->private)) { +if (test_bit (PAGE_HEADLESS , &zpdesc->zppage_flag)) {/* if a headless page is under reclaim, just leave. * NB: we use test_and_set_bit for a reason: if the bit * has not been set before, we release this page
@@ -1111,7 +1109,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)*/ if (!page_claimed) {put_z3fold_header (zhdr); -free_z3fold_page (page, true); +free_z3fold_page (zpdesc, true);atomic64_dec (&pool->pages_nr); }return ;
@@ -1146,20 +1144,20 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)put_z3fold_header (zhdr);return ; } -if (test_and_set_bit (NEEDS_COMPACTING , &page->private)) { -clear_bit (PAGE_CLAIMED , &page->private); +if (test_and_set_bit (NEEDS_COMPACTING , &zpdesc->zppage_flag)) { +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);put_z3fold_header (zhdr);return ; }if (zhdr->cpu <0 || !cpu_online (zhdr->cpu)) { zhdr->cpu =-1 ;kref_get (&zhdr->refcount); -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);do_compact_page (zhdr, true);return ; }kref_get (&zhdr->refcount); -clear_bit (PAGE_CLAIMED , &page->private); +clear_bit (PAGE_CLAIMED , &zpdesc->zppage_flag);queue_work_on (zhdr->cpu, pool->compact_wq, &zhdr->work);put_z3fold_header (zhdr); }
Signature · 1 line
2.43.0
PATCH 13/15 mm/z3fold: use zpdesc in z3fold_map/z3fold_unmap
In reply to [email protected]From: Alex Shi <[email protected]>
Convert page to zpdesc in z3fold_map/z3fold_unmap pair, the main purpose is doing page->private to zpdesc->zppage_flag conversion.
--- mm/z3fold.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
mm/z3fold.c +8 -8
@@ -1175,15 +1175,15 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)static void *z3fold_map (struct z3fold_pool *pool,unsigned long handle) {struct z3fold_header *zhdr; -struct page *page; +struct zpdesc *zpdesc;void *addr;enum buddy buddy; zhdr =get_z3fold_header (handle); addr = zhdr; - page =virt_to_page (zhdr); + zpdesc =page_zpdesc (virt_to_page (zhdr)); -if (test_bit (PAGE_HEADLESS , &page->private)) +if (test_bit (PAGE_HEADLESS , &zpdesc->zppage_flag)) goto out; buddy =handle_to_buddy (handle);
@@ -1193,7 +1193,7 @@ static void *z3fold_map(struct z3fold_pool *pool, unsigned long handle)break ;case MIDDLE : addr += zhdr->start_middle <<CHUNK_SHIFT ; -set_bit (MIDDLE_CHUNK_MAPPED , &page->private); +set_bit (MIDDLE_CHUNK_MAPPED , &zpdesc->zppage_flag);break ;case LAST : addr +=PAGE_SIZE - (handle_to_chunks (handle) <<CHUNK_SHIFT );
@@ -1220,18 +1220,18 @@ static void *z3fold_map(struct z3fold_pool *pool, unsigned long handle)static void z3fold_unmap (struct z3fold_pool *pool,unsigned long handle) {struct z3fold_header *zhdr; -struct page *page; +struct zpdesc *zpdesc;enum buddy buddy; zhdr =get_z3fold_header (handle); - page =virt_to_page (zhdr); + zpdesc =page_zpdesc (virt_to_page (zhdr)); -if (test_bit (PAGE_HEADLESS , &page->private)) +if (test_bit (PAGE_HEADLESS , &zpdesc->zppage_flag))return ; buddy =handle_to_buddy (handle);if (buddy ==MIDDLE ) -clear_bit (MIDDLE_CHUNK_MAPPED , &page->private); +clear_bit (MIDDLE_CHUNK_MAPPED , &zpdesc->zppage_flag); zhdr->mapped_count--;put_z3fold_header (zhdr); }
Signature · 1 line
2.43.0
PATCH 14/15 mm/z3fold: introduce __zpdesc_set_movable
In reply to [email protected]From: Alex Shi <[email protected]>
Add a helper __zpdesc_set_movable() for __SetPageMovable(), and use it in callers.
Since we actually use the page.mapping for 'struct movable_operations' pointer, we could add it into zpdesc struct now.
--- mm/z3fold.c | 6 +++--- mm/zpdesc.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-)
mm/z3fold.c +3 -3
@@ -1050,11 +1050,11 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, }if (can_sleep) {zpdesc_lock (zpdesc); -__SetPageMovable (zpdesc_page (zpdesc), &z3fold_mops); +__zpdesc_set_movable (zpdesc, &z3fold_mops);zpdesc_unlock (zpdesc); }else {WARN_ON (!zpdesc_trylock (zpdesc)); -__SetPageMovable (zpdesc_page (zpdesc), &z3fold_mops); +__zpdesc_set_movable (zpdesc, &z3fold_mops);zpdesc_unlock (zpdesc); }z3fold_page_lock (zhdr);
@@ -1334,7 +1334,7 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page,encode_handle (new_zhdr,MIDDLE );set_bit (NEEDS_COMPACTING , &newzpdesc->zppage_flag); new_zhdr->cpu =smp_processor_id (); -__SetPageMovable (zpdesc_page (newzpdesc), &z3fold_mops); +__zpdesc_set_movable (newzpdesc, &z3fold_mops);z3fold_page_unlock (new_zhdr);queue_work_on (new_zhdr->cpu, pool->compact_wq, &new_zhdr->work);
mm/zpdesc.h +6 -0
@@ -73,4 +73,10 @@ static inline void zpdesc_unlock(struct zpdesc *zpdesc)folio_unlock (zpdesc_folio (zpdesc)); } +static inline void __zpdesc_set_movable (struct zpdesc *zpdesc, +const struct movable_operations *mops) +{ +__SetPageMovable (zpdesc_page (zpdesc), mops); +} +#endif
Signature · 1 line
2.43.0
PATCH 15/15 mm/z3fold: introduce __zpdesc_clear_movable
In reply to [email protected]From: Alex Shi <[email protected]>
Add a helper __zpdesc_clear_movable() for __ClearPageMovable(), and use it in callers, that make code clear.
--- mm/z3fold.c | 4 ++-- mm/zpdesc.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
mm/z3fold.c +2 -2
@@ -352,7 +352,7 @@ static void free_z3fold_page(struct zpdesc *zpdesc, bool headless) {if (!headless) {zpdesc_lock (zpdesc); -__ClearPageMovable (zpdesc_page (zpdesc)); +__zpdesc_clear_movable (zpdesc);zpdesc_unlock (zpdesc); }__free_page (zpdesc_page (zpdesc));
@@ -1322,7 +1322,7 @@ static int z3fold_page_migrate(struct page *newpage, struct page *page,* so we only have to reinitialize it. */ INIT_LIST_HEAD (&new_zhdr->buddy); -__ClearPageMovable (zpdesc_page (zpdesc)); +__zpdesc_clear_movable (zpdesc);zpdesc_get (newzpdesc);z3fold_page_lock (new_zhdr);
mm/zpdesc.h +5 -0
@@ -79,4 +79,9 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, __SetPageMovable(zpdesc_page(zpdesc), mops); } +static inline void __zpdesc_clear_movable (struct zpdesc *zpdesc) +{ +__ClearPageMovable (zpdesc_page (zpdesc)); +} +#endif
Signature · 1 line
2.43.0
Quoted 6 lines · On 6/21/24 1:46 PM, [email protected] wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.
BTW,
Thanks for David and Willy's suggestion!
Since all zpool candidates are single page users, then we could use zpdesc to descript them all in future.
Thanks
Quoted 34 lines
For zpdesc(page), z3fold just uses the 5th member
zppage_flag, which match with page.private. Potentially uses the first member flags for headlessPG_locked,list_headlru and page.mapping|PAGE_MAPPING_MOVABLE for page migration.>
This patachset could save 26Kbyetes z3fold.o size, basely saving come from the page to folio conversion.Thanks a lot!
AlexAlex Shi (15):
mm/z3fold: add zpdesc struct and helper and use them in
z3fold_page_isolate
mm/z3fold: use zpdesc inz3fold_page_migratemm/z3fold: use zpdesc inz3fold_page_putbackmm/z3fold: use zpdesc in get/put_z3fold_header funcs mm/z3fold: use zpdesc ininit_z3fold_page
mm/z3fold: use zpdesc infree_z3fold_page
mm/z3fold: convert page to zpdesc in__release_z3fold_pagemm/z3fold: use zpdescfree_pages_work
mm/z3fold: use zpdesc inz3fold_compact_pageanddo_compact_pagemm/z3fold: use zpdesc in__z3fold_alloc
mm/z3fold: use zpdesc inz3fold_alloc
mm/z3fold: use zpdesc infree_z3fold_pageandz3fold_freemm/z3fold: use zpdesc in z3fold_map/z3fold_unmap mm/z3fold: introduce__zpdesc_set_movable
mm/z3fold: introduce__zpdesc_clear_movablemm/z3fold.c | 190 +++++++++++++++++++++++++++------------------------- mm/zpdesc.h | 87 ++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 93 deletions(-) create mode 100644 mm/zpdesc.h
Quoted 7 lines · On Thu, Jun 20, 2024 at 10:42 PM <[email protected]> wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.
Please do not focus your development efforts on z3fold. We really want to deprecate/remove it, as well as zbud eventually. See [1].
For zsmalloc, there is already an ongoing effort to split zsdesc from struct page [2].
[1]https://lore.kernel.org/lkml/CAJD7tkbRF6od-2x_L8-A1QL3=2Ww13sCj4S3i4bNndqF+3+_Vg@mail.gmail.com/
[2]https://lore.kernel.org/lkml/[email protected]/
Quoted 39 lines
For zpdesc(page), z3fold just uses the 5th member
zppage_flag, which match with page.private. Potentially uses the first member flags for headlessPG_locked,list_headlru and page.mapping|PAGE_MAPPING_MOVABLE for page migration.This patachset could save 26Kbyetes z3fold.o size, basely saving come from the page to folio conversion.
Thanks a lot!
AlexAlex Shi (15):
mm/z3fold: add zpdesc struct and helper and use them in
z3fold_page_isolate
mm/z3fold: use zpdesc inz3fold_page_migratemm/z3fold: use zpdesc inz3fold_page_putbackmm/z3fold: use zpdesc in get/put_z3fold_header funcs mm/z3fold: use zpdesc ininit_z3fold_page
mm/z3fold: use zpdesc infree_z3fold_page
mm/z3fold: convert page to zpdesc in__release_z3fold_pagemm/z3fold: use zpdescfree_pages_work
mm/z3fold: use zpdesc inz3fold_compact_pageanddo_compact_pagemm/z3fold: use zpdesc in__z3fold_alloc
mm/z3fold: use zpdesc inz3fold_alloc
mm/z3fold: use zpdesc infree_z3fold_pageandz3fold_freemm/z3fold: use zpdesc in z3fold_map/z3fold_unmap mm/z3fold: introduce__zpdesc_set_movable
mm/z3fold: introduce__zpdesc_clear_movablemm/z3fold.c | 190 +++++++++++++++++++++++++++------------------------- mm/zpdesc.h | 87 ++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 93 deletions(-) create mode 100644 mm/zpdesc.h--
2.43.0
Quoted 16 lines · Yosry Ahmed
Quoted 7 lines · On Thu, Jun 20, 2024 at 10:42 PM <[email protected]> wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/Quoted 7 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.
Quoted 7 lines
Please do not focus your development efforts on z3fold. We really want to deprecate/remove it, as well as zbud eventually. See [1].
For zsmalloc, there is already an ongoing effort to split zsdesc from struct page [2].
[1]https://lore.kernel.org/lkml/CAJD7tkbRF6od-2x_L8-A1QL3=2Ww13sCj4S3i4bNndqF+3+_Vg@mail.gmail.com/
Hi Yosry,
Thanks a lot for the info and comments! It's my stupid w/o checking the email list before work on it. Anyway don't know if z3fold would be removed, jut left this tested patchset here if someone need it.
Quoted 2 lines
David had pointed out this to me few weeks ago too. This patchset hasn't updated nearly a year. If Yoo don't object I'd like to pick up from his left and update it to latest zsmalloc.c.
Thanks
Alex
Quoted 40 lines
Quoted 40 lines
For zpdesc(page), z3fold just uses the 5th member
zppage_flag, which match with page.private. Potentially uses the first member flags for headlessPG_locked,list_headlru and page.mapping|PAGE_MAPPING_MOVABLE for page migration.This patachset could save 26Kbyetes z3fold.o size, basely saving come from the page to folio conversion.
Thanks a lot!
AlexAlex Shi (15):
mm/z3fold: add zpdesc struct and helper and use them in
z3fold_page_isolate
mm/z3fold: use zpdesc inz3fold_page_migratemm/z3fold: use zpdesc inz3fold_page_putbackmm/z3fold: use zpdesc in get/put_z3fold_header funcs mm/z3fold: use zpdesc ininit_z3fold_page
mm/z3fold: use zpdesc infree_z3fold_page
mm/z3fold: convert page to zpdesc in__release_z3fold_pagemm/z3fold: use zpdescfree_pages_work
mm/z3fold: use zpdesc inz3fold_compact_pageanddo_compact_pagemm/z3fold: use zpdesc in__z3fold_alloc
mm/z3fold: use zpdesc inz3fold_alloc
mm/z3fold: use zpdesc infree_z3fold_pageandz3fold_freemm/z3fold: use zpdesc in z3fold_map/z3fold_unmap mm/z3fold: introduce__zpdesc_set_movable
mm/z3fold: introduce__zpdesc_clear_movablemm/z3fold.c | 190 +++++++++++++++++++++++++++------------------------- mm/zpdesc.h | 87 ++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 93 deletions(-) create mode 100644 mm/zpdesc.h--
2.43.0
Quoted 24 lines · Alex Shi
Quoted 8 lines · Yosry Ahmed
Quoted 7 lines · On Thu, Jun 20, 2024 at 10:42 PM <[email protected]> wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/Quoted 5 lines
Quoted 5 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3zpool
Quoted 1 line
Quoted 1 line
usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend
the
Quoted 5 lines
Quoted 1 line
zpdesc to zbud and zsmalloc, combined their usage into one.
For zsmalloc, there is already an ongoing effort to split zsdesc from struct page [2].
Quoted 7 lines
Quoted 1 line
[2]
https://lore.kernel.org/lkml/[email protected]/
David had pointed out this to me few weeks ago too. This patchset hasn't updated nearly a year. If Yoo don't object I'd like to pick up from his left and update it to latest
zsmalloc.c.
Hi Alex and Yosry,
Thank you for mentioning this! I still believe the work is worth pursuing, but recently I haven't had the capacity to push it further.
I'm on board with you taking it over and updating it with the latest source code. If you have any questions while bringing it up to date, don't hesitate please reach out to me.
Quoted 28 lines · Hyeonggon Yoo
On Tue, Jun 25, 2024 at 5:11 PM Alex Shi <[email protected] <mailto:[email protected]>> wrote:
On 6/25/24 5:46 AM, Yosry Ahmed wrote:
> On Thu, Jun 20, 2024 at 10:42 PM <[email protected] <mailto:[email protected]>> wrote:
>>
>> From: Alex Shi <[email protected] <mailto:[email protected]>>
>>
>> According to Metthew's plan, the page descriptor will be replace by a 8
>> bytesmem_descon destination purpose.
>> https://lore.kernel.org/lkml/[email protected]/ <https://lore.kernel.org/lkml/[email protected]/>
>>
>> Here is a implement on z3fold to replace page descriptor by zpdesc,
>> which is still overlay on struct page now. but it's a step move forward
>> above destination.
>>
>> To name the struct zpdesc instead ofz3fold_desc, since there are 3 zpool
>> usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the
>> zpdesc to zbud and zsmalloc, combined their usage into one.
>
> For zsmalloc, there is already an ongoing effort to split zsdesc from
> struct page [2].
>
> [2]https://lore.kernel.org/lkml/[email protected]/ <https://lore.kernel.org/lkml/[email protected]/>
Quoted 8 lines
David had pointed out this to me few weeks ago too. This patchset hasn't updated nearly a year. If Yoo don't object I'd like to pick up from his left and update it to latest
zsmalloc.c.Hi Alex and Yosry,
Thank you for mentioning this! I still believe the work is worth pursuing, but recently I haven't had the capacity to push it further.
I'm on board with you taking it over and updating it with the latest source code. If you have any questions while bringing it up to date, don't hesitate please reach out to me.
Hi Yoo,
Thanks a lot for generous offer! I will update the patchset and send you for review ASAP. :)
Cheers!
Alex
Quoted 26 lines · Alex Shi
Quoted 22 lines · Yosry Ahmed
Quoted 7 lines · On Thu, Jun 20, 2024 at 10:42 PM <[email protected]> wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/Quoted 7 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.Please do not focus your development efforts on z3fold. We really want to deprecate/remove it, as well as zbud eventually. See [1].
For zsmalloc, there is already an ongoing effort to split zsdesc from struct page [2].
Quoted 6 lines
Quoted 1 line
[1]https://lore.kernel.org/lkml/CAJD7tkbRF6od-2x_L8-A1QL3=2Ww13sCj4S3i4bNndqF+3+_Vg@mail.gmail.com/
Hi Yosry,
Thanks a lot for the info and comments! It's my stupid w/o checking the email list before work on it. Anyway don't know if z3fold would be removed, jut left this tested patchset here if someone need it.
It's partially our fault for leaving z3fold knowing that it is headed toward deprecation/removal. FWIW, I tried to remove it or mark it as deprecated, but there was some resistance :/
Quoted 29 lines · Yosry Ahmed
Quoted 28 lines · Alex Shi
Quoted 23 lines · Yosry Ahmed
Quoted 7 lines · On Thu, Jun 20, 2024 at 10:42 PM <[email protected]> wrote:
From: Alex Shi <[email protected]>
According to Metthew's plan, the page descriptor will be replace by a 8 bytes
mem_descon destination purpose.
https://lore.kernel.org/lkml/[email protected]/Quoted 7 lines
Here is a implement on z3fold to replace page descriptor by zpdesc, which is still overlay on struct page now. but it's a step move forward above destination.
To name the struct zpdesc instead of
z3fold_desc, since there are 3 zpool usages under zswap, zbud, z3fold, zsmalloc. It looks like we may extend the zpdesc to zbud and zsmalloc, combined their usage into one.Please do not focus your development efforts on z3fold. We really want to deprecate/remove it, as well as zbud eventually. See [1].
For zsmalloc, there is already an ongoing effort to split zsdesc from struct page [2].
[1]https://lore.kernel.org/lkml/CAJD7tkbRF6od-2x_L8-A1QL3=2Ww13sCj4S3i4bNndqF+3+_Vg@mail.gmail.com/
Quoted 8 lines
Quoted 4 lines
Hi Yosry,
Thanks a lot for the info and comments! It's my stupid w/o checking the email list before work on it. Anyway don't know if z3fold would be removed, jut left this tested patchset here if someone need it.
It's partially our fault for leaving z3fold knowing that it is headed toward deprecation/removal. FWIW, I tried to remove it or mark it as deprecated, but there was some resistance :/
Yes, It happens. Community is too huge. Always someone want sth.
Quoted 10 lines · Yosry Ahmed
Quoted 3 lines · Alex Shi
Thanks a lot for the info and comments! It's my stupid w/o checking the email list before work on it. Anyway don't know if z3fold would be removed, jut left this tested patchset here if someone need it.
It's partially our fault for leaving z3fold knowing that it is headed toward deprecation/removal. FWIW, I tried to remove it or mark it as deprecated, but there was some resistance :/
Our apologies, Alex. Thank you for your contribution regardless!
Regarding zbud and z3fold, this is the second time this conversation has come up within a week or so. Chengming was trying to revert the multiple zpool changes. zsmalloc (after we re-introduce the class locks) does not seem to regress (at least based on benchmarking), but z3fold and zbud suffer. I think we are starting to pay the price of maintaining z3fold and zbud:
1. Future improvement to related subsystems now hurts z3fold. Developers/maintainers have to spend extra mental capacity to consider this, and users could potentially see worse performance if they select z3fold/zbud unknowingly.
2. Contributors are confused on where they should spend their effort on improving.
Can we at least have a roadmap for deprecating these 2? Something along the line of:
1. Deprecate either zbud or z3fold. We do not really need both of them.
2. Make zsmalloc independent of MMU, somehow (IIRC, compaction was one reason right? maybe making zsmalloc compaction dependent on MMU availability?).
3. Deprecate the remaining one - zsmalloc can be used in all deployments now.
4. (Optional) Maybe adding another allocator for the edge cases that zsmalloc does not handle well? I'd need to see numbers to be convinced that this is the case. I think I saw somewhere that Vitaly was working on zblock - look forward to seeing this :)
Quoted 26 lines · Nhat Pham
Quoted 10 lines · Yosry Ahmed
Quoted 3 lines · Alex Shi
Thanks a lot for the info and comments! It's my stupid w/o checking the email list before work on it. Anyway don't know if z3fold would be removed, jut left this tested patchset here if someone need it.
It's partially our fault for leaving z3fold knowing that it is headed toward deprecation/removal. FWIW, I tried to remove it or mark it as deprecated, but there was some resistance :/
Our apologies, Alex. Thank you for your contribution regardless!
Regarding zbud and z3fold, this is the second time this conversation has come up within a week or so. Chengming was trying to revert the multiple zpool changes. zsmalloc (after we re-introduce the class locks) does not seem to regress (at least based on benchmarking), but z3fold and zbud suffer. I think we are starting to pay the price of maintaining z3fold and zbud:
1. Future improvement to related subsystems now hurts z3fold. Developers/maintainers have to spend extra mental capacity to consider this, and users could potentially see worse performance if they select z3fold/zbud unknowingly.
Quoted 5 lines
2. Contributors are confused on where they should spend their effort on improving.
Can we at least have a roadmap for deprecating these 2? Something along the line of:
100% agreed. I think we can start with z3fold given that it doesn't offer significant advantages over zbud in my testing, and zbud is probably more popular since it was the default zpool for a while.
Then we should be able to remove zbud as well after we take care of the MMU dependency in zsmalloc. After that, if no new allocators show up in a while, we can drop the zpool abstraction entirely.
Just my 2c.