zsmalloc: make its pages movable
Subsystems (9)
cover zsmalloc: make its pages movable
As the discussion in the list, the zsmalloc introduce some problems around pages because its pages are unmovable.
These patches introduced page move function to zsmalloc. And they also add interface to struct page.
Hui Zhu (3):
page: add new flags "PG_movable" and add interfaces to control these pages
zsmalloc: mark its page "PG_movable"
zram: make create "__GFP_MOVABLE" pool
drivers/block/zram/zram_drv.c | 4 include/linux/mm_types.h | 11 + include/linux/page-flags.h | 3 mm/compaction.c | 6 mm/debug.c | 1 mm/migrate.c | 17 + mm/vmscan.c | 2 mm/zsmalloc.c | 409 ++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 428 insertions(+), 25 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/3 page: add new flags "PG_movable" and add interfaces to control these pages
This patch add PG_movable to mark a page as movable.
And when system call migrate function, it will call the interfaces isolate, put and migrate to control it.
There is a patch for page migrate interface in LKML. But for zsmalloc, it is too deep inside the file system. So I add another one.
--- include/linux/mm_types.h | 6 ++++++ include/linux/page-flags.h | 3 +++ mm/compaction.c | 6 ++++++ mm/debug.c | 1 + mm/migrate.c | 17 +++++++++++++---- mm/vmscan.c | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-)
include/linux/mm_types.h +6 -0
@@ -12,6 +12,7 @@#include <linux/cpumask.h> #include <linux/uprobes.h> #include <linux/page-flags-layout.h> +#include <linux/migrate_mode.h> #include <asm/page.h> #include <asm/mmu.h>
@@ -196,6 +197,11 @@ struct page {#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid;#endif + +int (*isolate)(struct page *page); +void (*put)(struct page *page); +int (*migrate)(struct page *page,struct page *newpage,int force, +enum migrate_mode mode); }/* * The struct page can be forced to be double word aligned so that atomic ops
include/linux/page-flags.h +3 -0
@@ -113,6 +113,7 @@ enum pageflags { PG_young, PG_idle, #endif + PG_movable,/* MOVABLE */ __NR_PAGEFLAGS,/* Filesystems */
@@ -230,6 +231,8 @@ PAGEFLAG(SwapBacked, swapbacked) __CLEARPAGEFLAG(SwapBacked, swapbacked) __PAGEFLAG(SlobFree, slob_free) +PAGEFLAG (Movable, movable) +/* * Private page markings that may be used by the filesystem that owns the page * for its own purposes.
mm/compaction.c +6 -0
@@ -752,6 +752,12 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,*/ is_lru =PageLRU (page);if (!is_lru) { +if (PageMovable (page)) { +if (page->isolate (page) ==0 ) + goto isolate_success; + +continue ; + }if (unlikely (balloon_page_movable (page))) {if (balloon_page_isolate (page)) {/* Successfully isolated */
mm/debug.c +1 -0
@@ -52,6 +52,7 @@ static const struct trace_print_flags pageflag_names[] = { {1UL << PG_young, "young" }, {1UL << PG_idle, "idle" }, #endif + {1UL << PG_movable, "movable" }, }; static void dump_flags(unsigned long flags,
mm/migrate.c +13 -4
@@ -93,7 +93,9 @@ void putback_movable_pages(struct list_head *l)list_del (&page->lru);dec_zone_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page)); -if (unlikely (isolated_balloon_page (page))) +if (PageMovable (page)) + page->put (page); +else if (unlikely (isolated_balloon_page (page)))balloon_page_putback (page);else putback_lru_page (page);
@@ -953,7 +955,10 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,if (unlikely (split_huge_page (page))) goto out; - rc =__unmap_and_move (page, newpage, force, mode); +if (PageMovable (page)) + rc = page->migrate (page, newpage, force, mode); +else + rc =__unmap_and_move (page, newpage, force, mode); out:if (rc != -EAGAIN ) {
@@ -967,7 +972,9 @@ out:dec_zone_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));/* Soft-offlined page shouldn't go through lru cache list */ -if (reason ==MR_MEMORY_FAILURE ) { +if (PageMovable (page)) + page->put (page); +else if (reason ==MR_MEMORY_FAILURE ) {put_page (page);if (!test_set_page_hwpoison (page))num_poisoned_pages_inc ();
@@ -983,7 +990,9 @@ out:if (rc !=MIGRATEPAGE_SUCCESS && put_new_page) {ClearPageSwapBacked (newpage);put_new_page (newpage, private); - }else if (unlikely (__is_movable_balloon_page (newpage))) { + }else if (PageMovable (newpage)) +put_page (newpage); +else if (unlikely (__is_movable_balloon_page (newpage))) {/* drop our reference, page already in the balloon */ put_page (newpage); }else
mm/vmscan.c +1 -1
@@ -1245,7 +1245,7 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,list_for_each_entry_safe (page, next, page_list, lru) {if (page_is_file_cache (page) && !PageDirty (page) && - !isolated_balloon_page (page)) { + !isolated_balloon_page (page) && !PageMovable (page)) {ClearPageActive (page);list_move (&page->lru, &clean_pages); }
Signature · 7 lines
1.9.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/3] page: add new flags "PG_movable" and add interfaces to control these pages
Quoted 30 lines · Hui Zhu
This patch add
PG_movableto mark a page as movable.
And when system call migrate function, it will call the interfaces isolate, put and migrate to control it.There is a patch for page migrate interface in LKML. But for zsmalloc, it is too deep inside the file system. So I add another one.
Signed-off-by Hui Zhu <[email protected]>--- include/linux/mm_types.h | 6 ++++++ include/linux/page-flags.h | 3 +++ mm/compaction.c | 6 ++++++ mm/debug.c | 1 + mm/migrate.c | 17 +++++++++++++---- mm/vmscan.c | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-)include/linux/mm_types.h +1
-0@@ -12,6 +12,7 @@#include <linux/cpumask.h> #include <linux/uprobes.h> #include <linux/page-flags-layout.h> +#include <linux/migrate_mode.h> #include <asm/page.h> #include <asm/mmu.h>
include/linux/mm_types.h struct page { · line 204
Quoted 8 lines
include/linux/mm_types.h +5
-0@@ -196,6 +197,11 @@ struct page {#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid;#endif + +int (*isolate)(struct page *page); +void (*put)(struct page *page); +int (*migrate)(struct page *page,struct page *newpage,int force, +enum migrate_mode mode);
Three new function pointers in a struct page? No way! Nowadays it has around 64 bytes IIRC and we do quite some crazy stuff to keep it packed. We can't just like this add extra 24 bytes of overhead per 4096 bytes of useful data.
include/linux/page-flags.h enum pageflags { · line 116
Quoted 12 lines
include/linux/mm_types.h +0
-0}/* * The struct page can be forced to be double word aligned so that atomic ops include/linux/page-flags.h +1
-0@@ -113,6 +113,7 @@ enum pageflags { PG_young, PG_idle, #endif + PG_movable, /* MOVABLE */
Page flag space is also a rare resource and we shouldn't add new ones if it's possible to do otherwise - and it should be in this case.
Since Sergey already responded to the cover letter with links to the prior relevant series, I just wanted to point out the biggest reasons why this cannot be accepted technically.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/3] page: add new flags "PG_movable" and add interfaces to control these pages
In reply to Hui ZhuQuoted 30 lines · Hui Zhu
This patch add
PG_movableto mark a page as movable.
And when system call migrate function, it will call the interfaces isolate, put and migrate to control it.There is a patch for page migrate interface in LKML. But for zsmalloc, it is too deep inside the file system. So I add another one.
Signed-off-by Hui Zhu <[email protected]>--- include/linux/mm_types.h | 6 ++++++ include/linux/page-flags.h | 3 +++ mm/compaction.c | 6 ++++++ mm/debug.c | 1 + mm/migrate.c | 17 +++++++++++++---- mm/vmscan.c | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-)include/linux/mm_types.h +1
-0@@ -12,6 +12,7 @@#include <linux/cpumask.h> #include <linux/uprobes.h> #include <linux/page-flags-layout.h> +#include <linux/migrate_mode.h> #include <asm/page.h> #include <asm/mmu.h>
include/linux/mm_types.h struct page { · line 205
Quoted 9 lines
include/linux/mm_types.h +5
-0@@ -196,6 +197,11 @@ struct page {#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid;#endif + +int (*isolate)(struct page *page); +void (*put)(struct page *page); +int (*migrate)(struct page *page,struct page *newpage,int force, +enum migrate_mode mode); }
That's no-go. We are not going to add three pointers to struct page. It would cost ~0.5% of system memory.
NAK.
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/3 zsmalloc: mark its page "PG_movable"
In reply to Hui ZhuThis patch mark zsmalloc's page "PG_movable" and introduce the function for the interfaces zs_isolatepage, zs_isolatepage and zs_migratepage.
--- include/linux/mm_types.h | 5 + mm/zsmalloc.c | 416 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 402 insertions(+), 19 deletions(-)
include/linux/mm_types.h +5 -0
@@ -202,6 +202,11 @@ struct page {void (*put)(struct page *page);int (*migrate)(struct page *page,struct page *newpage,int force,enum migrate_mode mode); + +#ifdef CONFIG_ZSMALLOC +void *zs_class; +struct list_head zs_lru; +#endif }/* * The struct page can be forced to be double word aligned so that atomic ops
mm/zsmalloc.c +397 -19
572 lines not on this page · raw message
Signature · 7 lines
1.9.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/3 zram: make create "__GFP_MOVABLE" pool
In reply to Hui ZhuChange the flags when call zs_create_pool to make zram alloc movable zsmalloc page.
--- drivers/block/zram/zram_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +3 -1
@@ -514,7 +514,9 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) goto out_error; } - meta->mem_pool =zs_create_pool (pool_name,GFP_NOIO | __GFP_HIGHMEM); + meta->mem_pool + =zs_create_pool (pool_name, +GFP_NOIO | __GFP_HIGHMEM | __GFP_MOVABLE);if (!meta->mem_pool) {pr_err ("Error creating memory pool\n" ); goto out_error;
Signature · 7 lines
1.9.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Hui Zhu
As the discussion in the list, the zsmalloc introduce some problems around pages because its pages are unmovable.
These patches introduced page move function to zsmalloc. And they also add interface to struct page.
Hi,
have you seen
http://lkml.iu.edu/hypermail/linux/kernel/1507.0/03233.html
http://lkml.iu.edu/hypermail/linux/kernel/1508.1/00696.html
?
-ss
Quoted 4 lines
Hui Zhu (3):
page: add new flags "PG_movable" and add interfaces to control these pages
zsmalloc: mark its page "PG_movable"
zram: make create "__GFP_MOVABLE" pool
Quoted 10 lines
drivers/block/zram/zram_drv.c | 4 include/linux/mm_types.h | 11 + include/linux/page-flags.h | 3 mm/compaction.c | 6 mm/debug.c | 1 mm/migrate.c | 17 + mm/vmscan.c | 2 mm/zsmalloc.c | 409 ++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 428 insertions(+), 25 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>