zram/zsmalloc promotion
Subsystems (6)
Minchan Kim
maintainerv5 cover zram/zsmalloc promotion
This patchset promotes zram/zsmalloc from staging.
Both are very clean and zram have been used by many embedded product for a long time. For example,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 is trial to use zram as swap in ChromeOS project, too. (Although they report some problem recently, it was not a problem of zram). When you google zram, you can find various usecase in xda-developers.
The benefit of zram is very clear. With my experience, the benefit in real practice was to remove jitter of video application.
It would be effect of efficient memory usage by compression but more issue is whether swap is there or not in the system. As you know, recent mobile platform have used JAVA so there are lots of anonymous pages. But embedded system normally doesn't use eMMC or SDCard as swap because there is wear-leveling issue and latency so we can't reclaim anymous pages. It sometime ends up making system very slow when it requires to get contiguous memory and even many file-backed pages are evicted. It's never what embedded people want it. Zram is one of best solution for that.
Quote from Luigi
"
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.
"
It's time to go out of staging.
Greg, Jens is already OK that zram is located under driver/blocks/. The issue remained is where we put zsmalloc. The candidate is two under mm/ or under lib/. Konrad and Nitin wanted to put zsmalloc into lib/ instead of mm/.
Quote from Nitin
"
I think mm/ directory should only contain the code which is intended for global use such as the slab allocator, page reclaim code etc. zsmalloc is used by only one (or possibly two) drivers, so lib/ seems to be the right place.
"
Quote from Konrand
"
I like the idea of keeping it in /lib or /mm. Actually 'lib' sounds more appropriate since it is dealing with storing a bunch of pages in a nice layout for great density purposes.
"
In fact, there is some history about that.
Why I put zsmalloc into under mm firstly was that Andrew had a concern about using strut page's some fields freely in zsmalloc so he wanted to maintain it in mm/ if I remember correctly.
So I and Nitin tried to ask the opinion to akpm several times (at least 6 and even I sent such patch a few month ago) but didn't get any reply from him or any mm guys so I guess mm guys doesn't have any concern about that any more.
In point of view that it's an another slab-like allocator, it might be proper under mm but it's not popular as current mm's allocators(/SLUB/SLOB and page allocator).
Frankly speaking, I don't care whether we put it to mm/ or lib/. It seems contributors(ex, Nitin, Konrad, Pekka, Seth and Dan) like lib/ and other mm guys are still silent. That's why I am biased into lib/ now.
If someone yell we should keep it to mm/ by logical claim, I can change my mind easily. Please raise your hand.
If Andrew doesn't have a concern about that any more, I would like to locate it into /lib.
This patchset is based on next-20121115.
Minchan Kim (3):
zsmalloc: promote to lib/
zram: promote zram from staging
zram: select ZSMALLOC when ZRAM is configured
drivers/block/Kconfig | 1 + drivers/block/Makefile | 1 + drivers/block/zram/Kconfig | 26 + drivers/block/zram/Makefile | 3 + drivers/block/zram/zram.txt | 76 +++ drivers/block/zram/zram_drv.c | 776 ++++++++++++++++++++++ drivers/block/zram/zram_drv.h | 119 ++++ drivers/block/zram/zram_sysfs.c | 225 +++++++ drivers/staging/Kconfig | 4 - drivers/staging/Makefile | 2 - drivers/staging/zcache/zcache-main.c | 4 +- drivers/staging/zram/Kconfig | 25 - drivers/staging/zram/Makefile | 3 - drivers/staging/zram/zram.txt | 76 --- drivers/staging/zram/zram_drv.c | 776 ---------------------- drivers/staging/zram/zram_drv.h | 120 ---- drivers/staging/zram/zram_sysfs.c | 225 ------- drivers/staging/zsmalloc/Kconfig | 10 - drivers/staging/zsmalloc/Makefile | 3 - drivers/staging/zsmalloc/zsmalloc-main.c | 1064 ------------------------------ drivers/staging/zsmalloc/zsmalloc.h | 43 -- include/linux/zsmalloc.h | 43 ++ lib/Kconfig | 18 + lib/Makefile | 1 + lib/zsmalloc.c | 1064 ++++++++++++++++++++++++++++++ 25 files changed, 2355 insertions(+), 2353 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/zram_drv.h create mode 100644 drivers/block/zram/zram_sysfs.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/zram_sysfs.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 create mode 100644 lib/zsmalloc.c
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 v5 1/3 zsmalloc: promote to lib/
This patch promotes the slab-based zsmalloc memory allocator from the staging tree to lib/
zcache/zram depends on this allocator for storing compressed RAM pages in an efficient way under system wide memory pressure where high-order (greater than 0) page allocation are very likely to fail.
For more information on zsmalloc and its internals, read the documentation at the top of the zsmalloc.c file.
--- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/zcache/zcache-main.c | 4 +- drivers/staging/zram/zram_drv.h | 3 +- drivers/staging/zsmalloc/Kconfig | 10 - drivers/staging/zsmalloc/Makefile | 3 - drivers/staging/zsmalloc/zsmalloc-main.c | 1064 ------------------------------ drivers/staging/zsmalloc/zsmalloc.h | 43 -- include/linux/zsmalloc.h | 43 ++ lib/Kconfig | 18 + lib/Makefile | 1 + lib/zsmalloc.c | 1064 ++++++++++++++++++++++++++++++ 12 files changed, 1129 insertions(+), 1127 deletions(-) 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 create mode 100644 lib/zsmalloc.c
drivers/staging/Kconfig +0 -2
@@ -76,8 +76,6 @@ source "drivers/staging/zram/Kconfig" source "drivers/staging/zcache/Kconfig" -source "drivers/staging/zsmalloc/Kconfig" - source "drivers/staging/wlags49_h2/Kconfig" source "drivers/staging/wlags49_h25/Kconfig"
drivers/staging/Makefile +0 -1
@@ -33,7 +33,6 @@ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_ZCACHE) += zcache/ -obj-$(CONFIG_ZSMALLOC) += zsmalloc/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
drivers/staging/zcache/zcache-main.c +2 -2
@@ -32,9 +32,9 @@#include <linux/crypto.h> #include <linux/string.h> #include <linux/idr.h> -#include "tmem.h" +#include <linux/zsmalloc.h> -#include "../zsmalloc/zsmalloc.h" +#include "tmem.h" #ifdef CONFIG_CLEANCACHE #include <linux/cleancache.h>
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/zsmalloc/Kconfig deleted +0 -10
@@ -1,10 +0,0 @@ -config ZSMALLOC - tristate "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.
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 -1064
1,064 lines not on this page · raw message
drivers/staging/zsmalloc/zsmalloc.h deleted +0 -43
43 lines not on this page · raw message
include/linux/zsmalloc.h new file +43 -0
43 lines not on this page · raw message
lib/Kconfig +18 -0
@@ -216,6 +216,24 @@ config DECOMPRESS_LZO config GENERIC_ALLOCATOR boolean +config ZSMALLOC + tristate "Memory allocator for compressed pages" + default n + help + zsmalloc is a slab-based memory allocator designed to store + compressed RAM pages. zsmalloc uses a memory pool that combines + single pages into higher order pages by linking them together + using the fields of the struct page. Allocations are then + mapped through copy buffers or VM mapping, in order to reduce + memory pool fragmentation and increase allocation success rate under + memory pressure. + + This results in a non-standard allocator interface where + a handle, not a pointer, is returned by the allocation function. + This handle must be mapped in order to access the allocated space. + + If unsure, say N. + # # reed solomon support is select'ed if needed #
lib/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_CRC7) += crc7.o obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_CRC8) += crc8.o obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o +obj-$(CONFIG_ZSMALLOC) += zsmalloc.o obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
lib/zsmalloc.c new file +1064 -0
1,064 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>
Minchan Kim
maintainerPATCH v5 2/3 zram: promote zram from staging
In reply to Minchan KimIt's time to promote zram from staging because zram lives in staging for a long time and is improved by many contributors so code is very clean. Most important issue, zram's dependency with x86 is solved by making zsmalloc portable. In addition, many embedded product uses zram in real practice so I think there is no reason to prevent promotion now.
--- drivers/block/Kconfig | 1 + drivers/block/Makefile | 1 + drivers/block/zram/Kconfig | 25 ++ drivers/block/zram/Makefile | 3 + drivers/block/zram/zram.txt | 76 ++++ drivers/block/zram/zram_drv.c | 776 +++++++++++++++++++++++++++++++++++++ drivers/block/zram/zram_drv.h | 119 ++++++ drivers/block/zram/zram_sysfs.c | 225 +++++++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/zram/Kconfig | 25 -- drivers/staging/zram/Makefile | 3 - drivers/staging/zram/zram.txt | 76 ---- drivers/staging/zram/zram_drv.c | 776 ------------------------------------- drivers/staging/zram/zram_drv.h | 119 ------ drivers/staging/zram/zram_sysfs.c | 225 ----------- 16 files changed, 1226 insertions(+), 1227 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/zram_drv.h create mode 100644 drivers/block/zram/zram_sysfs.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/zram_sysfs.c
drivers/block/Kconfig +1 -0
@@ -290,6 +290,7 @@ config BLK_DEV_CRYPTOLOOP cryptoloop device. source "drivers/block/drbd/Kconfig" +source "drivers/block/zram/Kconfig" config BLK_DEV_NBD tristate "Network block device support"
drivers/block/Makefile +1 -0
@@ -30,6 +30,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 +25 -0
@@ -0,0 +1,25 @@ +config ZRAM + tristate "Compressed RAM block device support" + depends on BLOCK && SYSFS && ZSMALLOC + 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: http://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.
drivers/block/zram/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +zram-y := zram_drv.o zram_sysfs.o + +obj-$(CONFIG_ZRAM) += zram.o
drivers/block/zram/zram.txt new file +76 -0
76 lines not on this page · raw message
drivers/block/zram/zram_drv.c new file +776 -0
776 lines not on this page · raw message
drivers/block/zram/zram_drv.h new file +119 -0
119 lines not on this page · raw message
drivers/block/zram/zram_sysfs.c new file +225 -0
225 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/zcache/Kconfig" source "drivers/staging/wlags49_h2/Kconfig"
drivers/staging/Makefile +0 -1
@@ -31,7 +31,6 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_IPACK_BUS) += ipack/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ -obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_ZCACHE) += zcache/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/
drivers/staging/zram/Kconfig deleted +0 -25
@@ -1,25 +0,0 @@ -config ZRAM - tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && ZSMALLOC - 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: http://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.
drivers/staging/zram/Makefile deleted +0 -3
@@ -1,3 +0,0 @@ -zram-y := zram_drv.o zram_sysfs.o - -obj-$(CONFIG_ZRAM) += zram.o
drivers/staging/zram/zram.txt deleted +0 -76
76 lines not on this page · raw message
drivers/staging/zram/zram_drv.c deleted +0 -776
776 lines not on this page · raw message
drivers/staging/zram/zram_drv.h deleted +0 -119
119 lines not on this page · raw message
drivers/staging/zram/zram_sysfs.c deleted +0 -225
225 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>
Minchan Kim
maintainerPATCH v5 3/3 zram: select ZSMALLOC when ZRAM is configured
In reply to Minchan KimAt the monent, we can configure zram in driver/block once zsmalloc in /lib menu is configured firstly. It's not convenient.
User can configure zram in driver/block regardless of zsmalloc enabling by this patch.
--- drivers/block/zram/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/zram/Kconfig +2 -1
@@ -1,6 +1,7 @@ config ZRAM tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && ZSMALLOC + depends on BLOCK && SYSFS + select ZSMALLOC select LZO_COMPRESS select LZO_DECOMPRESS default n
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>