Skip to contentSkip to conversation

promote zcache from staging

PATCH In review Seth Jennings 3 participants 7 messages Sep 4, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover promote zcache from staging

zcache is the remaining piece of code required to support in-kernel memory compression. The other two features, cleancache and frontswap, have been promoted to mainline in 3.0 and 3.5 respectively. This patchset promotes zcache from the staging tree to mainline.

Based on the level of activity and contributions we're seeing from a diverse set of people and interests, I think zcache has matured to the point where it makes sense to promote this out of staging.

Overview
========
zcache is a backend to frontswap and cleancache that accepts pages from those mechanisms and compresses them, leading to reduced I/O caused by swap and file re-reads. This is very valuable in shared storage situations to reduce load on things like SANs. Also, in the case of slow backing/swap devices, zcache can also yield a performance gain.

In-Kernel Memory Compression Overview:

swap subsystem page cache
+ +
frontswap cleancache
+ +
zcache frontswap glue zcache cleancache glue

        +                      +
        +---------+------------+
                  +
            zcache/tmem core
                  +
        +---------+------------+
        +                      +
     zsmalloc                 zbud

Everything below the frontswap/cleancache layer is current inside the zcache driver expect for zsmalloc which is a shared between zcache and another memory compression driver, zram.

Since zcache is dependent on zsmalloc, it is also being promoted by this patchset.

For information on zsmalloc and the rationale behind it's design and use cases verses already existing allocators in the kernel:

https://lkml.org/lkml/2012/1/9/386

zsmalloc is the allocator used by zcache to store persistent pages that comes from frontswap, as opposed to zbud which is the (internal) allocator used for ephemeral pages from cleancache.

zsmalloc uses many fields of the page struct to create it's conceptual high-order page called a zspage. Exactly which fields are used and for what purpose is documented at the top of the zsmalloc .c file. Because zsmalloc uses struct page extensively, Andrew advised that the promotion location be mm/:

https://lkml.org/lkml/2012/1/20/308

Some benchmarking numbers demonstrating the I/O saving that can be had with zcache:

https://lkml.org/lkml/2012/3/22/383

Dan's presentation at LSF/MM this year on zcache:

http://oss.oracle.com/projects/tmem/dist/documentation/presentations/LSFMM12-zcache-final.pdf

There was a recent thread about cleancache memory corruption that is resolved by this patch that should be making it into linux-next via Greg very soon:

https://lkml.org/lkml/2012/8/29/253

Changlog:
v2:
* rebased to next-20120904
* removed already accepted patch from patchset

Seth Jennings (3):
zsmalloc: promote to mm/
drivers: add memory management driver class
zcache: promote to drivers/mm/

 drivers/Kconfig                                    |    2 ++
 drivers/Makefile                                   |    1 +
 drivers/mm/Kconfig                                 |   13 +++++++++++++
 drivers/mm/Makefile                                |    1 +
 drivers/{staging => mm}/zcache/Makefile            |    0
 drivers/{staging => mm}/zcache/tmem.c              |    0
 drivers/{staging => mm}/zcache/tmem.h              |    0
 drivers/{staging => mm}/zcache/zcache-main.c       |    4 ++--
 drivers/staging/Kconfig                            |    4 ----
 drivers/staging/Makefile                           |    2 --
 drivers/staging/zcache/Kconfig                     |   11 -----------
 drivers/staging/zram/zram_drv.h                    |    3 +--
 drivers/staging/zsmalloc/Kconfig                   |   10 ----------
 drivers/staging/zsmalloc/Makefile                  |    3 ---
 .../staging/zsmalloc => include/linux}/zsmalloc.h  |    0
 mm/Kconfig                                         |   18 ++++++++++++++++++
 mm/Makefile                                        |    1 +
 .../zsmalloc/zsmalloc-main.c => mm/zsmalloc.c      |    3 +--
 18 files changed, 40 insertions(+), 36 deletions(-)
 create mode 100644 drivers/mm/Kconfig
 create mode 100644 drivers/mm/Makefile
 rename drivers/{staging => mm}/zcache/Makefile (100%)
 rename drivers/{staging => mm}/zcache/tmem.c (100%)
 rename drivers/{staging => mm}/zcache/tmem.h (100%)
 rename drivers/{staging => mm}/zcache/zcache-main.c (99%)
 delete mode 100644 drivers/staging/zcache/Kconfig
 delete mode 100644 drivers/staging/zsmalloc/Kconfig
 delete mode 100644 drivers/staging/zsmalloc/Makefile
 rename {drivers/staging/zsmalloc => include/linux}/zsmalloc.h (100%)
 rename drivers/staging/zsmalloc/zsmalloc-main.c => mm/zsmalloc.c (99%)
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>
#1 lore raw

PATCH v2 1/3 zsmalloc: promote to mm/

This patch promotes the slab-based zsmalloc memory allocator from the staging tree to mm/

