zram/zsmalloc promotion
Subsystems (7)
Minchan Kim
maintainerv6 cover zram/zsmalloc promotion
It's 6th trial of zram/zsmalloc promotion.
[patch 5, zram: promote zram from staging] explains why we need zram.
Main reason to block promotion is there was no review of zsmalloc part while Jens already acked zram part.
At that time, zsmalloc was used for zram, zcache and zswap so everybody wanted to make it general and at last, Mel reviewed it.
Most of review was related to zswap dumping mechanism which can pageout compressed page into swap in runtime and zswap gives up using zsmalloc and invented a new wheel, zbud. Other reviews were not major.
http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04334.html
Zcache don't use zsmalloc either so only zsmalloc user is zram now. So I think there is no concern any more.
Patch 1 adds new Kconfig for zram to use page table method instead of copy. Andrew suggested it.
Patch 2 adds lots of commnt for zsmalloc.
Patch 3 moves zsmalloc under driver/staging/zram because zram is only user for zram now.
Patch 4 makes unmap_kernel_range exportable function because zsmalloc have used map_vm_area which is already exported function but zsmalloc need to use unmap_kernel_range and it should be built with module.
Patch 5 moves zram from driver/staging to driver/blocks, finally.
It touches mm, staging, blocks so I am not sure who is right position maintainer so I will Cc Andrw, Jens and Greg.
This patch is based on next-20130813.
Thanks.
Minchan Kim (4):
zsmalloc: add Kconfig for enabling page table method
zsmalloc: move it under zram
mm: export unmap_kernel_range
zram: promote zram from staging
Nitin Cupta (1):
zsmalloc: add more comment
drivers/block/Kconfig | 2 + drivers/block/Makefile | 1 + drivers/block/zram/Kconfig | 37 + drivers/block/zram/Makefile | 3 + drivers/block/zram/zram.txt | 71 ++ drivers/block/zram/zram_drv.c | 987 +++++++++++++++++++++++++++ drivers/block/zram/zsmalloc.c | 1084 ++++++++++++++++++++++++++++++ drivers/staging/Kconfig | 4 - drivers/staging/Makefile | 2 - drivers/staging/zram/Kconfig | 25 - drivers/staging/zram/Makefile | 3 - drivers/staging/zram/zram.txt | 77 --- drivers/staging/zram/zram_drv.c | 984 --------------------------- drivers/staging/zram/zram_drv.h | 125 ---- drivers/staging/zsmalloc/Kconfig | 10 - drivers/staging/zsmalloc/Makefile | 3 - drivers/staging/zsmalloc/zsmalloc-main.c | 1063 ----------------------------- drivers/staging/zsmalloc/zsmalloc.h | 43 -- include/linux/zram.h | 123 ++++ include/linux/zsmalloc.h | 52 ++ mm/vmalloc.c | 1 + 21 files changed, 2361 insertions(+), 2339 deletions(-) create mode 100644 drivers/block/zram/Kconfig create mode 100644 drivers/block/zram/Makefile create mode 100644 drivers/block/zram/zram.txt create mode 100644 drivers/block/zram/zram_drv.c create mode 100644 drivers/block/zram/zsmalloc.c delete mode 100644 drivers/staging/zram/Kconfig delete mode 100644 drivers/staging/zram/Makefile delete mode 100644 drivers/staging/zram/zram.txt delete mode 100644 drivers/staging/zram/zram_drv.c delete mode 100644 drivers/staging/zram/zram_drv.h delete mode 100644 drivers/staging/zsmalloc/Kconfig delete mode 100644 drivers/staging/zsmalloc/Makefile delete mode 100644 drivers/staging/zsmalloc/zsmalloc-main.c delete mode 100644 drivers/staging/zsmalloc/zsmalloc.h create mode 100644 include/linux/zram.h create mode 100644 include/linux/zsmalloc.h
Signature · 7 lines
1.7.9.5 -- 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>
Minchan Kim
maintainerPATCH v6 1/5 zsmalloc: add Kconfig for enabling page table method
Zsmalloc has two methods 1) copy-based and 2) pte based to access objects that span two pages.
You can see history why we supported two approach from [1].
But it was bad choice that adding hard coding to select arch which want to use pte based method because there are lots of SoC in an architecure and they can have different cache size, CPU speed and so on so it would be better to expose it to user as selectable Kconfig option like Andrew Morton suggested.
[1] https://lkml.org/lkml/2012/7/11/58
--- drivers/staging/zsmalloc/Kconfig | 13 +++++++++++++ drivers/staging/zsmalloc/zsmalloc-main.c | 19 ++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/staging/zsmalloc/Kconfig +13 -0
@@ -8,3 +8,16 @@ config ZSMALLOC non-standard allocator interface where a handle, not a pointer, is returned by an alloc(). This handle must be mapped in order to access the allocated space. + +config PGTABLE_MAPPING + bool "Use page table mapping to access object in zsmalloc" + depends on ZSMALLOC + help + By default, zsmalloc uses a copy-based object mapping method to + access allocations that span two pages. However, if a particular + architecture (ex, ARM) performs VM mapping faster than copying, + then you should select this. This causes zsmalloc to use page table + mapping rather than copying for object mapping. + + You can check speed with zsmalloc benchmark[1]. + [1] https://github.com/spartacus06/zsmalloc
drivers/staging/zsmalloc/zsmalloc-main.c +4 -15
@@ -218,19 +218,8 @@ struct zs_pool {#define CLASS_IDX_MASK ((1 << CLASS_IDX_BITS) - 1)#define FULLNESS_MASK ((1 << FULLNESS_BITS) - 1) -/* -* By default, zsmalloc uses a copy-based object mapping method to access -* allocations that span two pages. However, if a particular architecture -* performs VM mapping faster than copying, then it should be added here -* so that USE_PGTABLE_MAPPING is defined. This causes zsmalloc to use -* page table mapping rather than copying for object mapping. -*/ -#if defined(CONFIG_ARM ) && !defined(MODULE ) -#define USE_PGTABLE_MAPPING -#endif -struct mapping_area { -#ifdef USE_PGTABLE_MAPPING +#ifdef CONFIG_PGTABLE_MAPPING struct vm_struct *vm;/* vm area for mapping object that span pages */ #else char *vm_buf;/* copy buffer for objects that span pages */
@@ -622,7 +611,7 @@ static struct page *find_get_zspage(struct size_class *class)return page; } -#ifdef USE_PGTABLE_MAPPING +#ifdef CONFIG_PGTABLE_MAPPING static inline int __zs_cpu_up (struct mapping_area *area) {/*
@@ -660,7 +649,7 @@ static inline void __zs_unmap_object(struct mapping_area *area, unmap_kernel_range(addr, PAGE_SIZE * 2); } -#else /* USE_PGTABLE_MAPPING */ +#else /* CONFIG_PGTABLE_MAPPING */ static inline int __zs_cpu_up (struct mapping_area *area) {
@@ -738,7 +727,7 @@ out: pagefault_enable(); } -#endif /* USE_PGTABLE_MAPPING */ +#endif /* CONFIG_PGTABLE_MAPPING */ static int zs_cpu_notifier (struct notifier_block *nb,unsigned long action,void *pcpu)
Signature · 7 lines
1.7.9.5 -- 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>
Minchan Kim
maintainerPATCH v6 2/5 zsmalloc: add more comment
In reply to Minchan KimFrom: Nitin Cupta <[email protected]>
This patch adds lots of comments and it will help others to review and enhance.
--- drivers/staging/zsmalloc/zsmalloc-main.c | 66 +++++++++++++++++++++++++----- drivers/staging/zsmalloc/zsmalloc.h | 9 +++- 2 files changed, 64 insertions(+), 11 deletions(-)
drivers/staging/zsmalloc/zsmalloc-main.c +56 -10
@@ -10,16 +10,14 @@* Released under the terms of GNU General Public License Version 2.0 */ -/* -* This allocator is designed for use with zcache and zram. Thus, the -* allocator is supposed to work well under low memory conditions. In -* particular, it never attempts higher order page allocation which is -* very likely to fail under memory pressure. On the other hand, if we -* just use single (0-order) pages, it would suffer from very high -* fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy -* an entire page. This was one of the major issues with its predecessor -* (xvmalloc). +* This allocator is designed for use with zram. Thus, the allocator is +* supposed to work well under low memory conditions. In particular, it +* never attempts higher order page allocation which is very likely to +* fail under memory pressure. On the other hand, if we just use single +* (0-order) pages, it would suffer from very high fragmentation -- +* any object of size PAGE_SIZE/2 or larger would occupy an entire page. +* This was one of the major issues with its predecessor (xvmalloc). * * To overcome these issues, zsmalloc allocates a bunch of 0-order pages * and links them together using various 'struct page' fields. These linked
@@ -27,6 +25,21 @@* page boundaries. The code refers to these linked pages as a single entity * called zspage. * +* For simplicity, zsmalloc can only allocate objects of size up to PAGE_SIZE +* since this satisfies the requirements of all its current users (in the +* worst case, page is incompressible and is thus stored "as-is" i.e. in +* uncompressed form). For allocation requests larger than this size, failure +* is returned (see zs_malloc). +* +* Additionally, zs_malloc() does not return a dereferenceable pointer. +* Instead, it returns an opaque handle (unsigned long) which encodes actual +* location of the allocated object. The reason for this indirection is that +* zsmalloc does not keep zspages permanently mapped since that would cause +* issues on 32-bit systems where the VA region for kernel space mappings +* is very small. So, before using the allocating memory, the object has to +* be mapped using zs_map_object() to get a usable pointer and subsequently +* unmapped using zs_unmap_object(). +* * Following is how we use various fields and flags of underlying * struct page(s) to form a zspage. *
@@ -98,7 +111,7 @@/* * Object location (<PFN>, <obj_idx>) is encoded as -* as single (void *) handle value. +* as single (unsigned long) handle value. * * Note that object index <obj_idx> is relative to system * page <PFN> it is stored in, so for each sub-page belonging
@@ -264,6 +277,13 @@ static void set_zspage_mapping(struct page *page, unsigned int class_idx, page->mapping = (struct address_space *)m; } +/* +* zsmalloc divides the pool into various size classes where each +* class maintains a list of zspages where each zspage is divided +* into equal sized chunks. Each allocation falls into one of these +* classes depending on its size. This function returns index of the +* size class which has chunk size big enough to hold the give size. +*/ static int get_size_class_index (int size) {int idx =0 ;
@@ -275,6 +295,13 @@ static int get_size_class_index(int size)return idx; } +/* +* For each size class, zspages are divided into different groups +* depending on how "full" they are. This was done so that we could +* easily find empty or nearly empty zspages when we try to shrink +* the pool (not yet implemented). This function returns fullness +* status of the given page. +*/ static enum fullness_group get_fullness_group (struct page *page) {int inuse, max_objects;
@@ -296,6 +323,12 @@ static enum fullness_group get_fullness_group(struct page *page)return fg; } +/* +* Each size class maintains various freelists and zspages are assigned +* to one of these freelists based on the number of live objects they +* have. This functions inserts the given zspage into the freelist +* identified by <class, fullness_group>. +*/ static void insert_zspage (struct page *page,struct size_class *class,enum fullness_group fullness) {
@@ -313,6 +346,10 @@ static void insert_zspage(struct page *page, struct size_class *class, *head = page; } +/* +* This function removes the given zspage from the freelist identified +* by <class, fullness_group>. +*/ static void remove_zspage (struct page *page,struct size_class *class,enum fullness_group fullness) {
@@ -334,6 +371,15 @@ static void remove_zspage(struct page *page, struct size_class *class,list_del_init (&page->lru); } +/* +* Each size class maintains zspages in different fullness groups depending +* on the number of live objects they contain. When allocating or freeing +* objects, the fullness status of the page can change, say, from ALMOST_FULL +* to ALMOST_EMPTY when freeing an object. This function checks if such +* a status change has occurred for the given page and accordingly moves the +* page from the freelist of the old fullness group to that of the new +* fullness group. +*/ static enum fullness_group fix_fullness_group (struct zs_pool *pool,struct page *page) {
drivers/staging/zsmalloc/zsmalloc.h +8 -1
@@ -18,12 +18,19 @@/* * zsmalloc mapping modes * -* NOTE: These only make a difference when a mapped object spans pages +* NOTE: These only make a difference when a mapped object spans pages. +* They also have no effect when PGTABLE_MAPPING is selected. */ enum zs_mapmode {ZS_MM_RW ,/* normal read-write mapping */ ZS_MM_RO ,/* read-only (no copy-out at unmap time) */ ZS_MM_WO /* write-only (no copy-in at map time) */ +/* +* NOTE: ZS_MM_WO should only be used for initializing new +* (uninitialized) allocations. Partial writes to already +* initialized allocations should use ZS_MM_RW to preserve the +* existing data. +*/ };struct zs_pool ;
Signature · 7 lines
1.7.9.5 -- 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>
Minchan Kim
maintainerPATCH v6 3/5 zsmalloc: move it under zram
In reply to Minchan KimThis patch moves zsmalloc under zram directory because there isn't any other user any more.
Before that, description will explain why we have needed custom allocator.
Zsmalloc is a new slab-based memory allocator for storing compressed pages. It is designed for low fragmentation and high allocation success rate on large object, but <= PAGE_SIZE allocations.
zsmalloc differs from the kernel slab allocator in two primary ways to achieve these design goals.
zsmalloc never requires high order page allocations to back slabs, or "size classes" in zsmalloc terms. Instead it allows multiple single-order pages to be stitched together into a "zspage" which backs the slab. This allows for higher allocation success rate under memory pressure.
Also, zsmalloc allows objects to span page boundaries within the zspage. This allows for lower fragmentation than could be had with the kernel slab allocator for objects between PAGE_SIZE/2 and PAGE_SIZE. With the kernel slab allocator, if a page compresses to 60% of it original size, the memory savings gained through compression is lost in fragmentation because another object of the same size can't be stored in the leftover space.
This ability to span pages results in zsmalloc allocations not being directly addressable by the user. The user is given an non-dereferencable handle in response to an allocation request. That handle must be mapped, using zs_map_object(), which returns a pointer to the mapped region that can be used. The mapping is necessary since the object data may reside in two different noncontigious pages.
The zsmalloc fulfills the allocation needs for zram perfectly and there is no user any more so let's move it into zram/. (I and Nitin already discussed it).
NOTE:
This change prevent to build zram to module because zsmalloc uses unmap_kernel_range which isn't exported so we wanted to export it but it doesn't makse sense because zsmalloc was in staging. Upcoming patch will solve it.
https://lkml.org/lkml/2013/3/26/794
--- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/zram/Kconfig | 17 +- drivers/staging/zram/Makefile | 2 +- drivers/staging/zram/zram_drv.c | 5 + drivers/staging/zram/zram_drv.h | 3 +- drivers/staging/zram/zsmalloc.c | 1084 +++++++++++++++++++++++++++++ drivers/staging/zsmalloc/Kconfig | 23 - drivers/staging/zsmalloc/Makefile | 3 - drivers/staging/zsmalloc/zsmalloc-main.c | 1098 ------------------------------ drivers/staging/zsmalloc/zsmalloc.h | 50 -- include/linux/zsmalloc.h | 52 ++ 12 files changed, 1158 insertions(+), 1182 deletions(-) create mode 100644 drivers/staging/zram/zsmalloc.c delete mode 100644 drivers/staging/zsmalloc/Kconfig delete mode 100644 drivers/staging/zsmalloc/Makefile delete mode 100644 drivers/staging/zsmalloc/zsmalloc-main.c delete mode 100644 drivers/staging/zsmalloc/zsmalloc.h create mode 100644 include/linux/zsmalloc.h
drivers/staging/Kconfig +0 -2
@@ -72,8 +72,6 @@ source "drivers/staging/sep/Kconfig" source "drivers/staging/iio/Kconfig" -source "drivers/staging/zsmalloc/Kconfig" - source "drivers/staging/zram/Kconfig" source "drivers/staging/wlags49_h2/Kconfig"
drivers/staging/Makefile +0 -1
@@ -31,7 +31,6 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_ZRAM) += zram/ -obj-$(CONFIG_ZSMALLOC) += zsmalloc/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
drivers/staging/zram/Kconfig +15 -2
@@ -1,6 +1,6 @@ config ZRAM - tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && ZSMALLOC + bool "Compressed RAM block device support" + depends on BLOCK && SYSFS select LZO_COMPRESS select LZO_DECOMPRESS default n
@@ -23,3 +23,16 @@ config ZRAM_DEBUG help This option adds additional debugging code to the compressed RAM block device driver. + +config PGTABLE_MAPPING + bool "Use page table mapping to access object in zsmalloc" + depends on ZRAM + help + By default, zsmalloc uses a copy-based object mapping method to + access allocations that span two pages. However, if a particular + architecture (ex, ARM) performs VM mapping faster than copying, + then you should select this. This causes zsmalloc to use page table + mapping rather than copying for object mapping. + + You can check speed with zsmalloc benchmark[1]. + [1] https://github.com/spartacus06/zsmalloc
drivers/staging/zram/Makefile +1 -1
@@ -1,3 +1,3 @@ zram-y := zram_drv.o -obj-$(CONFIG_ZRAM) += zram.o +obj-$(CONFIG_ZRAM) += zram.o zsmalloc.o
drivers/staging/zram/zram_drv.c +5 -0
@@ -909,6 +909,10 @@ static int __init zram_init(void) {int ret, dev_id; + ret =zs_init (); +if (ret) +return ret; +if (num_devices > max_num_devices) {pr_warn ("Invalid value for num_devices: %u\n" , num_devices);
@@ -947,6 +951,7 @@ free_devices: unregister:unregister_blkdev (zram_major,"zram" ); out: +zs_exit ();return ret; }
drivers/staging/zram/zram_drv.h +1 -2
@@ -17,8 +17,7 @@#include <linux/spinlock.h> #include <linux/mutex.h> - -#include "../zsmalloc/zsmalloc.h" +#include <linux/zsmalloc.h> /* * Some arbitrary value. This is just to catch
drivers/staging/zram/zsmalloc.c new file +1084 -0
1,084 lines not on this page · raw message
drivers/staging/zsmalloc/Kconfig deleted +0 -23
@@ -1,23 +0,0 @@ -config ZSMALLOC - bool "Memory allocator for compressed pages" - default n - help - zsmalloc is a slab-based memory allocator designed to store - compressed RAM pages. zsmalloc uses virtual memory mapping - in order to reduce fragmentation. However, this results in a - non-standard allocator interface where a handle, not a pointer, is - returned by an alloc(). This handle must be mapped in order to - access the allocated space. - -config PGTABLE_MAPPING - bool "Use page table mapping to access object in zsmalloc" - depends on ZSMALLOC - help - By default, zsmalloc uses a copy-based object mapping method to - access allocations that span two pages. However, if a particular - architecture (ex, ARM) performs VM mapping faster than copying, - then you should select this. This causes zsmalloc to use page table - mapping rather than copying for object mapping. - - You can check speed with zsmalloc benchmark[1]. - [1] https://github.com/spartacus06/zsmalloc
drivers/staging/zsmalloc/Makefile deleted +0 -3
@@ -1,3 +0,0 @@ -zsmalloc-y := zsmalloc-main.o - -obj-$(CONFIG_ZSMALLOC) += zsmalloc.o
drivers/staging/zsmalloc/zsmalloc-main.c deleted +0 -1098
1,098 lines not on this page · raw message
drivers/staging/zsmalloc/zsmalloc.h deleted +0 -50
50 lines not on this page · raw message
include/linux/zsmalloc.h new file +52 -0
52 lines not on this page · raw message
Signature · 7 lines
1.7.9.5 -- 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 v6 3/5] zsmalloc: move it under zram
Quoted 10 lines · Minchan Kim
This patch moves zsmalloc under zram directory because there isn't any other user any more.
Before that, description will explain why we have needed custom allocator.
Zsmalloc is a new slab-based memory allocator for storing compressed pages. It is designed for low fragmentation and high allocation success rate on large object, but <=
PAGE_SIZEallocations.
One things zsmalloc will probably have to address before Andrew deems it worthy is the "memmap peekers" issue. I had to make this change in zbud before Andrew would accept it and this is one of the reasons I have yet to implement zsmalloc support for zswap yet.
Basically, zsmalloc makes the assumption that once the kernel page allocator gives it a page for the pool, zsmalloc can stuff whatever metatdata it wants into the struct page. The problem comes when some parts of the kernel do not obtain the struct page pointer via the allocator but via walking the memmap. Those routines will make certain assumption about the state and structure of the data in the struct page, leading to issues.
My solution for zbud was to move the metadata into the pool pages themselves, using the first block of each page for metadata regarding that page.
Andrew might also have something to say about the placement of zsmalloc.c. IIRC, if it was going to be merged, he wanted it in mm/ if it was going to be messing around in the struct page.
Seth
--
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>
Minchan Kim
maintainerRe: [PATCH v6 3/5] zsmalloc: move it under zram
Hello Seth,
Quoted 17 lines · Seth Jennings
Quoted 10 lines · Minchan Kim
This patch moves zsmalloc under zram directory because there isn't any other user any more.
Before that, description will explain why we have needed custom allocator.
Zsmalloc is a new slab-based memory allocator for storing compressed pages. It is designed for low fragmentation and high allocation success rate on large object, but <=
PAGE_SIZEallocations.One things zsmalloc will probably have to address before Andrew deems it worthy is the "memmap peekers" issue. I had to make this change in zbud before Andrew would accept it and this is one of the reasons I have yet to implement zsmalloc support for zswap yet.
Quoted 7 lines
Basically, zsmalloc makes the assumption that once the kernel page allocator gives it a page for the pool, zsmalloc can stuff whatever metatdata it wants into the struct page. The problem comes when some parts of the kernel do not obtain the struct page pointer via the allocator but via walking the memmap. Those routines will make certain assumption about the state and structure of the data in the struct page, leading to issues.
All of memmap peekers should make such asummption based on pageflag so if zsmalloc don't need touch flag field, it should be no problem.
In addition to that, SLUB allocator already have touched it so why not for zsmalloc?
Quoted 8 lines
My solution for zbud was to move the metadata into the pool pages themselves, using the first block of each page for metadata regarding that page.
Andrew might also have something to say about the placement of
zsmalloc.c. IIRC, if it was going to be merged, he wanted it inmm/if it was going to be messing around in the struct page.
NP.
Thanks for the review, Seth.
Quoted 8 lines
Seth
--
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>
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
Minchan Kim
maintainerPATCH v6 4/5 mm: export unmap_kernel_range
In reply to Minchan KimNow zsmalloc needs exported unmap_kernel_range for building it as module. In detail, here it is.
https://lkml.org/lkml/2013/1/18/487
We didn't send patch to make unmap_kernel_range exportable at that time. Because zram is staging stuff and we didn't think make VM function exportable for staging stuff makes sense so we decided giving up build=m for zsmalloc but zsmalloc moved under zram directory so if we can't build zsmalloc as module, it means we can't build zram as module, either. In addition, another reason we should export it is that buddy map_vm_area is already exported.
--- mm/vmalloc.c | 1 + 1 file changed, 1 insertion(+)
mm/vmalloc.c +1 -0
@@ -1254,6 +1254,7 @@ void unmap_kernel_range(unsigned long addr, unsigned long size)vunmap_page_range (addr, end);flush_tlb_kernel_range (addr, end); } +EXPORT_SYMBOL_GPL (unmap_kernel_range);int map_vm_area (struct vm_struct *area,pgprot_t prot,struct page ***pages) {
Signature · 7 lines
1.7.9.5 -- 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>
Minchan Kim
maintainerPATCH v6 5/5 zram: promote zram from staging
In reply to Minchan KimZram has lived in staging for a LONG LONG time and have been fixed/improved by many contributors so code is clean and stable now. Of course, there are lots of product using zram in real practice.
The major TV companys have used zram as swap since two years ago and recently our production team released android smart phone with zram which is used as swap, too. And there was a report Google released their ChromeOS with zram, too and cyanogenmod have been used zram long time ago. And I heard some disto have used zram block device for tmpfs. In addition, I saw many report from many other peoples. For example, Lubuntu start to use it.
The benefit of zram is very clear. With my experience, one of the benefit was to remove jitter of video application with backgroud memory pressure. It would be effect of efficient memory usage by compression but more issue is whether swap is there or not in the system. Recent mobile platforms have used JAVA so there are many anonymous pages. But embedded system normally are reluctant to use eMMC or SDCard as swap because there is wear-leveling and latency issues so if we do not use swap, it means we can't reclaim anoymous pages and at last, we could encounter OOM kill. :(
Although we have real storage as swap, it was a problem, too. Because it sometime ends up making system very unresponsible caused by slow swap storage performance.
Quote from Luigi on Google
"
Since Chrome OS was mentioned: the main reason why we don't use swap to a disk (rotating or SSD) is because it doesn't degrade gracefully and leads to a bad interactive experience. Generally we prefer to manage RAM at a higher level, by transparently killing and restarting processes. But we noticed that zram is fast enough to be competitive with the latter, and it lets us make more efficient use of the available RAM.
"
and he announced. http://www.spinics.net/lists/linux-mm/msg57717.html
Other uses case is to use zram for block device. Zram is block device so anyone can format the block device and mount on it so some guys on the internet start zram as /var/tmp.
http://forums.gentoo.org/viewtopic-t-838198-start-0.html
It's time to promote it and we should accept more new features because some enhance patches have been pended until zram complete to promote from staging
In addition, block subsystem maintainer Jens already acked it so I guess there is no reason to prevent zram promotion any more and it would be one of good example to prove how staging stuffs evolve.
--- drivers/block/Kconfig | 2 + drivers/block/Makefile | 1 + drivers/block/zram/Kconfig | 37 ++ drivers/block/zram/Makefile | 3 + drivers/block/zram/zram.txt | 71 +++ drivers/block/zram/zram_drv.c | 987 +++++++++++++++++++++++++++++++++++ drivers/block/zram/zsmalloc.c | 1084 +++++++++++++++++++++++++++++++++++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/zram/Kconfig | 38 -- drivers/staging/zram/Makefile | 3 - drivers/staging/zram/zram.txt | 77 --- drivers/staging/zram/zram_drv.c | 989 ----------------------------------- drivers/staging/zram/zram_drv.h | 124 ----- drivers/staging/zram/zsmalloc.c | 1084 --------------------------------------- include/linux/zram.h | 123 +++++ 16 files changed, 2308 insertions(+), 2318 deletions(-) create mode 100644 drivers/block/zram/Kconfig create mode 100644 drivers/block/zram/Makefile create mode 100644 drivers/block/zram/zram.txt create mode 100644 drivers/block/zram/zram_drv.c create mode 100644 drivers/block/zram/zsmalloc.c delete mode 100644 drivers/staging/zram/Kconfig delete mode 100644 drivers/staging/zram/Makefile delete mode 100644 drivers/staging/zram/zram.txt delete mode 100644 drivers/staging/zram/zram_drv.c delete mode 100644 drivers/staging/zram/zram_drv.h delete mode 100644 drivers/staging/zram/zsmalloc.c create mode 100644 include/linux/zram.h
drivers/block/Kconfig +2 -0
@@ -105,6 +105,8 @@ source "drivers/block/paride/Kconfig" source "drivers/block/mtip32xx/Kconfig" +source "drivers/block/zram/Kconfig" + config BLK_CPQ_DA tristate "Compaq SMART2 support" depends on PCI && VIRT_TO_BUS
drivers/block/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_BLK_DEV_UMEM) += umem.o obj-$(CONFIG_BLK_DEV_NBD) += nbd.o obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryptoloop.o obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o +obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_VIODASD) += viodasd.o obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
drivers/block/zram/Kconfig new file +37 -0
@@ -0,0 +1,37 @@ +config ZRAM + tristate "Compressed RAM block device support" + depends on BLOCK && SYSFS + select LZO_COMPRESS + select LZO_DECOMPRESS + default n + help + Creates virtual block devices called /dev/zramX (X = 0, 1, ...). + Pages written to these disks are compressed and stored in memory + itself. These disks allow very fast I/O and compression provides + good amounts of memory savings. + + It has several use cases, for example: /tmp storage, use as swap + disks and maybe many more. + + See zram.txt for more information. + +config ZRAM_DEBUG + bool "Compressed RAM block device debug support" + depends on ZRAM + default n + help + This option adds additional debugging code to the compressed + RAM block device driver. + +config PGTABLE_MAPPING + bool "Use page table mapping to access object in zsmalloc" + depends on ZRAM + help + By default, zsmalloc uses a copy-based object mapping method to + access allocations that span two pages. However, if a particular + architecture (ex, ARM) performs VM mapping faster than copying, + then you should select this. This causes zsmalloc to use page table + mapping rather than copying for object mapping. + + You can check speed with zsmalloc benchmark[1]. + [1] https://github.com/spartacus06/zsmalloc
drivers/block/zram/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_ZRAM) := zram.o + +zram-y := zram_drv.o zsmalloc.o
drivers/block/zram/zram.txt new file +71 -0
71 lines not on this page · raw message
drivers/block/zram/zram_drv.c new file +987 -0
987 lines not on this page · raw message
drivers/block/zram/zsmalloc.c new file +1084 -0
1,084 lines not on this page · raw message
drivers/staging/Kconfig +0 -2
@@ -72,8 +72,6 @@ source "drivers/staging/sep/Kconfig" source "drivers/staging/iio/Kconfig" -source "drivers/staging/zram/Kconfig" - source "drivers/staging/wlags49_h2/Kconfig" source "drivers/staging/wlags49_h25/Kconfig"
drivers/staging/Makefile +0 -1
@@ -30,7 +30,6 @@ obj-$(CONFIG_VT6656) += vt6656/ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ -obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
drivers/staging/zram/Kconfig deleted +0 -38
@@ -1,38 +0,0 @@ -config ZRAM - bool "Compressed RAM block device support" - depends on BLOCK && SYSFS - select LZO_COMPRESS - select LZO_DECOMPRESS - default n - help - Creates virtual block devices called /dev/zramX (X = 0, 1, ...). - Pages written to these disks are compressed and stored in memory - itself. These disks allow very fast I/O and compression provides - good amounts of memory savings. - - It has several use cases, for example: /tmp storage, use as swap - disks and maybe many more. - - See zram.txt for more information. - Project home: <https://compcache.googlecode.com/> - -config ZRAM_DEBUG - bool "Compressed RAM block device debug support" - depends on ZRAM - default n - help - This option adds additional debugging code to the compressed - RAM block device driver. - -config PGTABLE_MAPPING - bool "Use page table mapping to access object in zsmalloc" - depends on ZRAM - help - By default, zsmalloc uses a copy-based object mapping method to - access allocations that span two pages. However, if a particular - architecture (ex, ARM) performs VM mapping faster than copying, - then you should select this. This causes zsmalloc to use page table - mapping rather than copying for object mapping. - - You can check speed with zsmalloc benchmark[1]. - [1] https://github.com/spartacus06/zsmalloc
drivers/staging/zram/Makefile deleted +0 -3
@@ -1,3 +0,0 @@ -zram-y := zram_drv.o - -obj-$(CONFIG_ZRAM) += zram.o zsmalloc.o
drivers/staging/zram/zram.txt deleted +0 -77
77 lines not on this page · raw message
drivers/staging/zram/zram_drv.c deleted +0 -989
670 lines not on this page · raw message
drivers/staging/zram/zram_drv.h deleted +0 -124
124 lines not on this page · raw message
drivers/staging/zram/zsmalloc.c deleted +0 -1084
1,084 lines not on this page · raw message
include/linux/zram.h new file +123 -0
123 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
1.7.9.5 -- 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>
Part of the diff is not shown here. View the raw message.
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for compression factors better than 2:1? I have the impression (maybe wrong) that it does not. In our use of zram (Chrome OS) typical overall compression ratios are between 2.5:1 and 3:1. We would hate to waste that memory if we switch to zswap.
Thanks!
Quoted 85 lines · Minchan Kim
It's 6th trial of zram/zsmalloc promotion.
[patch 5, zram: promote zram from staging] explains why we need zram.Main reason to block promotion is there was no review of zsmalloc part while Jens already acked zram part.
At that time, zsmalloc was used for zram, zcache and zswap so everybody wanted to make it general and at last, Mel reviewed it.
Most of review was related to zswap dumping mechanism which can pageout compressed page into swap in runtime and zswap gives up using zsmalloc and invented a new wheel, zbud. Other reviews were not major.
http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04334.htmlZcache don't use zsmalloc either so only zsmalloc user is zram now. So I think there is no concern any more.
Patch 1 adds new
Kconfigfor zram to use page table method instead of copy. Andrew suggested it.Patch 2 adds lots of commnt for zsmalloc.
Patch 3 moves zsmalloc under driver/staging/zram because zram is only user for zram now.
Patch 4 makes
unmap_kernel_rangeexportable function because zsmalloc have usedmap_vm_areawhich is already exported function but zsmalloc need to useunmap_kernel_rangeand it should be built with module.Patch 5 moves zram from driver/staging to driver/blocks, finally.
It touches mm, staging, blocks so I am not sure who is right position maintainer so I will Cc Andrw, Jens and Greg.
This patch is based on next-20130813.
Thanks.
Minchan Kim (4):
zsmalloc: addKconfigfor enabling page table method
zsmalloc: move it under zram
mm: exportunmap_kernel_range
zram: promote zram from stagingNitin Cupta (1):
zsmalloc: add more commentdrivers/block/Kconfig | 2 + drivers/block/Makefile | 1 + drivers/block/zram/Kconfig | 37 + drivers/block/zram/Makefile | 3 + drivers/block/zram/zram.txt | 71 ++ drivers/block/zram/zram_drv.c | 987 +++++++++++++++++++++++++++ drivers/block/zram/zsmalloc.c | 1084 ++++++++++++++++++++++++++++++ drivers/staging/Kconfig | 4 - drivers/staging/Makefile | 2 - drivers/staging/zram/Kconfig | 25 - drivers/staging/zram/Makefile | 3 - drivers/staging/zram/zram.txt | 77 --- drivers/staging/zram/zram_drv.c | 984 --------------------------- drivers/staging/zram/zram_drv.h | 125 ---- drivers/staging/zsmalloc/Kconfig | 10 - drivers/staging/zsmalloc/Makefile | 3 - drivers/staging/zsmalloc/zsmalloc-main.c | 1063 ----------------------------- drivers/staging/zsmalloc/zsmalloc.h | 43 -- include/linux/zram.h | 123 ++++ include/linux/zsmalloc.h | 52 ++ mm/vmalloc.c | 1 + 21 files changed, 2361 insertions(+), 2339 deletions(-) create mode 100644 drivers/block/zram/Kconfig create mode 100644 drivers/block/zram/Makefile create mode 100644 drivers/block/zram/zram.txt create mode 100644 drivers/block/zram/zram_drv.c create mode 100644 drivers/block/zram/zsmalloc.c delete mode 100644 drivers/staging/zram/Kconfig delete mode 100644 drivers/staging/zram/Makefile delete mode 100644 drivers/staging/zram/zram.txt delete mode 100644 drivers/staging/zram/zram_drv.c delete mode 100644 drivers/staging/zram/zram_drv.h delete mode 100644 drivers/staging/zsmalloc/Kconfig delete mode 100644 drivers/staging/zsmalloc/Makefile delete mode 100644 drivers/staging/zsmalloc/zsmalloc-main.c delete mode 100644 drivers/staging/zsmalloc/zsmalloc.h create mode 100644 include/linux/zram.h create mode 100644 include/linux/zsmalloc.h
Quoted 3 lines
--
1.7.9.5
--
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>
Minchan Kim
maintainerHi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
Quoted 2 lines
compression factors better than 2:1? I have the impression (maybe wrong) that it does not. In our use of zram (Chrome OS) typical
Since zswap changed allocator from zsmalloc to zbud, I didn't follow because I had no interest of low compressoin ratio allocator so I have no idea of status of zswap at a moment but I guess it would be still 2:1.
Quoted 2 lines
overall compression ratios are between 2.5:1 and 3:1. We would hate to waste that memory if we switch to zswap.
If you have real swap storage, zswap might be better although I have no number but real swap is money for embedded system and it has sudden garbage collection on firmware side if we use eMMC or SSD so that it could affect system latency. Morever, if we start to use real swap, maybe we should encrypt the data and it would be severe overhead(CPU and Power).
And what I am considering after promoting for zram feature is asynchronous I/O and it's possible because zram is block device.
Thanks!
Signature · 8 lines
Kind regards, Minchan Kim -- 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 12 lines · Minchan Kim
Hi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
AFAIR, the next step of zswap should be have a modular allocation layer so that users can choose zsmalloc or zbud to use.
Seth?
Signature · 8 lines
Regards, --Bob -- 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 14 lines · Bob Liu
Quoted 12 lines · Minchan Kim
Hi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
Quoted 4 lines
AFAIR, the next step of zswap should be have a modular allocation layer so that users can choose zsmalloc or zbud to use.
Seth?
Yes, that should be doable without too much effort, at least if you disregard writeback. I believe I wrote the code so that you can make the registration of the eviction handler for the allocator NULL, in which case, zswap can just fail the store and fall back to swap. That reintroduces the inverse LRU issue when the pool is full, but in the meantime you potentially get much better effective compression. Then tackle zsmalloc writeback separately.
Seth
--
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>
Hi Minchan,
Quoted 23 lines · Minchan Kim
Hi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
Quoted 2 lines
compression factors better than 2:1? I have the impression (maybe wrong) that it does not. In our use of zram (Chrome OS) typical
Since zswap changed allocator from zsmalloc to zbud, I didn't follow because I had no interest of low compressoin ratio allocator so I have no idea of status of zswap at a moment but I guess it would be still 2:1.
Quoted 2 lines
overall compression ratios are between 2.5:1 and 3:1. We would hate to waste that memory if we switch to zswap.
Quoted 7 lines
If you have real swap storage, zswap might be better although I have no number but real swap is money for embedded system and it has sudden garbage collection on firmware side if we use eMMC or SSD so that it could affect system latency. Morever, if we start to use real swap, maybe we should encrypt the data and it would be severe overhead(CPU and Power).
Why real swap for embedded system need encrypt the data? I think there is no encrypt for data against server and desktop.
Quoted 13 lines
And what I am considering after promoting for zram feature is asynchronous I/O and it's possible because zram is block device.
Thanks!
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
--
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>
Hi Minchan,
Quoted 23 lines · Minchan Kim
Hi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
Quoted 2 lines
compression factors better than 2:1? I have the impression (maybe wrong) that it does not. In our use of zram (Chrome OS) typical
Since zswap changed allocator from zsmalloc to zbud, I didn't follow because I had no interest of low compressoin ratio allocator so I have no idea of status of zswap at a moment but I guess it would be still 2:1.
Quoted 2 lines
overall compression ratios are between 2.5:1 and 3:1. We would hate to waste that memory if we switch to zswap.
Quoted 7 lines
If you have real swap storage, zswap might be better although I have no number but real swap is money for embedded system and it has sudden garbage collection on firmware side if we use eMMC or SSD so that it could affect system latency. Morever, if we start to use real swap, maybe we should encrypt the data and it would be severe overhead(CPU and Power).
Why real swap for embedded system need encrypt the data? I think there is no encrypt for data against server and desktop.
Quoted 13 lines
And what I am considering after promoting for zram feature is asynchronous I/O and it's possible because zram is block device.
Thanks!
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
--
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>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Minchan Kim
maintainerHi,
Quoted 33 lines · Wanpeng Li
Hi Minchan,
Quoted 23 lines · Minchan Kim
Hi Luigi,
Quoted 2 lines · Luigi Semenzato
During earlier discussions of zswap there was a plan to make it work with zsmalloc as an option instead of zbud. Does zbud work for
AFAIR, it was not an optoin but zsmalloc was must but there were several objections because zswap's notable feature is to dump compressed object to real swap storage. For that, zswap needs to store bounded objects in a zpage so that dumping could be bounded, too. Otherwise, it could encounter OOM easily.
Quoted 2 lines
compression factors better than 2:1? I have the impression (maybe wrong) that it does not. In our use of zram (Chrome OS) typical
Since zswap changed allocator from zsmalloc to zbud, I didn't follow because I had no interest of low compressoin ratio allocator so I have no idea of status of zswap at a moment but I guess it would be still 2:1.
Quoted 2 lines
overall compression ratios are between 2.5:1 and 3:1. We would hate to waste that memory if we switch to zswap.
Quoted 7 lines
If you have real swap storage, zswap might be better although I have no number but real swap is money for embedded system and it has sudden garbage collection on firmware side if we use eMMC or SSD so that it could affect system latency. Morever, if we start to use real swap, maybe we should encrypt the data and it would be severe overhead(CPU and Power).
Quoted 2 lines
Why real swap for embedded system need encrypt the data? I think there is no encrypt for data against server and desktop.
I have used some portable device but suddenly, I lost it or was stolen. A hacker can pick it up and read my swap and found my precious information. I don't want it. I guess it's one of reason ChromeOS don't want to use real swap.
https://groups.google.com/a/chromium.org/forum/#!msg/chromium-os-discuss/92Fvi4Ezego/ZvbrC3L2FG4J
Quoted 15 lines
Quoted 14 lines
And what I am considering after promoting for zram feature is asynchronous I/O and it's possible because zram is block device.
Thanks!
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
Signature · 8 lines
Kind regards, Minchan Kim -- 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 19 lines · Minchan Kim
Hi,
Quoted 13 lines · Wanpeng Li
Hi Minchan,
Quoted 10 lines · Minchan Kim
Hi Luigi,
On Wed, Aug 14, 2013 at 08:53:31AM -0700, Luigi Semenzato wrote:
If you have real swap storage, zswap might be better although I have no number but real swap is money for embedded system and it has sudden garbage collection on firmware side if we use eMMC or SSD so that it could affect system latency. Morever, if we start to use real swap, maybe we should encrypt the data and it would be severe overhead(CPU and Power).Quoted 2 lines
Why real swap for embedded system need encrypt the data? I think there is no encrypt for data against server and desktop.
Quoted 6 lines
I have used some portable device but suddenly, I lost it or was stolen. A hacker can pick it up and read my swap and found my precious information. I don't want it. I guess it's one of reason ChromeOS don't want to use real swap.
https://groups.google.com/a/chromium.org/forum/#!msg/chromium-os-discuss/92Fvi4Ezego/ZvbrC3L2FG4J
This is when you use dm-crypt. Also, as noted by others, zswap with a fake backing device that always returns failure (and thus never stores data on disk) should behave like zram without any physical swap.
--
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 6 lines · Minchan Kim
It's 6th trial of zram/zsmalloc promotion.
[patch 5, zram: promote zram from staging] explains why we need zram.Main reason to block promotion is there was no review of zsmalloc part while Jens already acked zram part.
Quoted 7 lines
At that time, zsmalloc was used for zram, zcache and zswap so everybody wanted to make it general and at last, Mel reviewed it.
Most of review was related to zswap dumping mechanism which can pageout compressed page into swap in runtime and zswap gives up using zsmalloc and invented a new wheel, zbud. Other reviews were not major.
http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04334.html
zsmalloc has unpredictable performance characteristics when reclaiming a single page when it was used to back zswap. I felt the unpredictable performance characteristics would make it close to impossible to support for normal server workloads. It would appear to work well until there were massive stalls and I do not think this was ever properly investigated. At one point I would have been happy if zsmalloc could be tuned to store only store 2 compressed pages per physical page but cannot remember why that proposal was never implemented (or if it was and I missed it or forgot). I expected it would change over time but there were no follow-ups that I'm aware of.
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get promoted anyway but personally I think compressed memory continues to be a tragic story.
Signature · 8 lines
Mel Gorman SUSE Labs -- 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 25 lines · Mel Gorman
Quoted 6 lines · Minchan Kim
It's 6th trial of zram/zsmalloc promotion.
[patch 5, zram: promote zram from staging] explains why we need zram.Main reason to block promotion is there was no review of zsmalloc part while Jens already acked zram part.
Quoted 7 lines
At that time, zsmalloc was used for zram, zcache and zswap so everybody wanted to make it general and at last, Mel reviewed it.
Most of review was related to zswap dumping mechanism which can pageout compressed page into swap in runtime and zswap gives up using zsmalloc and invented a new wheel, zbud. Other reviews were not major.
http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04334.htmlzsmalloc has unpredictable performance characteristics when reclaiming a single page when it was used to back zswap. I felt the unpredictable performance characteristics would make it close to impossible to support for normal server workloads. It would appear to work well until there were massive stalls and I do not think this was ever properly investigated. At one point I would have been happy if zsmalloc could be tuned to store only store 2 compressed pages per physical page but cannot remember why that proposal was never implemented (or if it was and I missed it or forgot). I expected it would change over time but there were no follow-ups that I'm aware of.
Quoted 10 lines
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
We are running zram in a large number of laptops (all Chromebooks, which now account for 20 to 25% of all sub-$300 laptops sold in the USA) and haven't seen this problem.
To be fair, we limit the zram disk size to 1.5 x physical RAM (1 x physical RAM on some systems) and Chrome automatically closes tabs (i.e. shuts down processes) before the zram device is full. When processes quit, their swap space is freed and in practice most of it is reclaimed, possibly all of it.
Quoted 9 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Quoted 7 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I do not know why this never happened but guess the zswap people never were interested and the zram people never tried.
Stephen (on the To: list), who is an intern here, is trying that just now.
Quoted 9 lines
Why was the pseudo device
to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get promoted anyway but personally I think compressed memory continues to be a tragic story.
This may be exceedingly negative. I don't doubt that there is tragedy attached to it (is any part of the kernel immune to that?) but we are using compression and it makes a substantial difference to many people, sometimes the difference between a useless and a usable system for their workloads. I would hope that this compensates for the tragedy.
https://groups.google.com/forum/#!topic/chromebook-central/r27r3ZcchhM%5B1-25-false%5D
We currently use zram because it was available in 3.4 and earlier. We understand some of its limitations, so we're now experimenting with zswap. But zram is still perfectly usable in our environment and possibly others, and it's small and seems well isolated, thus it should be relatively easy to maintain.
Quoted 3 lines
--
Mel Gorman
SUSE Labs
--
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>
Minchan Kim
maintainerQuoted 15 lines · Mel Gorman
Quoted 6 lines · Minchan Kim
It's 6th trial of zram/zsmalloc promotion.
[patch 5, zram: promote zram from staging] explains why we need zram.Main reason to block promotion is there was no review of zsmalloc part while Jens already acked zram part.
Quoted 7 lines
At that time, zsmalloc was used for zram, zcache and zswap so everybody wanted to make it general and at last, Mel reviewed it.
Most of review was related to zswap dumping mechanism which can pageout compressed page into swap in runtime and zswap gives up using zsmalloc and invented a new wheel, zbud. Other reviews were not major.
http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04334.html
Quoted 9 lines
zsmalloc has unpredictable performance characteristics when reclaiming a single page when it was used to back zswap. I felt the unpredictable performance characteristics would make it close to impossible to support for normal server workloads. It would appear to work well until there were massive stalls and I do not think this was ever properly investigated. At one point I would have been happy if zsmalloc could be tuned to store only store 2 compressed pages per physical page but cannot remember why that proposal was never implemented (or if it was and I missed it or forgot). I expected it would change over time but there were no follow-ups that I'm aware of.
I remember you said it in LSF/MM and zswap people didn't implement it. I have no idea why they went that way.
Quoted 11 lines
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.
Quoted 9 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.
Quoted 6 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support. I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 3 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.
Quoted 11 lines
a tragic story.
Signature · 8 lines
Mel Gorman SUSE Labs -- 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>
Signature · 8 lines
Kind regards, Minchan Kim -- 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 13 lines · Minchan Kim
Quoted 12 lines
<SNIP>
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Quoted 9 lines
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.
Which zswap could also do if
a) it had a pseudo block device that failed all writes
b) zsmalloc was pluggable
I recognise this sucks because zram is already in the field but if zram is promoted then zram and zswap will continue to diverge further with no reconcilation in sight.
Part of the point of using zswap was that potentially zcache could be implemented on top of it and so all file cache could be stored compressed in memory. AFAIK, it's not possible to do the same thing for zram because of the lack of writeback capabilities. Maybe it could be done if zram could be configured to write to an underlying storage device but it may be very clumsy to configure. I don't know as I never investigated it and to be honest, I'm struggling to remember how I got involved anywhere near zswap/zcache/zram/zwtf in the first place.
Quoted 9 lines
Quoted 8 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Quoted 7 lines
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.
And is zsmalloc was pluggable for zswap then it would also benefit.
Quoted 7 lines
Quoted 5 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Quoted 13 lines
I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Even if it supported zsmalloc I would still wonder why zswap is not using it as a pluggable option :(
Quoted 5 lines
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
I know.
Quoted 5 lines
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.
As this is already used heavily in the field and I am not responsible for maintaining it I am not going to object to it being promoted. I can always push that it be disabled in distribution configs as it is not suitable for general workloads for reason already discussed.
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing to diverge will ultimately bite someone in the ass.
Signature · 8 lines
Mel Gorman SUSE Labs -- 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>
Hi Mel,
Quoted 24 lines · Mel Gorman
Quoted 13 lines · Minchan Kim
Quoted 12 lines
<SNIP>
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Quoted 9 lines
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.
Quoted 5 lines
Which zswap could also do if
a) it had a pseudo block device that failed all writes
b) zsmalloc was pluggable
I'll take a try soon!
Quoted 80 lines
I recognise this sucks because zram is already in the field but if zram is promoted then zram and zswap will continue to diverge further with no reconcilation in sight.
Part of the point of using zswap was that potentially zcache could be implemented on top of it and so all file cache could be stored compressed in memory. AFAIK, it's not possible to do the same thing for zram because of the lack of writeback capabilities. Maybe it could be done if zram could be configured to write to an underlying storage device but it may be very clumsy to configure. I don't know as I never investigated it and to be honest, I'm struggling to remember how I got involved anywhere near zswap/zcache/zram/zwtf in the first place.
Quoted 9 lines
Quoted 8 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Quoted 7 lines
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.And is zsmalloc was pluggable for zswap then it would also benefit.
Quoted 7 lines
Quoted 5 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Quoted 13 lines
I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Even if it supported zsmalloc I would still wonder why zswap is not using it as a pluggable option :(
Quoted 5 lines
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
I know.
Quoted 5 lines
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.
Quoted 8 lines
As this is already used heavily in the field and I am not responsible for maintaining it I am not going to object to it being promoted. I can always push that it be disabled in distribution configs as it is not suitable for general workloads for reason already discussed.
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes
Agree! I prefer this way too!
Quoted 5 lines
zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing to diverge will ultimately bite someone in the ass.
Signature · 8 lines
Regards, -Bob -- 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>
Hi Mel,
Quoted 24 lines · Mel Gorman
Quoted 13 lines · Minchan Kim
Quoted 12 lines
<SNIP>
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Quoted 9 lines
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.
Quoted 5 lines
Which zswap could also do if
a) it had a pseudo block device that failed all writes
b) zsmalloc was pluggable
I'll take a try soon!
Quoted 85 lines
I recognise this sucks because zram is already in the field but if zram is promoted then zram and zswap will continue to diverge further with no reconcilation in sight.
Part of the point of using zswap was that potentially zcache could be implemented on top of it and so all file cache could be stored compressed in memory. AFAIK, it's not possible to do the same thing for zram because of the lack of writeback capabilities. Maybe it could be done if zram could be configured to write to an underlying storage device but it may be very clumsy to configure. I don't know as I never investigated it and to be honest, I'm struggling to remember how I got involved anywhere near zswap/zcache/zram/zwtf in the first place.
Quoted 9 lines
Quoted 8 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Quoted 7 lines
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.And is zsmalloc was pluggable for zswap then it would also benefit.
Quoted 7 lines
Quoted 5 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Quoted 13 lines
I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Even if it supported zsmalloc I would still wonder why zswap is not using it as a pluggable option :(
Quoted 5 lines
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
I know.
Quoted 5 lines
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.As this is already used heavily in the field and I am not responsible for maintaining it I am not going to object to it being promoted. I can always push that it be disabled in distribution configs as it is not suitable for general workloads for reason already discussed.
Quoted 4 lines
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why
Agree! I prefer this way too!
Quoted 4 lines
that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing to diverge will ultimately bite someone in the ass.
Signature · 8 lines
Regards, -Bob -- 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>
Minchan Kim
maintainerHi Mel,
Quoted 59 lines · Mel Gorman
Quoted 13 lines · Minchan Kim
Quoted 12 lines
<SNIP>
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Quoted 9 lines
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.Which zswap could also do if
a) it had a pseudo block device that failed all writes
b) zsmalloc was pluggableI recognise this sucks because zram is already in the field but if zram is promoted then zram and zswap will continue to diverge further with no reconcilation in sight.
Part of the point of using zswap was that potentially zcache could be implemented on top of it and so all file cache could be stored compressed in memory. AFAIK, it's not possible to do the same thing for zram because of the lack of writeback capabilities. Maybe it could be done if zram could be configured to write to an underlying storage device but it may be very clumsy to configure. I don't know as I never investigated it and to be honest, I'm struggling to remember how I got involved anywhere near zswap/zcache/zram/zwtf in the first place.
Quoted 9 lines
Quoted 8 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Quoted 7 lines
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device. Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Compression. It was really bottlneck point. I had an internal patch which can make zram use various compressor, not only LZO.
The better good compressor was, the more bottlenck compressor was.
Quoted 43 lines
Quoted 14 lines
I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Even if it supported zsmalloc I would still wonder why zswap is not using it as a pluggable option :(
Quoted 5 lines
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
I know.
Quoted 5 lines
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.As this is already used heavily in the field and I am not responsible for maintaining it I am not going to object to it being promoted. I can always push that it be disabled in distribution configs as it is not suitable for general workloads for reason already discussed.
Quoted 6 lines
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing
Then, do you think current zswap's writeback is sane way?
I didn't raise an issue because I didn't want to be a blocker when zswap was promoted. Actually, I didn't like that way because I thought swap-writeback feature should be implemented by VM itself rather than some hooked driver internal logic. VM alreay has a lot information so it would handle multipe heterogenous swap more efficenlty like cache hierachy without LRU inversing. It could solve current zswap LRU inversing problem generally and help others who want to configure multiple swap system as well as zram.
Quoted 1 line
to diverge will ultimately bite someone in the ass.
Mel, current zram situation is following as.
1) There are a lot users in the world.
2) So, many valuable contributions have been in there.
2) The new feature development of zram had stalled because Greg asserted he doesn't accept new feature until promote will be done and recently, he said he will remove zram in staging if anybody doesn't try to promote
3) You are saying zram shouldn't be promote. IOW, zram should go away.
Right? Then, What should we zram developers do?
What's next step for zram which is really perfect for embedded system? We should really lose a chance to enhance zram although fresh zswap couldn't replace old zram?
Mel, please consider embedded world although they are very little voice in this core subsystem.
Quoted 5 lines
Signature · 3 lines
-- Mel Gorman SUSE Labs
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
Hi Minchan,
Quoted 62 lines · Minchan Kim
Hi Mel,
Quoted 59 lines · Mel Gorman
Quoted 13 lines · Minchan Kim
Quoted 12 lines
<SNIP>
I do not believe this is a problem for zram as such because I do not think it ever writes back to disk and is immune from the unpredictable performance characteristics problem. The problem for zram using zsmalloc is OOM killing. If it's used for swap then there is no guarantee that killing processes frees memory and that could result in an OOM storm. Of course there is no guarantee that memory is freed with zbud either but you are guaranteed that freeing 50%+1 of the compressed pages will free a single physical page. The characteristics for zsmalloc are much more severe. This might be managable in an applicance with very careful control of the applications that are running but not for general servers or desktops.
Quoted 9 lines
Fair enough but let's think of current usecase for zram.
As I said in description, most of user for zram are embedded products. So, most of them has no swap storage and hate OOM kill because OOM is already very very slow path so system slow response is really thing we want to avoid. We prefer early process kill to slow response. That's why custom low memory killer/notifier is popular in embedded side. so actually, OOM storm problem shouldn't be a big problem under well-control limited system.Which zswap could also do if
a) it had a pseudo block device that failed all writes
b) zsmalloc was pluggableI recognise this sucks because zram is already in the field but if zram is promoted then zram and zswap will continue to diverge further with no reconcilation in sight.
Part of the point of using zswap was that potentially zcache could be implemented on top of it and so all file cache could be stored compressed in memory. AFAIK, it's not possible to do the same thing for zram because of the lack of writeback capabilities. Maybe it could be done if zram could be configured to write to an underlying storage device but it may be very clumsy to configure. I don't know as I never investigated it and to be honest, I'm struggling to remember how I got involved anywhere near zswap/zcache/zram/zwtf in the first place.
Quoted 16 lines
Quoted 8 lines
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.
Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.
Quoted 5 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device. Let say one usecase for using zram-blk.
But maybe we can make zswap creating some pseudo block devices. All data will be stored in zswap memory pool instead of real device.
If zswap pool gets full, refuse to accept any new pages(no wirte back will happen).
That's all the same as zram.
In this case, zswap can be used to replace zram!
Quoted 89 lines
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Compression. It was really bottlneck point. I had an internal patch which can make zram use various compressor, not only LZO.
The better good compressor was, the more bottlenck compressor was.Quoted 43 lines
Quoted 14 lines
I guess frontswap is synchronous by semantic while zram could support asynchronous I/O.
Quoted 5 lines
do not know why this never happened but guess the zswap people never were interested and the zram people never tried. Why was the pseudo device to avoid writebacks never implemented? Why was the underlying allocator not made pluggable to optionally use zsmalloc when the user did not care that it had terrible writeback characteristics?
I remember you suggested to make zsmalloc with pluggable for zswap. But I don't know why zswap people didn't implement it.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
zswap cannot replicate zram+tmpfs but I also think that such a configuration is a bad idea anyway. As zram is already being deployed then it might get
It seems your big concern of zsmalloc is fragmentaion so if zsmalloc can support compaction, it would mitigate the concern.
Even if it supported zsmalloc I would still wonder why zswap is not using it as a pluggable option :(
Quoted 5 lines
Quoted 1 line
promoted anyway but personally I think compressed memory continues to be
I admit zram might have limitations but it has helped lots of people. It's not an imaginary scenario.
I know.
Quoted 5 lines
Please, let's not do get out of zram from kernel tree and stall it on staging forever with preventing new features.
Please, let's promote, expose it to more potential users, receive more complains from them, recruit more contributors and let's enhance.As this is already used heavily in the field and I am not responsible for maintaining it I am not going to object to it being promoted. I can always push that it be disabled in distribution configs as it is not suitable for general workloads for reason already discussed.
Quoted 6 lines
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing
Then, do you think current zswap's writeback is sane way?
I didn't raise an issue because I didn't want to be a blocker when zswap was promoted. Actually, I didn't like that way because I thought swap-writeback feature should be implemented by VM itself rather than some hooked driver internal logic. VM alreay has a lot information so it would handle multipe heterogenous swap more efficenlty like cache hierachy without LRU inversing. It could solve current zswap LRU inversing problem generally and help others who want to configure multiple swap system as well as zram.Quoted 1 line
to diverge will ultimately bite someone in the ass.
Mel, current zram situation is following as.
Quoted 8 lines
1) There are a lot users in the world.
2) So, many valuable contributions have been in there.
2) The new feature development of zram had stalled because Greg asserted he doesn't accept new feature until promote will be done and recently, he said he will remove zram in staging if anybody doesn't try to promote
3) You are saying zram shouldn't be promote. IOW, zram should go away.Right? Then, What should we zram developers do?
In my opinion we can do:
1) promote zsmalloc to mm/
2) making zswap can support zsmalloc
3) making zswap can create some fake block device and emulate the same action of zram
like don't write back.
Quoted 7 lines
What's next step for zram which is really perfect for embedded system? We should really lose a chance to enhance zram although fresh zswap couldn't replace old zram?
Mel, please consider embedded world although they are very little voice in this core subsystem.
Signature · 8 lines
Regards, --Bob -- 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 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.
Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a zbud_ops that does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?
mm/zswap.c +0 -1
@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Quoted 6 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Compression. It was really bottlneck point. I had an internal patch which can make zram use various compressor, not only LZO.
The better good compressor was, the more bottlenck compressor was.
There are two issues there. One that different compression algorithms should be optional with tradeoffs on speed vs compression ratio. There is no reason why that couldn't be hacked into zswap.
The second is that only one page can be compressed at a time. That would require further work to allow the frontswap API to asynchronously compress pages. It would be a lot more heavy lifting but it is not impossible.
Quoted 8 lines
Quoted 6 lines
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing
Then, do you think current zswap's writeback is sane way?
No, it's clunky as hell and the layering between zswap and zbud is twisty (e.g. zswap store -> zbud reclaim -> zswap writeback wtf?). I believe it used to be a lot worse but was ironed out a bit in preparation for merging. As bad as it is, general workloads cannot just consume unreclaimable pages with compressed data and writeback should be optionally handled at the very least.
How zswap currently implements it could be a whole lot better. It's silly that it is the allocator the directly performs synchronous writeback one page at a time because that will means the world stalls when zswap fills. On larger machines that is just going to be brick wall and considering that zswap was intended for virtualisation it is particularly hilarious. I think I brought up its stalling behaviour during review when it was being merged. It would have been preferable if writeback could be initiated in batches and then waited on at the very least. It's worse that it uses _swap_writepage directly instead of going through a writepage ops. It would have been better if zbud pages existed on the LRU and written back with an address space ops and properly handled asynchonous writeback.
Zswap could be massively improved, there is no denying that. I've seen no follow-up patches since which is a bit worrying but I'm not losing sleep over it.
Zram does not even try to do anything like this and from your description of the embedded use case there is no intention of ever trying.
Quoted 4 lines
I didn't raise an issue because I didn't want to be a blocker when zswap was promoted. Actually, I didn't like that way because I thought swap-writeback feature should be implemented by VM itself rather than some hooked driver internal logic.
You could also have brought it up any time since or pushed for it to be implemented with the view to making zswap functionally equivalent to zram.
Quoted 9 lines
VM alreay has a lot information so it would handle multipe heterogenous swap more efficenlty like cache hierachy without LRU inversing. It could solve current zswap LRU inversing problem generally and help others who want to configure multiple swap system as well as zram.
Quoted 1 line
to diverge will ultimately bite someone in the ass.
Mel, current zram situation is following as.
Quoted 8 lines
1) There are a lot users in the world.
2) So, many valuable contributions have been in there.
2) The new feature development of zram had stalled because Greg asserted he doesn't accept new feature until promote will be done and recently, he said he will remove zram in staging if anybody doesn't try to promote
3) You are saying zram shouldn't be promote. IOW, zram should go away.Right? Then, What should we zram developers do?
I've already explained, more than once going at least as far back as April, how I thought zswap could be made functionally identical to zram and improved.
Quoted 7 lines
What's next step for zram which is really perfect for embedded system? We should really lose a chance to enhance zram although fresh zswap couldn't replace old zram?
Mel, please consider embedded world although they are very little voice in this core subsystem.
I already said I recognise it has a large number of users in the field and users count a lot more than me complaining. If it gets promoted then I expect it will be on those grounds.
My position is that I think it's a bad idea because it is clear there is no plan or intention of ever brining zram and zswap together. Instead we are to have two features providing similar functionality with zram diverging further from zswap. Ultimately I believe this will increase maintenance headaches. It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try. I will not be acking this series but there many be enough developers that are actually willing to maintain a duel zram/zswap mess to make it happen anyway.
Signature · 8 lines
Mel Gorman SUSE Labs -- 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 5 lines · Mel Gorman
On Fri, Aug 16, 2013 at 01:26:41PM +0900, Minchan Kim wrote:
<SNIP>
It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try.
I should mention that Bob Liu did some work with zcache recently but is now looking like it'll be dropped from staging. I did not look at the details and I have no idea if anything else is planned with it.
Signature · 8 lines
Mel Gorman SUSE Labs -- 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>
Hi Mel,
Quoted 11 lines · Mel Gorman
Quoted 5 lines · Mel Gorman
On Fri, Aug 16, 2013 at 01:26:41PM +0900, Minchan Kim wrote:
<SNIP>
It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try.I should mention that Bob Liu did some work with zcache recently but is now looking like it'll be dropped from staging. I did not look at the details and I have no idea if anything else is planned with it.
The plan is like this:
Zcache dropped from staging.
As a result, for swap pages compression using zswap(zram). For file pages compression using my new implemention of zcache(v3) mm/zcache.c
If there is requirement we can merge zswap and zcachev3 in future!
Signature · 8 lines
Regards, -Bob -- 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>
Greg Kroah-Hartman
maintainerQuoted 10 lines · Bob Liu
Hi Mel,
Quoted 7 lines · Mel Gorman
Quoted 5 lines · Mel Gorman
On Fri, Aug 16, 2013 at 01:26:41PM +0900, Minchan Kim wrote:
<SNIP>
It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try.
Quoted 7 lines
Quoted 4 lines
I should mention that Bob Liu did some work with zcache recently but is now looking like it'll be dropped from staging. I did not look at the details and I have no idea if anything else is planned with it.
The plan is like this:
Zcache dropped from staging.
It's already gone in linux-next and will show up as deleted in 3.12-rc1.
greg k-h
--
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>
Hi Mel,
Quoted 5 lines · Mel Gorman
I already said I recognise it has a large number of users in the field and users count a lot more than me complaining. If it gets promoted then I expect it will be on those grounds.
Quoted 7 lines
My position is that I think it's a bad idea because it is clear there is no plan or intention of ever brining zram and zswap together. Instead we are to have two features providing similar functionality with zram diverging further from zswap. Ultimately I believe this will increase maintenance headaches. It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try. I will not be acking this series but there many be enough
I already reimplemented zcache based on mm/zbud.c.
http://thread.gmane.org/gmane.linux.kernel.mm/104824
I'll pay more attention to the problems of zswap as you mentioned.
Quoted 3 lines
developers that are actually willing to maintain a duel zram/zswap mess to make it happen anyway.
Signature · 8 lines
Regards, -Bob -- 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>
Minchan Kim
maintainerHello Mel,
Quoted 42 lines · Mel Gorman
Quoted 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a
zbud_opsthat does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?mm/zswap.c +0
-1@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)
Quoted 4 lines
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Never. Because I didn't have such requirement for zram.
Quoted 18 lines
Quoted 7 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 2 lines
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
You mean "make pseudo block device and register make_request_fn
and prevent writeback". Bah, yes, it's doable but what is it different with below?
1) move zbud into zram
2) implement frontswap API in zram
3) implement writebazk in zram
The zram has been for a long time in staging to be promoted and have been maintained/deployed. Of course, I have asked the promotion several times for above a year.
Why can't zram include zswap functions if you really want to merge them? Is there any problem?
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
These are the sort of reason why I feel that zram has limited cases where it is safe to use and zswap has a wider range of applications. At least I would be very unhappy to try supporting zram in the field for normal servers. zswap should be able to replace the functionality of zram+swap by backing zswap with a pseudo block device that rejects all writes. I
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
One of difference between zswap and zram is asynchronous I/O support.
As zram is not writing to disk, how compelling is asynchronous IO? If zswap was backed by the pseudo device is there a measurable bottleneck?
Compression. It was really bottlneck point. I had an internal patch which can make zram use various compressor, not only LZO.
The better good compressor was, the more bottlenck compressor was.
Quoted 7 lines
There are two issues there. One that different compression algorithms should be optional with tradeoffs on speed vs compression ratio. There is no reason why that couldn't be hacked into zswap.
The second is that only one page can be compressed at a time. That would require further work to allow the frontswap API to asynchronously compress pages. It would be a lot more heavy lifting but it is not impossible.
You're saying zswap can do everything to replace zram and I can say that zram also can do everything to replace zswap, too and I'd like to say zram would be better than zswap about writeback.
Current zswap writeback has a few issues.
First of all, why should writeback happen zswap layer as I said earlier? What if someone try to configue swap layer hierachy with fast and slow devices among in-memory, SSD, eMMC, harddisk, network storage?
In this case, priority-based round-robin method of swap layer isn't good model for caching hierachy. It would be better to handle it in swap layer generally. It's not an only zswap specific problem. If we solve it in swap layer, zram would be enough.
Another disadvntage is that zswap is decompressing a page right before writeback. and write one-by-one page. But zram can implement writing out it with zpage unit, batching, sequentially if it has indirect layer to handle V2P layer which could translate virtual swapoff to physical swapoff because physical swapoff could be allocated right before write happening. In addtion to that, V2P layer can support zpage compaction for mitigating the fragementation problem of zsmalloc.
Quoted 28 lines
Quoted 9 lines
Quoted 7 lines
However, I believe that the promotion will lead to zram and zswap diverging further from each other, both implementing similar functionality and ultimately cause greater maintenance headaches. There is a path that makes zswap a functional replacement for zram and I've seen no good reason why that path was not taken. Zram cannot be a functional replacment for zswap as there is no obvious sane way writeback could be implemented. Continuing
Then, do you think current zswap's writeback is sane way?
No, it's clunky as hell and the layering between zswap and zbud is twisty (e.g. zswap store -> zbud reclaim -> zswap writeback wtf?). I believe it used to be a lot worse but was ironed out a bit in preparation for merging. As bad as it is, general workloads cannot just consume unreclaimable pages with compressed data and writeback should be optionally handled at the very least.
How zswap currently implements it could be a whole lot better. It's silly that it is the allocator the directly performs synchronous writeback one page at a time because that will means the world stalls when zswap fills. On larger machines that is just going to be brick wall and considering that zswap was intended for virtualisation it is particularly hilarious. I think I brought up its stalling behaviour during review when it was being merged. It would have been preferable if writeback could be initiated in batches and then waited on at the very least. It's worse that it uses
_swap_writepagedirectly instead of going through a writepage ops. It would have been better if zbud pages existed on the LRU and written back with an address space ops and properly handled asynchonous writeback.
Quoted 6 lines
Zswap could be massively improved, there is no denying that. I've seen no follow-up patches since which is a bit worrying but I'm not losing sleep over it.
Zram does not even try to do anything like this and from your description of the embedded use case there is no intention of ever trying.
Yes. Because there was no such requirement for zram but it could be doable and even better as I said. And another reason I didn't try is zswap had a plan to support writeback and We(I, Seth, Dan) didn't thought zswap will replace zram. That's why I helped zswap merging.
Okay, you might disagree all points I said above and insist on that zswap must include zram functionality and discard zram.
If everybody really want to unify zram and zswap, I can do it but I think it should be based on zram. As I said, zram can support frontswap and writeback via borrowing all code from zswap/zbud so that zram doesn't break anything and it's more flexible.
1) zram-blk
2) zram-swap with block device, which can be enhanced for writeback batch, sequential without decompressing.
3) zswap with frontswap.
4) If VM start to consider multiple swap-cache hierachy, we can remove 3.
Why do you want to replace old-stable/has-many-users/well-maintained feature with new-fresh thing? It is never reasonable to me.
Quoted 9 lines
Quoted 5 lines
I didn't raise an issue because I didn't want to be a blocker when zswap was promoted. Actually, I didn't like that way because I thought swap-writeback feature should be implemented by VM itself rather than some hooked driver internal logic.
You could also have brought it up any time since or pushed for it to be implemented with the view to making zswap functionally equivalent to zram.
Then, Are you okay if I resend zram promotion patches with adding frontswap stuff to replace zswap? I don't want it but if everybody want, I will do.
Quoted 35 lines
Quoted 10 lines
VM alreay has a lot information so it would handle multipe heterogenous swap more efficenlty like cache hierachy without LRU inversing. It could solve current zswap LRU inversing problem generally and help others who want to configure multiple swap system as well as zram.
Quoted 1 line
to diverge will ultimately bite someone in the ass.
Mel, current zram situation is following as.
Quoted 8 lines
1) There are a lot users in the world.
2) So, many valuable contributions have been in there.
2) The new feature development of zram had stalled because Greg asserted he doesn't accept new feature until promote will be done and recently, he said he will remove zram in staging if anybody doesn't try to promote
3) You are saying zram shouldn't be promote. IOW, zram should go away.Right? Then, What should we zram developers do?
I've already explained, more than once going at least as far back as April, how I thought zswap could be made functionally identical to zram and improved.
Quoted 7 lines
What's next step for zram which is really perfect for embedded system? We should really lose a chance to enhance zram although fresh zswap couldn't replace old zram?
Mel, please consider embedded world although they are very little voice in this core subsystem.
I already said I recognise it has a large number of users in the field and users count a lot more than me complaining. If it gets promoted then I expect it will be on those grounds.
Quoted 9 lines
My position is that I think it's a bad idea because it is clear there is no plan or intention of ever brining zram and zswap together. Instead we are to have two features providing similar functionality with zram diverging further from zswap. Ultimately I believe this will increase maintenance headaches. It'll get even more entertaining if/when someone ever tries to reimplement zcache although since Dan left I do not believe anyone is planning to try. I will not be acking this series but there many be enough developers that are actually willing to maintain a duel zram/zswap mess to make it happen anyway.
Okay, My position is following as.
1) I'd like to stick compressed block device because writeback should be hanled in VM layer rather than zswap layer to solve common problem in general.
2) If you disagree with that and want to unify zswap and zram,
I'd like to based on zram so that zram can implement frontswap API and writeback through borrowing from zswap. Because zram has long history/stable/many contributors/many users compared to zswap.
If 1) works sometime in future, we can remove zswap internal writeback totally. If 1) don't work, we can enhance writeback more efficiently like I mentioned without frontswap.
I admit it should be done before zswap is merged but as I already said at that time, we(I, Seth, Dan) never thought zswap could replace zram totally. But I think it's not too late.
3) I admit zswap can implement pusedo block device through borrowing many code from zram so that it can support zram without breaking. But it might lose our git history which is one of valuable from getting staging.
Andrew, please put your opinion and decision.
Signature · 8 lines
Kind regards, Minchan Kim -- 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>
Hi Minchan,
Quoted 80 lines · Minchan Kim
Hello Mel,
Quoted 42 lines · Mel Gorman
Quoted 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a
zbud_opsthat does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?mm/zswap.c +0
-1@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)Quoted 4 lines
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Never. Because I didn't have such requirement for zram.
Quoted 18 lines
Quoted 7 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 2 lines
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
You mean "make pseudo block device and register
make_request_fn
and prevent writeback". Bah, yes, it's doable but what is it different with below?1) move zbud into zram
2) implement frontswap API in zram
3) implement writebazk in zram
Quoted 6 lines
The zram has been for a long time in staging to be promoted and have been maintained/deployed. Of course, I have asked the promotion several times for above a year.
Why can't zram include zswap functions if you really want to merge them? Is there any problem?
I think merging zram into zswap or merging zswap into zram are the same thing. It's no difference.
Both way will result in a solution finally with zram block device, frontswap API etc.
The difference is just the name and the merging patch title, I think it's unimportant.
I've implemented a series [PATCH 0/4] mm: merge zram into zswap, I can change the tile to "merge zswap into zram" if you want and rename zswap to something like zhybrid.
Signature · 8 lines
Regards, -Bob -- 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>
Minchan Kim
maintainerHello Bob,
Sorry for the late response. I was on holiday.
Quoted 87 lines · Bob Liu
Hi Minchan,
Quoted 84 lines · Minchan Kim
Hello Mel,
Quoted 42 lines · Mel Gorman
Quoted 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a
zbud_opsthat does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?mm/zswap.c +0
-1@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)Quoted 4 lines
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Never. Because I didn't have such requirement for zram.
Quoted 18 lines
Quoted 7 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 2 lines
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
You mean "make pseudo block device and register
make_request_fn
and prevent writeback". Bah, yes, it's doable but what is it different with below?1) move zbud into zram
2) implement frontswap API in zram
3) implement writebazk in zramThe zram has been for a long time in staging to be promoted and have been maintained/deployed. Of course, I have asked the promotion several times for above a year.
Quoted 5 lines
Quoted 2 lines
Why can't zram include zswap functions if you really want to merge them? Is there any problem?
I think merging zram into zswap or merging zswap into zram are the same thing. It's no difference.
True but i'd like to merge zswap code into zram.
Because as you know, zram has already lots of users while zswap is almost new young so I'd like to keep backward compatibility for zram so moving zswap code into zram is more handy and could keep the git log as well.
Quoted 2 lines
Both way will result in a solution finally with zram block device, frontswap API etc.
Right but z* family people should discuss that zswap-writeback is really good solution for compressed swap. Firstly, I thought zswap is differnt with zram so there is no issue to promote zram so I and Nitin helped zsmalloc promotion for Seth and have reviewed at zswap inital phases but the situation is chainging. Let's discussion further points about compresssed swap solution. I raised issues as reply of Mel in my thread. Let's think of it.
Quoted 3 lines
The difference is just the name and the merging patch title, I think it's unimportant.
If we decide merging them, yes, module name would be important and we can't ignore copyright and maintainer part, either. Anyway,
I'd like to go that way as last resort afther enough thinking which can justify frontswap-based swap writeback is right approach.
Quoted 4 lines
I've implemented a series [PATCH 0/4] mm: merge zram into zswap, I can change the tile to "merge zswap into zram" if you want and rename zswap to something like zhybrid.
Hmm, I saw that roughly and you are ignoring zram's backward compatibility and zram-blk functionality which can be used for in-memory compressed block device without swap.
Thanks.
Signature · 8 lines
Kind regards, Minchan Kim -- 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 131 lines · Minchan Kim
Hello Bob,
Sorry for the late response. I was on holiday.
Quoted 87 lines · Bob Liu
Hi Minchan,
Quoted 84 lines · Minchan Kim
Hello Mel,
Quoted 42 lines · Mel Gorman
Quoted 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a
zbud_opsthat does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?mm/zswap.c +0
-1@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)Quoted 4 lines
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Never. Because I didn't have such requirement for zram.
Quoted 18 lines
Quoted 7 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 2 lines
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
You mean "make pseudo block device and register
make_request_fn
and prevent writeback". Bah, yes, it's doable but what is it different with below?1) move zbud into zram
2) implement frontswap API in zram
3) implement writebazk in zramThe zram has been for a long time in staging to be promoted and have been maintained/deployed. Of course, I have asked the promotion several times for above a year.
Quoted 5 lines
Quoted 2 lines
Why can't zram include zswap functions if you really want to merge them? Is there any problem?
I think merging zram into zswap or merging zswap into zram are the same thing. It's no difference.
True but i'd like to merge zswap code into zram.
Because as you know, zram has already lots of users while zswap is almost new young so I'd like to keep backward compatibility for zram so moving zswap code into zram is more handy and could keep the git log as well.Quoted 2 lines
Both way will result in a solution finally with zram block device, frontswap API etc.
Right but z* family people should discuss that zswap-writeback is really good solution for compressed swap. Firstly, I thought zswap is differnt with zram so there is no issue to promote zram so I and Nitin helped zsmalloc promotion for Seth and have reviewed at zswap inital phases but the situation is chainging. Let's discussion further points about compresssed swap solution. I raised issues as reply of Mel in my thread. Let's think of it.
Quoted 3 lines
The difference is just the name and the merging patch title, I think it's unimportant.
If we decide merging them, yes, module name would be important and we can't ignore copyright and maintainer part, either. Anyway,
I'd like to go that way as last resort afther enough thinking which can justify frontswap-based swap writeback is right approach.Quoted 4 lines
I've implemented a series [PATCH 0/4] mm: merge zram into zswap, I can change the tile to "merge zswap into zram" if you want and rename zswap to something like zhybrid.
Hmm, I saw that roughly and you are ignoring zram's backward compatibility and zram-blk functionality which can be used for in-memory compressed block device without swap.
Quoted 5 lines
Thanks.
--
Kind regards,
Minchan Kim
We are gearing up to evaluate zswap, but we have only ported kernels up to 3.8 to our hardware, so we may be missing important patches.
In our experience, and with all due respect, the linux MM is a complex beast, and it's difficult to predict how hard it will be for us to switch to zswap. Even with the relatively simple zram, our load triggered bugs in other parts of the MM that took a fair amount of work to resolve.
I may be wrong, but the in-memory compressed block device implemented by zram seems like a simple device which uses a well-established API to the rest of the kernel. If it is removed from the kernel, will it be difficult for us to carry our own patch? Because we may have to do that for a while. Of course we would prefer it if it stayed in, at least temporarily.
Also, could someone confirm or deny that the maximum compression ratio in zbud is 2? Because we easily achieve a 2.6-2.8 compression ratio with our loads using zram with zsmalloc and LZO or snappy. Losing that memory will cause a noticeable regression, which will encourage us to stick with zram.
I am hoping that our load is not so unusual that we are the only Linux users in this situation, and that zsmalloc (or other allocator-compressor with similar characteristics) will continue to exist, whether it is used by zram or zswap.
Thanks!
--
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>
Hi Luigi,
Quoted 7 lines · Luigi Semenzato
We are gearing up to evaluate zswap, but we have only ported kernels up to 3.8 to our hardware, so we may be missing important patches.
In our experience, and with all due respect, the linux MM is a complex beast, and it's difficult to predict how hard it will be for us to switch to zswap. Even with the relatively simple zram, our load
I think it will be easy if zswap can also create a pseudo block device(I already done the simple implementation [PATCH 0/4] mm: merge zram into zswap), then it's transparent for original zram users.
Quoted 23 lines
triggered bugs in other parts of the MM that took a fair amount of work to resolve.
I may be wrong, but the in-memory compressed block device implemented by zram seems like a simple device which uses a well-established API to the rest of the kernel. If it is removed from the kernel, will it be difficult for us to carry our own patch? Because we may have to do that for a while. Of course we would prefer it if it stayed in, at least temporarily.
Also, could someone confirm or deny that the maximum compression ratio in zbud is 2? Because we easily achieve a 2.6-2.8 compression ratio with our loads using zram with zsmalloc and LZO or snappy. Losing that memory will cause a noticeable regression, which will encourage us to stick with zram.
I am hoping that our load is not so unusual that we are the only Linux users in this situation, and that zsmalloc (or other allocator-compressor with similar characteristics) will continue to exist, whether it is used by zram or zswap.
Thanks!
Signature · 8 lines
Regards, -Bob -- 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>
Minchan Kim
maintainerHello Luigi,
Quoted 147 lines · Luigi Semenzato
Quoted 131 lines · Minchan Kim
Hello Bob,
Sorry for the late response. I was on holiday.
Quoted 87 lines · Bob Liu
Hi Minchan,
Quoted 84 lines · Minchan Kim
Hello Mel,
Quoted 42 lines · Mel Gorman
Quoted 18 lines · Minchan Kim
Quoted 18 lines
Quoted 17 lines
Quoted 9 lines
<SNIP>
If it's used for something like tmpfs then it becomes much worse. Normal tmpfs without swap can lockup if tmpfs is allowed to fill memory. In a sane configuration, lockups will be avoided and deleting a tmpfs file is guaranteed to free memory. When zram is used to back tmpfs, there is no guarantee that any memory is freed due to fragmentation of the compressed pages. The only way to recover the memory may be to kill applications holding tmpfs files open and then delete them which is fairly drastic action in a normal server environment.Indeed.
Actually, I had a plan to support zsmalloc compaction. The zsmalloc exposes handle instead of pure pointer so it could migrate some zpages to somewhere to pack in. Then, it could help above problem and OOM storm problem. Anyway, it's a totally new feature and requires many changes and experiement. Although we don't have such feature, zram is still good for many people.Quoted 3 lines
Quoted 1 line
And is zsmalloc was pluggable for zswap then it would also benefit.
But zswap isn't pseudo block device so it couldn't be used for block device.
It would not be impossible to write one. Taking a quick look it might even be doable by just providing a
zbud_opsthat does not have an evict handler and make sure the errors are handled correctly. i.e. does the following patch mean that zswap never writes back and instead just compresses pages in memory?mm/zswap.c +0
-1@@ -819,7 +819,6 @@ static void zswap_frontswap_invalidate_area(unsigned type) }static struct zbud_ops zswap_zbud_ops = { - .evict = zswap_writeback_entry };static void zswap_frontswap_init (unsigned type)Quoted 4 lines
If so, it should be doable to link that up in a sane way so it can be configured at runtime.
Did you ever even try something like this?
Never. Because I didn't have such requirement for zram.
Quoted 18 lines
Quoted 7 lines
Let say one usecase for using zram-blk.
1) Many embedded system don't have swap so although tmpfs can support swapout it's pointless still so such systems should have sane configuration to limit memory space so it's not only zram problem.
If zswap was backed by a pseudo device that failed all writes or an an ops with no evict handler then it would be functionally similar.
Quoted 6 lines
2) Many embedded system don't have enough memory. Let's assume short-lived file growing up until half of system memory once in a while. We don't want to write it on flash by wear-leveing issue and very slowness so we want to use in-memory but if we uses tmpfs, it should evict half of working set to cover them when the size reach peak. zram would be better choice.
Quoted 2 lines
Then back it by a pseudo device that fails all writes so it does not have to write to disk.
You mean "make pseudo block device and register
make_request_fn
and prevent writeback". Bah, yes, it's doable but what is it different with below?1) move zbud into zram
2) implement frontswap API in zram
3) implement writebazk in zramThe zram has been for a long time in staging to be promoted and have been maintained/deployed. Of course, I have asked the promotion several times for above a year.
Quoted 5 lines
Quoted 2 lines
Why can't zram include zswap functions if you really want to merge them? Is there any problem?
I think merging zram into zswap or merging zswap into zram are the same thing. It's no difference.
True but i'd like to merge zswap code into zram.
Because as you know, zram has already lots of users while zswap is almost new young so I'd like to keep backward compatibility for zram so moving zswap code into zram is more handy and could keep the git log as well.Quoted 2 lines
Both way will result in a solution finally with zram block device, frontswap API etc.
Right but z* family people should discuss that zswap-writeback is really good solution for compressed swap. Firstly, I thought zswap is differnt with zram so there is no issue to promote zram so I and Nitin helped zsmalloc promotion for Seth and have reviewed at zswap inital phases but the situation is chainging. Let's discussion further points about compresssed swap solution. I raised issues as reply of Mel in my thread. Let's think of it.
Quoted 3 lines
The difference is just the name and the merging patch title, I think it's unimportant.
If we decide merging them, yes, module name would be important and we can't ignore copyright and maintainer part, either. Anyway,
I'd like to go that way as last resort afther enough thinking which can justify frontswap-based swap writeback is right approach.Quoted 4 lines
I've implemented a series [PATCH 0/4] mm: merge zram into zswap, I can change the tile to "merge zswap into zram" if you want and rename zswap to something like zhybrid.
Hmm, I saw that roughly and you are ignoring zram's backward compatibility and zram-blk functionality which can be used for in-memory compressed block device without swap.
Quoted 5 lines
Thanks.
--
Kind regards,
Minchan KimWe are gearing up to evaluate zswap, but we have only ported kernels up to 3.8 to our hardware, so we may be missing important patches.
In our experience, and with all due respect, the linux MM is a complex beast, and it's difficult to predict how hard it will be for us to switch to zswap. Even with the relatively simple zram, our load triggered bugs in other parts of the MM that took a fair amount of work to resolve.
Quoted 3 lines
I may be wrong, but the in-memory compressed block device implemented by zram seems like a simple device which uses a well-established API to the rest of the kernel. If it is removed from the kernel, will it
True.
Quoted 3 lines
be difficult for us to carry our own patch? Because we may have to do that for a while. Of course we would prefer it if it stayed in, at least temporarily.
Totally, I agree. zram shouldn't go out before we have clear solution for the future.
Quoted 6 lines
Also, could someone confirm or deny that the maximum compression ratio in zbud is 2? Because we easily achieve a 2.6-2.8 compression ratio with our loads using zram with zsmalloc and LZO or snappy. Losing that memory will cause a noticeable regression, which will encourage us to stick with zram.
2 is right for zbud and that's why zswap people want to merge zsmalloc into zswap.
Quoted 5 lines
I am hoping that our load is not so unusual that we are the only Linux users in this situation, and that zsmalloc (or other allocator-compressor with similar characteristics) will continue to exist, whether it is used by zram or zswap.
Don't mind. zsmalloc should be in there.
Currently, my concern is that zswap is really a good feature for compressed swap when we consider further enhancements? I don't think so. Maybe zswap should borrow, if ever, all of the code from zram to emulate zram and keep the backward compatibility.
But I don't think it does make sense. Why really young zswap should try to absorb old zram? Hmm..
Quoted 8 lines
Thanks!
--
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>
Signature · 8 lines
Kind regards, Minchan Kim -- 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>