zcache 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 ---
 .../staging/zsmalloc => include/linux}/zsmalloc.h  |    0
 mm/Kconfig                                         |   18 ++++++++++++++++++
 mm/Makefile                                        |    1 +
 .../zsmalloc/zsmalloc-main.c => mm/zsmalloc.c      |    3 +--
 10 files changed, 23 insertions(+), 22 deletions(-)
 delete mode 100644 drivers/staging/zsmalloc/Kconfig
 delete mode 100644 drivers/staging/zsmalloc/Makefile
 rename {drivers/staging/zsmalloc => include/linux}/zsmalloc.h (100%)
 rename drivers/staging/zsmalloc/zsmalloc-main.c => mm/zsmalloc.c (99%)
drivers/staging/Kconfig +0 -2
index e3402d5..b7f7bc7 100644
@@ -78,8 +78,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
index 3be59d0..ad74bee 100644
@@ -34,7 +34,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
index 52b43b7..34b2c5c 100644
@@ -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
index 572c0b1..f6d0925 100644
@@ -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
deleted file mode 100644
index 9084565..0000000
@@ -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
deleted file mode 100644
index b134848..0000000
@@ -1,3 +0,0 @@
-zsmalloc-y 		:= zsmalloc-main.o
-
-obj-$(CONFIG_ZSMALLOC)	+= zsmalloc.o
include/linux/zsmalloc.h renamed from drivers/staging/zsmalloc/zsmalloc.h +0 -0
similarity index 100%
rename from drivers/staging/zsmalloc/zsmalloc.h
rename to include/linux/zsmalloc.h
mm/Kconfig +18 -0
index d5c8019..2586b66 100644
@@ -411,3 +411,21 @@ config FRONTSWAP
 	  and swap data is stored as normal on the matching swap device.
 
 	  If unsure, say Y to enable frontswap.
+
+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.
mm/Makefile +1 -0
index 92753e2..8a3d7bea 100644
@@ -57,3 +57,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o
 obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
 obj-$(CONFIG_CLEANCACHE) += cleancache.o
 obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o
+obj-$(CONFIG_ZSMALLOC) += zsmalloc.o
mm/zsmalloc.c renamed from drivers/staging/zsmalloc/zsmalloc-main.c +1 -2
similarity index 99%
rename from drivers/staging/zsmalloc/zsmalloc-main.c
rename to mm/zsmalloc.c
index 09a9d35..6b20429 100644
@@ -78,8 +78,7 @@
 #include <linux/hardirq.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
-
-#include "zsmalloc.h"
+#include <linux/zsmalloc.h>
 
 /*
  * This must be power of 2 and greater than of equal to sizeof(link_free).
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/3 drivers: add memory management driver class

In reply to Seth Jennings

This patchset creates a new driver class under drivers/ for memory management related drivers, like zcache.

This driver class would be for drivers that don't actually enabled a hardware device, but rather augment the memory manager in some way.

In-tree candidates for this driver class are zcache, zram, and lowmemorykiller, both in staging.

---
 drivers/Kconfig    |    2 ++
 drivers/Makefile   |    1 +
 drivers/mm/Kconfig |    3 +++
 3 files changed, 6 insertions(+)
 create mode 100644 drivers/mm/Kconfig
drivers/Kconfig +2 -0
index 324e958..d126132 100644
@@ -154,4 +154,6 @@ source "drivers/vme/Kconfig"
 
 source "drivers/pwm/Kconfig"
 
+source "drivers/mm/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index d64a0f7..aa69e1c 100644
@@ -140,3 +140,4 @@ obj-$(CONFIG_EXTCON)		+= extcon/
 obj-$(CONFIG_MEMORY)		+= memory/
 obj-$(CONFIG_IIO)		+= iio/
 obj-$(CONFIG_VME_BUS)		+= vme/
+obj-$(CONFIG_MM_DRIVERS)	+= mm/
drivers/mm/Kconfig new file +3 -0
new file mode 100644
index 0000000..e5b3743
@@ -0,0 +1,3 @@
+menu "Memory management drivers"
+
+endmenu
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>
#3 lore raw

PATCH v2 3/3 zcache: promote to drivers/mm/

In reply to Seth Jennings

This patchset promotes the zcache driver from staging to drivers/mm/.

zcache captures swap pages via frontswap and pages that fall out of the page cache via cleancache and compress them in RAM, providing a compressed RAM swap and a compressed second-chance page cache.

---
 drivers/mm/Kconfig                           |   10 ++++++++++
 drivers/mm/Makefile                          |    1 +
 drivers/{staging => mm}/zcache/Makefile      |    0
 drivers/{staging => mm}/zcache/tmem.c        |    0
 drivers/{staging => mm}/zcache/tmem.h        |    0
 drivers/{staging => mm}/zcache/zcache-main.c |    0
 drivers/staging/Kconfig                      |    2 --
 drivers/staging/Makefile                     |    1 -
 drivers/staging/zcache/Kconfig               |   11 -----------
 9 files changed, 11 insertions(+), 14 deletions(-)
 create mode 100644 drivers/mm/Makefile
 rename drivers/{staging => mm}/zcache/Makefile (100%)
 rename drivers/{staging => mm}/zcache/tmem.c (100%)
 rename drivers/{staging => mm}/zcache/tmem.h (100%)
 rename drivers/{staging => mm}/zcache/zcache-main.c (100%)
 delete mode 100644 drivers/staging/zcache/Kconfig
drivers/mm/Kconfig +10 -0
index e5b3743..22289c6 100644
@@ -1,3 +1,13 @@
 menu "Memory management drivers"
 
+config ZCACHE
+	bool "Dynamic compression of swap pages and clean pagecache pages"
+	depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && ZSMALLOC=y
+	select CRYPTO_LZO
+	default n
+	help
+	  Zcache uses compression and an in-kernel implementation of
+	  transcendent memory to store clean page cache pages and swap
+	  in RAM, providing a noticeable reduction in disk I/O.
+
 endmenu
drivers/mm/Makefile new file +1 -0
new file mode 100644
index 0000000..f36f509
@@ -0,0 +1 @@
+obj-$(CONFIG_ZCACHE)	+= zcache/
drivers/mm/zcache/Makefile renamed from drivers/staging/zcache/Makefile +0 -0
similarity index 100%
rename from drivers/staging/zcache/Makefile
rename to drivers/mm/zcache/Makefile
drivers/mm/zcache/tmem.c renamed from drivers/staging/zcache/tmem.c +0 -0
similarity index 100%
rename from drivers/staging/zcache/tmem.c
rename to drivers/mm/zcache/tmem.c
drivers/mm/zcache/tmem.h renamed from drivers/staging/zcache/tmem.h +0 -0
similarity index 100%
rename from drivers/staging/zcache/tmem.h
rename to drivers/mm/zcache/tmem.h
drivers/mm/zcache/zcache-main.c renamed from drivers/staging/zcache/zcache-main.c +0 -0
similarity index 100%
rename from drivers/staging/zcache/zcache-main.c
rename to drivers/mm/zcache/zcache-main.c
drivers/staging/Kconfig +0 -2
index b7f7bc7..0940d2e 100644
@@ -76,8 +76,6 @@ source "drivers/staging/iio/Kconfig"
 
 source "drivers/staging/zram/Kconfig"
 
-source "drivers/staging/zcache/Kconfig"
-
 source "drivers/staging/wlags49_h2/Kconfig"
 
 source "drivers/staging/wlags49_h25/Kconfig"
drivers/staging/Makefile +0 -1
index ad74bee..6e1c491 100644
@@ -33,7 +33,6 @@ 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/
 obj-$(CONFIG_FB_SM7XX)		+= sm7xxfb/
drivers/staging/zcache/Kconfig deleted +0 -11
deleted file mode 100644
index 4881839..0000000
@@ -1,11 +0,0 @@
-config ZCACHE
-	bool "Dynamic compression of swap pages and clean pagecache pages"
-	depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && ZSMALLOC=y
-	select CRYPTO_LZO
-	default n
-	help
-	  Zcache doubles RAM efficiency while providing a significant
-	  performance boosts on many workloads.  Zcache uses
-	  compression and an in-kernel implementation of transcendent
-	  memory to store clean page cache pages and swap in RAM,
-	  providing a noticeable reduction in disk I/O.
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>
#4 lore raw
In reply to Seth Jennings
Quoted 4 lines · Seth Jennings

zcache is the remaining piece of code required to support in-kernel memory compression. The other two features, cleancache and frontswap, have been promoted to mainline in 3.0 and 3.5 respectively. This patchset promotes zcache from the staging tree to mainline.

Could you please post it as a singular path. As if it was out-off-tree? That way it will be much easier to review it by looking at the full code.

--
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>

maintainer
#5 lore raw
Quoted 8 lines · On Tue, 4 Sep 2012 15:57:11 -0400 Konrad Rzeszutek Wilk…
Quoted 4 lines · Seth Jennings

zcache is the remaining piece of code required to support in-kernel memory compression. The other two features, cleancache and frontswap, have been promoted to mainline in 3.0 and 3.5 respectively. This patchset promotes zcache from the staging tree to mainline.

Could you please post it as a singular path. As if it was out-off-tree? That way it will be much easier to review it by looking at the full code.

Yes please. Very few of the MM developers are familiar with this code.

--
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>

#6 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Seth Jennings

zcache is the remaining piece of code required to support in-kernel memory compression. The other two features, cleancache and frontswap, have been promoted to mainline in 3.0 and 3.5 respectively. This patchset promotes zcache from the staging tree to mainline.

Could you please post it as a singular path. As if it was out-off-tree? That way it will be much easier to review it by looking at the full code.

Ah yes, my bad. Scratch v2. Nothing to see here.

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>