zswap: compressed swap caching
Subsystems (7)
v13 cover zswap: compressed swap caching
This is the latest version of the zswap patchset for compressed swap caching. This is submitted for merging into linux-next and inclusion in v3.11.
New in this Version:
Lucky 13!
Integrated feedback from Andrew and moved zbud page metadata out of the struct page to an in-line header structure.
Useful References:
LSFMM: In-kernel memory compression
https://lwn.net/Articles/548109/
The zswap compressed swap cache
https://lwn.net/Articles/537422/
Zswap Overview:
Zswap is a lightweight compressed cache for swap pages. It takes pages that are in the process of being swapped out and attempts to compress them into a dynamically allocated RAM-based memory pool. If this process is successful, the writeback to the swap device is deferred and, in many cases, avoided completely. This results in a significant I/O reduction and performance gains for systems that are swapping.
The results of a kernel building benchmark indicate a runtime reduction of 53% and an I/O reduction 76% with zswap vs normal swapping with a kernel build under heavy memory pressure (see Performance section for more).
Some addition performance metrics regarding the performance improvements and I/O reductions that can be achieved using zswap as measured by SPECjbb are provided here:
http://ibm.co/VCgHvM
These results include runs on x86 and new results on Power7+ with hardware compression acceleration.
Of particular note is that zswap is able to evict pages from the compressed cache, on an LRU basis, to the backing swap device when the compressed pool reaches it size limit or the pool is unable to obtain additional pages from the buddy allocator. This eviction functionality had been identified as a requirement in prior community discussions.
Rationale:
Zswap provides compressed swap caching that basically trades CPU cycles for reduced swap I/O. This trade-off can result in a significant performance improvement as reads to/writes from to the compressed cache almost always faster that reading from a swap device which incurs the latency of an asynchronous block I/O read.
Some potential benefits:
* Desktop/laptop users with limited RAM capacities can mitigate the performance impact of swapping.
* Overcommitted guests that share a common I/O resource can dramatically reduce their swap I/O pressure, avoiding heavy handed I/O throttling by the hypervisor. This allows more work to get done with less impact to the guest workload and guests sharing the I/O subsystem
* Users with SSDs as swap devices can extend the life of the device by drastically reducing life-shortening writes.
Compressed swap is also provided in zcache, along with page cache compression and RAM clustering through RAMSter. Zswap seeks to deliver the benefit of swap compression to users in a discrete function. This design decision is akin to Unix design philosophy of doing one thing well, it leaves file cache compression and other features for separate code.
Design:
Zswap receives pages for compression through the Frontswap API and is able to evict pages from its own compressed pool on an LRU basis and write them back to the backing swap device in the case that the compressed pool is full or unable to secure additional pages from the buddy allocator.
Zswap makes use of zbud for the managing the compressed memory pool. Each allocation in zbud is not directly accessible by address. Rather, a handle is return by the allocation routine and that handle must be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compressed pages are freed. The pool is not preallocated.
When a swap page is passed from frontswap to zswap, zswap maintains a mapping of the swap entry, a combination of the swap type and swap offset, to the zbud handle that references that compressed swap page. This mapping is achieved with a red-black tree per swap type. The swap offset is the search key for the tree nodes.
Zswap seeks to be simple in its policies. Sysfs attributes allow for two user controlled policies:
* max_compression_ratio - Maximum compression ratio, as as percentage, for an acceptable compressed page. Any page that does not compress by at least this ratio will be rejected.
* max_pool_percent - The maximum percentage of memory that the compressed pool can occupy.
To enabled zswap, the "enabled" attribute must be set to 1 at boot time.
Zswap allows the compressor to be selected at kernel boot time by setting the “compressor” attribute. The default compressor is lzo.
A debugfs interface is provided for various statistic about pool size, number of pages stored, and various counters for the reasons pages are rejected.
Changelog:
v13:
* integrated feedback from Andrew
* moved zbud pool page metadata from struct page to in-line header contained in the page itself, avoiding potential issues with (broken?) code that accesses struct pages directly from the memmap array.
v12:
* updated Kconfig help and Documentation to indicate zswap is experimental
* remove max_compression_ratio tunable
* make zbud_pool's pages_nr lock protected and non-atomic
* don't export zbud symbols
* refactor reset_zbud_page()/__free_page() into free_zbud_page()
* make zsawp_pool_pages non-atomic
* zswap_enabled add __read_mostly
* remove type field from zswap_tree
* various comment changes
v11:
* fixup symbol collision with lib/fault-inject.c (Greg)
* rebase v3.10-rc1
v10:
* replace zsmalloc with zbud (zsmalloc to come back as option in future dev)
* lru logic moved out of zswap into allocator
* simplified and improved writeback logic
* removed memory pool and tmpage pool as part of refactoring
* Rebase to (almost) v3.10-rc1
v9:
* Fix load-during-writeback race; double lru add (for real this time)
* checkpatch and comment fixes
* Fix __swap_writepage() return value check
* Move check for max outstanding writebacks (dedup some code)
* Rebase to v3.9-rc6
v8:
* Fix load-during-writeback race; double lru add
* checkpatch fixups
* s/NOWAIT/ATOMIC for tree allocation (Dave)
* Check __swap_writepage() for error before incr outstanding write count (Rob)
* Convert pcpu compression buffer alloc from alloc_page() to kmalloc() (Dave)
* Rebase to v3.9-rc5
v7:
* Decrease zswap_stored_pages during tree cleanup (Joonsoo)
* Move zswap_entry_cache_alloc() earlier during store (Joonsoo)
* Move type field from struct zswap_entry to struct zswap_tree
* Change to swapper_space array (-rc1 change)
* s/reset_page_mapcount/page_mapcount_reset in zsmalloc (-rc1 change)
* Rebase to v3.9-rc1
v6:
* fix access-after-free regression introduced in v5 (rb_erase() outside the lock)
* fix improper freeing of rbtree (Cody)
* fix comment typo (Ric)
* add comments about ZS_MM_WO usage and page mapping mode (Joonsoo)
* don't use page->object (Joonsoo)
* remove DEBUG (Joonsoo)
* rebase to v3.8
v5:
* zsmalloc patch converted from promotion to "new code" (for review only, see note in [1/8])
* promote zsmalloc to mm/ instead of /lib
* add more documentation everywhere
* convert USE_PGTABLE_MAPPING to kconfig option, thanks to Minchan
* s/flush/writeback/
* #define pr_fmt() for formatting messages (Joe)
* checkpatch fixups
* lots of changes suggested Minchan
v4:
* Added Acks (Minchan)
* Separated flushing functionality into standalone patch for easier review (Minchan)
* fix comment on zswap enabled attribute (Minchan)
* add TODO for dynamic mempool size (Minchan)
* and check for NULL in zswap_free_page() (Minchan)
* add missing zs_free() in error path (Minchan)
* TODO: add comments for flushing/refcounting (Minchan)
v3:
* Dropped the zsmalloc patches from the set, except the promotion patch which has be converted to a rename patch (vs full diff). The dropped patches have been Acked and are going into Greg's staging tree soon.
* Separated [PATCHv2 7/9] into two patches since it makes changes for two different reasons (Minchan)
* Moved ZSWAP_MAX_OUTSTANDING_FLUSHES near the top in zswap.c (Rik)
* Rebase to v3.8-rc5. linux-next is a little volatile with the swapper_space per type changes which will effect this patchset.
* TODO: Move some stats from debugfs to sysfs. Which ones? (Rik)
v2:
* Rename zswap_fs_* functions to zswap_frontswap_* to avoid confusion with "filesystem"
* Add comment about what the tree lock protects
* Remove "#if 0" code (should have been done before)
* Break out changes to existing swap code into separate patch
* Fix blank line EOF warning on documentation file
* Rebase to next-20130107
Performance, Kernel Building:
Setup
========
Gentoo w/ kernel v3.7-rc7
Quad-core i5-2500 @ 3.3GHz
512MB DDR3 1600MHz (limited with mem=512m on boot) Filesystem and swap on 80GB HDD (about 58MB/s with hdparm -t) majflt are major page faults reported by the time command pswpin/out is the delta of pswpin/out from /proc/vmstat before and after the make -jN
Summary
========
* Zswap reduces I/O and improves performance at all swap pressure levels.
* Under heavy swaping at 24 threads, zswap reduced I/O by 76%, saving over 1.5GB of I/O, and cut runtime in half.
Details
========
I/O (in pages)
base zswap change change
N pswpin pswpout majflt I/O sum pswpin pswpout majflt I/O sum %I/O MB
8 1 335 291 627 0 0 249 249 -60% 1
12 3688 14315 5290 23293 123 860 5954 6937 -70% 64
16 12711 46179 16803 75693 2936 7390 46092 56418 -25% 75
20 42178 133781 49898 225857 9460 28382 92951 130793 -42% 371
24 96079 357280 105242 558601 7719 18484 109309 135512 -76% 1653
Runtime (in seconds)
N base zswap %change
8 107 107 0%
12 128 110 -14%
16 191 179 -6%
20 371 240 -35%
24 570 267 -53%
%CPU utilization (out of 400% on 4 cpus)
N base zswap %change
8 317 319 1%
12 267 311 16%
16 179 191 7%
20 94 143 52%
24 60 128 113%
Seth Jennings (4):
debugfs: add get/set for atomic types
zbud: add to mm/
zswap: add to mm/
zswap: add documentation
Documentation/vm/zswap.txt | 68 ++++ fs/debugfs/file.c | 42 ++ include/linux/debugfs.h | 2 + include/linux/zbud.h | 22 ++ lib/fault-inject.c | 21 - mm/Kconfig | 30 ++ mm/Makefile | 2 + mm/zbud.c | 526 ++++++++++++++++++++++++ mm/zswap.c | 943 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 1635 insertions(+), 21 deletions(-) create mode 100644 Documentation/vm/zswap.txt create mode 100644 include/linux/zbud.h create mode 100644 mm/zbud.c create mode 100644 mm/zswap.c
Signature · 1 line
1.7.9.5
PATCH v13 1/4 debugfs: add get/set for atomic types
debugfs currently lack the ability to create attributes that set/get atomic_t values.
This patch adds support for this through a new debugfs_create_atomic_t() function.
--- fs/debugfs/file.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ lib/fault-inject.c | 21 --------------------- 3 files changed, 44 insertions(+), 21 deletions(-)
fs/debugfs/file.c +42 -0
@@ -21,6 +21,7 @@#include <linux/debugfs.h> #include <linux/io.h> #include <linux/slab.h> +#include <linux/atomic.h> static ssize_t default_read_file (struct file *file,char __user *buf,size_t count,loff_t *ppos)
@@ -403,6 +404,47 @@ struct dentry *debugfs_create_size_t(const char *name, umode_t mode, }EXPORT_SYMBOL_GPL (debugfs_create_size_t); +static int debugfs_atomic_t_set (void *data,u64 val) +{ +atomic_set ((atomic_t *)data, val); +return 0 ; +} +static int debugfs_atomic_t_get (void *data,u64 *val) +{ + *val =atomic_read ((atomic_t *)data); +return 0 ; +} +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_t, debugfs_atomic_t_get, + debugfs_atomic_t_set,"%lld\n" ); +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_t_ro, debugfs_atomic_t_get,NULL ,"%lld\n" ); +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_t_wo,NULL , debugfs_atomic_t_set,"%lld\n" ); + +/** +* debugfs_create_atomic_t - create a debugfs file that is used to read and +* write an atomic_t value +* @name: a pointer to a string containing the name of the file to create. +* @mode: the permission that the file should have +* @parent: a pointer to the parent dentry for this file. This should be a +* directory dentry if set. If this parameter is %NULL, then the +* file will be created in the root of the debugfs filesystem. +* @value: a pointer to the variable that the file should read to and write +* from. +*/ +struct dentry *debugfs_create_atomic_t (const char *name,umode_t mode, +struct dentry *parent,atomic_t *value) +{ +/* if there are no write bits set, make read only */ +if (!(mode &S_IWUGO )) +return debugfs_create_file (name, mode, parent, value, + &fops_atomic_t_ro); +/* if there are no read bits set, make write only */ +if (!(mode &S_IRUGO )) +return debugfs_create_file (name, mode, parent, value, + &fops_atomic_t_wo); + +return debugfs_create_file (name, mode, parent, value, &fops_atomic_t); +} +EXPORT_SYMBOL_GPL (debugfs_create_atomic_t);static ssize_t read_file_bool (struct file *file,char __user *user_buf,size_t count,loff_t *ppos)
include/linux/debugfs.h +2 -0
@@ -79,6 +79,8 @@ struct dentry *debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value);struct dentry *debugfs_create_size_t (const char *name,umode_t mode,struct dentry *parent,size_t *value); +struct dentry *debugfs_create_atomic_t (const char *name,umode_t mode, +struct dentry *parent,atomic_t *value);struct dentry *debugfs_create_bool (const char *name,umode_t mode,struct dentry *parent,u32 *value);
lib/fault-inject.c +0 -21
@@ -182,27 +182,6 @@ static struct dentry *debugfs_create_stacktrace_depth(#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ -static int debugfs_atomic_t_set (void *data,u64 val) -{ -atomic_set ((atomic_t *)data, val); -return 0 ; -} - -static int debugfs_atomic_t_get (void *data,u64 *val) -{ - *val =atomic_read ((atomic_t *)data); -return 0 ; -} - -DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_t, debugfs_atomic_t_get, - debugfs_atomic_t_set,"%lld\n" ); - -static struct dentry *debugfs_create_atomic_t (const char *name,umode_t mode, -struct dentry *parent,atomic_t *value) -{ -return debugfs_create_file (name, mode, parent, value, &fops_atomic_t); -} -struct dentry *fault_create_debugfs_attr (const char *name,struct dentry *parent,struct fault_attr *attr) {
Signature · 1 line
1.7.9.5
PATCH v13 2/4 zbud: add to mm/
In reply to Seth Jenningszbud is an special purpose allocator for storing compressed pages. It is designed to store up to two compressed pages per physical page. While this design limits storage density, it has simple and deterministic reclaim properties that make it preferable to a higher density approach when reclaim will be used.
zbud works by storing compressed pages, or "zpages", together in pairs in a single memory page called a "zbud page". The first buddy is "left justifed" at the beginning of the zbud page, and the last buddy is "right justified" at the end of the zbud page. The benefit is that if either buddy is freed, the freed buddy space, coalesced with whatever slack space that existed between the buddies, results in the largest possible free region within the zbud page.
zbud also provides an attractive lower bound on density. The ratio of zpages to zbud pages can not be less than 1. This ensures that zbud can never "do harm" by using more pages to store zpages than the uncompressed zpages would have used on their own.
This implementation is a rewrite of the zbud allocator internally used by zcache in the driver/staging tree. The rewrite was necessary to remove some of the zcache specific elements that were ingrained throughout and provide a generic allocation interface that can later be used by zsmalloc and others.
This patch adds zbud to mm/ for later use by zswap.
--- include/linux/zbud.h | 22 +++ mm/Kconfig | 10 + mm/Makefile | 1 + mm/zbud.c | 526 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 include/linux/zbud.h create mode 100644 mm/zbud.c
include/linux/zbud.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _ZBUD_H_ +#define _ZBUD_H_ + +#include <linux/types.h> + +struct zbud_pool ; + +struct zbud_ops { +int (*evict)(struct zbud_pool *pool,unsigned long handle); +}; + +struct zbud_pool *zbud_create_pool (gfp_t gfp,struct zbud_ops *ops); +void zbud_destroy_pool (struct zbud_pool *pool); +int zbud_alloc (struct zbud_pool *pool,int size,gfp_t gfp, +unsigned long *handle); +void zbud_free (struct zbud_pool *pool,unsigned long handle); +int zbud_reclaim_page (struct zbud_pool *pool,unsigned int retries); +void *zbud_map (struct zbud_pool *pool,unsigned long handle); +void zbud_unmap (struct zbud_pool *pool,unsigned long handle); +u64 zbud_get_pool_size (struct zbud_pool *pool); + +#endif /* _ZBUD_H_ */
mm/Kconfig +10 -0
@@ -477,3 +477,13 @@ config FRONTSWAP and swap data is stored as normal on the matching swap device. If unsure, say Y to enable frontswap. + +config ZBUD + tristate + default n + help + A special purpose allocator for storing compressed pages. + It is designed to store up to two compressed pages per physical + page. While this design limits storage density, it has simple and + deterministic reclaim properties that make it preferable to a higher + density approach when reclaim will be used.
mm/Makefile +1 -0
@@ -58,3 +58,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_ZBUD) += zbud.o
mm/zbud.c new file +526 -0
526 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: [PATCHv13 2/4] zbud: add to mm/
Hi Seth,
Quoted 194 lines · Seth Jennings
zbud is an special purpose allocator for storing compressed pages. It is designed to store up to two compressed pages per physical page. While this design limits storage density, it has simple and deterministic reclaim properties that make it preferable to a higher density approach when reclaim will be used.
zbud works by storing compressed pages, or "zpages", together in pairs in a single memory page called a "zbud page". The first buddy is "left justifed" at the beginning of the zbud page, and the last buddy is "right justified" at the end of the zbud page. The benefit is that if either buddy is freed, the freed buddy space, coalesced with whatever slack space that existed between the buddies, results in the largest possible free region within the zbud page.
zbud also provides an attractive lower bound on density. The ratio of zpages to zbud pages can not be less than 1. This ensures that zbud can never "do harm" by using more pages to store zpages than the uncompressed zpages would have used on their own.
This implementation is a rewrite of the zbud allocator internally used by zcache in the driver/staging tree. The rewrite was necessary to remove some of the zcache specific elements that were ingrained throughout and provide a generic allocation interface that can later be used by zsmalloc and others.
This patch adds zbud to
mm/for later use by zswap.Signed-off-by Seth Jennings <[email protected]>Acked-by Rik van Riel <[email protected]>--- include/linux/zbud.h | 22 +++ mm/Kconfig | 10 + mm/Makefile | 1 + mm/zbud.c | 526 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 include/linux/zbud.h create mode 100644 mm/zbud.cinclude/linux/zbud.h new file +22
-0@@ -0,0 +1,22 @@ +#ifndef _ZBUD_H_ +#define _ZBUD_H_ + +#include <linux/types.h> + +struct zbud_pool ; + +struct zbud_ops { +int (*evict)(struct zbud_pool *pool,unsigned long handle); +}; + +struct zbud_pool *zbud_create_pool (gfp_t gfp,struct zbud_ops *ops); +void zbud_destroy_pool (struct zbud_pool *pool); +int zbud_alloc (struct zbud_pool *pool,int size,gfp_t gfp, +unsigned long *handle); +void zbud_free (struct zbud_pool *pool,unsigned long handle); +int zbud_reclaim_page (struct zbud_pool *pool,unsigned int retries); +void *zbud_map (struct zbud_pool *pool,unsigned long handle); +void zbud_unmap (struct zbud_pool *pool,unsigned long handle); +u64 zbud_get_pool_size (struct zbud_pool *pool); + +#endif /* _ZBUD_H_ */ mm/Kconfig +10
-0@@ -477,3 +477,13 @@ config FRONTSWAP and swap data is stored as normal on the matching swap device. If unsure, say Y to enable frontswap. + +config ZBUD + tristate + default n + help + A special purpose allocator for storing compressed pages. + It is designed to store up to two compressed pages per physical + page. While this design limits storage density, it has simple and + deterministic reclaim properties that make it preferable to a higher + density approach when reclaim will be used.mm/Makefile +1
-0@@ -58,3 +58,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_ZBUD) += zbud.omm/zbud.c new file +95
-0@@ -0,0 +1,526 @@ +/* +* zbud.c +* +* Copyright (C) 2013, Seth Jennings, IBM +* +* Concepts based on zcache internal zbud allocator by Dan Magenheimer. +* +* zbud is an special purpose allocator for storing compressed pages. Contrary +* to what its name may suggest, zbud is not a buddy allocator, but rather an +* allocator that "buddies" two compressed pages together in a single memory +* page. +* +* While this design limits storage density, it has simple and deterministic +* reclaim properties that make it preferable to a higher density approach when +* reclaim will be used. +* +* zbud works by storing compressed pages, or "zpages", together in pairs in a +* single memory page called a "zbud page". The first buddy is "left +* justifed" at the beginning of the zbud page, and the last buddy is "right +* justified" at the end of the zbud page. The benefit is that if either +* buddy is freed, the freed buddy space, coalesced with whatever slack space +* that existed between the buddies, results in the largest possible free region +* within the zbud page. +* +* zbud also provides an attractive lower bound on density. The ratio of zpages +* to zbud pages can not be less than 1. This ensures that zbud can never "do +* harm" by using more pages to store zpages than the uncompressed zpages would +* have used on their own. +* +* zbud pages are divided into "chunks". The size of the chunks is fixed at +* compile time and determined by NCHUNKS_ORDER below. Dividing zbud pages +* into chunks allows organizing unbuddied zbud pages into a manageable number +* of unbuddied lists according to the number of free chunks available in the +* zbud page. +* +* The zbud API differs from that of conventional allocators in that the +* allocation function, zbud_alloc(), returns an opaque handle to the user, +* not a dereferenceable pointer. The user must map the handle using +* zbud_map() in order to get a usable pointer by which to access the +* allocation data and unmap the handle with zbud_unmap() when operations +* on the allocation data are complete. +*/ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/atomic.h> +#include <linux/list.h> +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/preempt.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include <linux/zbud.h> + +/***************** +* Structures +*****************/ +/* +* NCHUNKS_ORDER determines the internal allocation granularity, effectively +* adjusting internal fragmentation. It also determines the number of +* freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the +* allocation granularity will be in chunks of size PAGE_SIZE/64, and there +* will be 64 freelists per pool. +*/ +#define NCHUNKS_ORDER 6 + +#define CHUNK_SHIFT (PAGE_SHIFT - NCHUNKS_ORDER) +#define CHUNK_SIZE (1 << CHUNK_SHIFT) +#define NCHUNKS (PAGE_SIZE >> CHUNK_SHIFT) +#define ZHDR_SIZE_ALIGNED CHUNK_SIZE + +/** +* struct zbud_pool - stores metadata for each zbud pool +* @lock: protects all pool fields and first|last_chunk fields of any +* zbud page in the pool +* @unbuddied: array of lists tracking zbud pages that only contain one buddy; +* the lists each zbud page is added to depends on the size of +* its free region. +* @buddied: list tracking the zbud pages that contain two buddies; +* these zbud pages are full +* @lru: list tracking the zbud pages in LRU order by most recently +* added buddy. +* @pages_nr: number of zbud pages in the pool. +* @ops: pointer to a structure of user defined operations specified at +* pool creation time. +* +* This structure is allocated at pool creation time and maintains metadata +* pertaining to a particular zbud pool. +*/ +struct zbud_pool { +spinlock_t lock; +struct list_head unbuddied[NCHUNKS ]; +struct list_head buddied; +struct list_head lru; +u64 pages_nr;
mm/zbud.c line 105
Quoted 10 lines
mm/zbud.c new file +10
-0+struct zbud_ops *ops; +}; + +/* +* struct zbud_header - zbud page metadata occupying the first chunk of each +* zbud page. +* @buddy: links the zbud page into the unbuddied/buddied lists in the pool +* @lru: links the zbud page into the lru list in the pool +* @first_chunks: the size of the first buddy in chunks, 0 if free +* @last_chunks: the size of the last buddy in chunks, 0 if free
Missing under_reclaim.
Quoted 164 lines
mm/zbud.c new file +164
-0+*/ +struct zbud_header { +struct list_head buddy; +struct list_head lru; +unsigned int first_chunks; +unsigned int last_chunks; +bool under_reclaim; +}; + +/***************** +* Helpers +*****************/ +/* Just to make the code easier to read */ +enum buddy { +FIRST , +LAST +}; + +/* Converts an allocation size in bytes to size in zbud chunks */ +static int size_to_chunks (int size) +{ +return (size +CHUNK_SIZE -1 ) >>CHUNK_SHIFT ; +} + +#define for_each_unbuddied_list (_iter, _begin) \ + for ((_iter) = (_begin); (_iter) < NCHUNKS; (_iter)++) + +/* Initializes the zbud header of a newly allocated zbud page */ +static struct zbud_header *init_zbud_page (struct page *page) +{ +struct zbud_header *zhdr =page_address (page); + zhdr->first_chunks =0 ; + zhdr->last_chunks =0 ; +INIT_LIST_HEAD (&zhdr->buddy); +INIT_LIST_HEAD (&zhdr->lru); +return zhdr; +} + +/* Resets the struct page fields and frees the page */ +static void free_zbud_page (struct zbud_header *zhdr) +{ +__free_page (virt_to_page (zhdr)); +} + +/* +* Encodes the handle of a particular buddy within a zbud page +* Pool lock should be held as this function accesses first|last_chunks +*/ +static unsigned long encode_handle (struct zbud_header *zhdr,enum buddy bud) +{ +unsigned long handle; + +/* +* For now, the encoded handle is actually just the pointer to the data +* but this might not always be the case. A little information hiding. +* Add CHUNK_SIZE to the handle if it is the first allocation to jump +* over the zbud header in the first chunk. +*/ + handle = (unsigned long )zhdr; +if (bud ==FIRST ) +/* skip over zbud header */ + handle +=ZHDR_SIZE_ALIGNED ; +else /* bud == LAST */ + handle +=PAGE_SIZE - (zhdr->last_chunks <<CHUNK_SHIFT ); +return handle; +} + +/* Returns the zbud page where a given handle is stored */ +static struct zbud_header *handle_to_zbud_header (unsigned long handle) +{ +return (struct zbud_header *)(handle &PAGE_MASK ); +} + +/* Returns the number of free chunks in a zbud page */ +static int num_free_chunks (struct zbud_header *zhdr) +{ +/* +* Rather than branch for different situations, just use the fact that +* free buddies have a length of zero to simplify everything. -1 at the +* end for the zbud header. +*/ +return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks -1 ; +} + +/***************** +* API Functions +*****************/ +/** +* zbud_create_pool() - create a new zbud pool +* @gfp: gfp flags when allocating the zbud pool structure +* @ops: user-defined operations for the zbud pool +* +* Return: pointer to the new zbud pool or NULL if the metadata allocation +* failed. +*/ +struct zbud_pool *zbud_create_pool (gfp_t gfp,struct zbud_ops *ops) +{ +struct zbud_pool *pool; +int i; + + pool =kmalloc (sizeof (struct zbud_pool ), gfp); +if (!pool) +return NULL ; +spin_lock_init (&pool->lock); +for_each_unbuddied_list (i,0 ) +INIT_LIST_HEAD (&pool->unbuddied[i]); +INIT_LIST_HEAD (&pool->buddied); +INIT_LIST_HEAD (&pool->lru); + pool->pages_nr =0 ; + pool->ops = ops; +return pool; +} + +/** +* zbud_destroy_pool() - destroys an existing zbud pool +* @pool: the zbud pool to be destroyed +* +* The pool should be emptied before this function is called. +*/ +void zbud_destroy_pool (struct zbud_pool *pool) +{ +kfree (pool); +} + +/** +* zbud_alloc() - allocates a region of a given size +* @pool: zbud pool from which to allocate +* @size: size in bytes of the desired allocation +* @gfp: gfp flags used if the pool needs to grow +* @handle: handle of the new allocation +* +* This function will attempt to find a free region in the pool large enough to +* satisfy the allocation request. A search of the unbuddied lists is +* performed first. If no suitable free region is found, then a new page is +* allocated and added to the pool to satisfy the request. +* +* gfp should not set __GFP_HIGHMEM as highmem pages cannot be used +* as zbud pool pages. +* +* Return: 0 if success and handle is set, otherwise -EINVAL is the size or +* gfp arguments are invalid or -ENOMEM if the pool was unable to allocate +* a new page. +*/ +int zbud_alloc (struct zbud_pool *pool,int size,gfp_t gfp, +unsigned long *handle) +{ +int chunks, i, freechunks; +struct zbud_header *zhdr =NULL ; +enum buddy bud; +struct page *page; + +if (size <=0 || gfp & __GFP_HIGHMEM) +return -EINVAL ; +if (size >PAGE_SIZE -ZHDR_SIZE_ALIGNED ) +return -ENOSPC ; + chunks =size_to_chunks (size); +spin_lock (&pool->lock); + +/* First, try to find an unbuddied zbud page. */ + zhdr =NULL ; +for_each_unbuddied_list (i, chunks) { +if (!list_empty (&pool->unbuddied[i])) { + zhdr =list_first_entry (&pool->unbuddied[i], + struct zbud_header, buddy);
mm/zbud.c line 279
Quoted 10 lines
mm/zbud.c new file +10
-0+list_del (&zhdr->buddy); +if (zhdr->first_chunks ==0 ) + bud =FIRST ; +else + bud =LAST ; + goto found; + } + } + +/* Couldn't find unbuddied zbud page, create new one */
How about moving zswap_is_full() to here.
if (zswap_is_full()) {
/* Don't alloc any new page, try to reclaim and direct use thereclaimed page instead */
}
Quoted 25 lines
mm/zbud.c new file +25
-0+spin_unlock (&pool->lock); + page =alloc_page (gfp); +if (!page) +return -ENOMEM ; +spin_lock (&pool->lock); + pool->pages_nr++; + zhdr =init_zbud_page (page); + bud =FIRST ; + +found: +if (bud ==FIRST ) + zhdr->first_chunks = chunks; +else + zhdr->last_chunks = chunks; + +if (zhdr->first_chunks ==0 || zhdr->last_chunks ==0 ) { +/* Add to unbuddied list */ + freechunks =num_free_chunks (zhdr); +list_add (&zhdr->buddy, &pool->unbuddied[freechunks]); + }else { +/* Add to buddied list */ +list_add (&zhdr->buddy, &pool->buddied); + } + +/* Add/move zbud page to beginning of LRU */
mm/zbud.c line 314
Quoted 10 lines
mm/zbud.c new file +10
-0+if (!list_empty (&zhdr->lru)) +list_del (&zhdr->lru); +list_add (&zhdr->lru, &pool->lru); + + *handle =encode_handle (zhdr, bud); +spin_unlock (&pool->lock); + +return 0 ; +} +
It looks good for me except two things.
One is about what the performance might be after the zswap pool is full. The other is still about the 20% limit of zswap pool size.
I need more time to test it.
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>
Re: [PATCHv13 2/4] zbud: add to mm/
Quoted 10 lines · Bob Liu
Hi Seth,
mm/zbud.c line 279
Quoted 1 line · Seth Jennings
mm/zbud.c new file +1
-0+/* Couldn't find unbuddied zbud page, create new one */ How about moving
zswap_is_full()to here.if (zswap_is_full()) { /* Don't alloc any new page, try to reclaim and direct use thereclaimed page instead */
Yes, this is at the top of the list for improvements.
I have already started on this work and it isn't quite as simple as it seems. The difficulty rises from the fact that, for now, zswap uses per-cpu compression buffers which require preemption to be disabled. This prevents the calling zbud_reclaim_page() in zbud_alloc() because the eviction handler for the user may do something that can wait; an allocation with GFP_WAIT for example.
So it's going to take some massaging in the zswap layer to get that to work.
It's very doable. Just not in this patchset without causing a lot of code thrash.
Quoted 10 lines
}
Quoted 8 lines
mm/zbud.c new file +8
-0+spin_unlock (&pool->lock); + page =alloc_page (gfp); +if (!page) +return -ENOMEM ; +spin_lock (&pool->lock); + pool->pages_nr++; + zhdr =init_zbud_page (page); + bud =FIRST ;
<snip>
Quoted 4 lines
It looks good for me except two things.
One is about what the performance might be after the zswap pool is full. The other is still about the 20% limit of zswap pool size.
Yep, working on both of them.
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>
PATCH v13 3/4 zswap: add to mm/
In reply to Seth Jenningszswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
This patch adds the zswap driver to mm/
--- mm/Kconfig | 20 ++ mm/Makefile | 1 + mm/zswap.c | 943 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 964 insertions(+) create mode 100644 mm/zswap.c
mm/Kconfig +20 -0
@@ -487,3 +487,23 @@ config ZBUD page. While this design limits storage density, it has simple and deterministic reclaim properties that make it preferable to a higher density approach when reclaim will be used. + +config ZSWAP + bool "Compressed cache for swap pages (EXPERIMENTAL)" + depends on FRONTSWAP && CRYPTO + select CRYPTO_LZO + select ZBUD + default n + help + A lightweight compressed cache for swap pages. It takes + pages that are in the process of being swapped out and attempts to + compress them into a dynamically allocated RAM-based memory pool. + This can result in a significant I/O reduction on swap device and, + in the case where decompressing from RAM is faster that swap device + reads, can also improve workload performance. + + This is marked experimental because it is a new feature (as of + v3.11) that interacts heavily with memory reclaim. While these + interactions don't cause any known issues on simple memory setups, + they have not be fully explored on the large set of potential + configurations and workloads that exist.
mm/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o obj-$(CONFIG_BOUNCE) += bounce.o obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o obj-$(CONFIG_FRONTSWAP) += frontswap.o +obj-$(CONFIG_ZSWAP) += zswap.o obj-$(CONFIG_HAS_DMA) += dmapool.o obj-$(CONFIG_HUGETLBFS) += hugetlb.o obj-$(CONFIG_NUMA) += mempolicy.o
mm/zswap.c new file +943 -0
943 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCHv13 3/4] zswap: add to mm/
Hi Seth,
Quoted 6 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
Quoted 8 lines
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
This patch adds the zswap driver to
mm/
Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
I found zswap will cause performance drop when using mmtests-0.10 to test it. The config file I'm using is: config-global-dhp__parallelio-memcachetest
The result is:
(v3.10-rc4-2G-nozswap was without zswap but the performance is better.)
v3.10-rc4 v3.10-rc4
2G-zswap-base 2G-nozswap
Ops memcachetest-0M 604.00 ( 0.00%) 1077.00 ( 78.31%)
Ops memcachetest-198M 630.00 ( 0.00%) 1007.00 ( 59.84%)
Ops memcachetest-430M 609.00 ( 0.00%) 939.00 ( 54.19%)
Ops memcachetest-661M 604.00 ( 0.00%) 845.00 ( 39.90%)
Ops memcachetest-893M 591.00 ( 0.00%) 839.00 ( 41.96%)
Ops memcachetest-1125M 599.00 ( 0.00%) 781.00 ( 30.38%)
Ops memcachetest-1356M 588.00 ( 0.00%) 771.00 ( 31.12%)
Ops io-duration-0M 0.00 ( 0.00%) 1.00 (-99.00%)
Ops io-duration-198M 177.00 ( 0.00%) 21.00 ( 88.14%)
Ops io-duration-430M 168.00 ( 0.00%) 25.00 ( 85.12%)
Ops io-duration-661M 214.00 ( 0.00%) 30.00 ( 85.98%)
Ops io-duration-893M 186.00 ( 0.00%) 32.00 ( 82.80%)
Ops io-duration-1125M 175.00 ( 0.00%) 42.00 ( 76.00%)
Ops io-duration-1356M 245.00 ( 0.00%) 51.00 ( 79.18%)
Ops swaptotal-0M 487760.00 ( 0.00%) 459754.00 ( 5.74%)
Ops swaptotal-198M 563581.00 ( 0.00%) 485194.00 ( 13.91%)
Ops swaptotal-430M 579472.00 ( 0.00%) 500817.00 ( 13.57%)
Ops swaptotal-661M 568086.00 ( 0.00%) 524209.00 ( 7.72%)
Ops swaptotal-893M 584405.00 ( 0.00%) 509846.00 ( 12.76%)
Ops swaptotal-1125M 572992.00 ( 0.00%) 534115.00 ( 6.78%)
Ops swaptotal-1356M 573259.00 ( 0.00%) 529814.00 ( 7.58%)
Ops swapin-0M 231250.00 ( 0.00%) 236069.00 ( -2.08%)
Ops swapin-198M 312259.00 ( 0.00%) 239149.00 ( 23.41%)
Ops swapin-430M 327178.00 ( 0.00%) 246803.00 ( 24.57%)
Ops swapin-661M 319575.00 ( 0.00%) 273644.00 ( 14.37%)
Ops swapin-893M 328195.00 ( 0.00%) 257327.00 ( 21.59%)
Ops swapin-1125M 317345.00 ( 0.00%) 271109.00 ( 14.57%)
Ops swapin-1356M 312858.00 ( 0.00%) 266050.00 ( 14.96%)
Ops minorfaults-0M 592150.00 ( 0.00%) 646076.00 ( -9.11%)
Ops minorfaults-198M 637339.00 ( 0.00%) 676441.00 ( -6.14%)
Ops minorfaults-430M 626228.00 ( 0.00%) 684715.00 ( -9.34%)
Ops minorfaults-661M 625089.00 ( 0.00%) 670639.00 ( -7.29%)
Ops minorfaults-893M 612877.00 ( 0.00%) 669723.00 ( -9.28%)
Ops minorfaults-1125M 624800.00 ( 0.00%) 667025.00 ( -6.76%)
Ops minorfaults-1356M 618800.00 ( 0.00%) 657600.00 ( -6.27%)
Ops majorfaults-0M 67664.00 ( 0.00%) 40060.00 ( 40.80%)
Ops majorfaults-198M 72377.00 ( 0.00%) 39517.00 ( 45.40%)
Ops majorfaults-430M 71822.00 ( 0.00%) 38895.00 ( 45.85%)
Ops majorfaults-661M 70009.00 ( 0.00%) 39625.00 ( 43.40%)
Ops majorfaults-893M 74988.00 ( 0.00%) 38073.00 ( 49.23%)
Ops majorfaults-1125M 72458.00 ( 0.00%) 38206.00 ( 47.27%)
Ops majorfaults-1356M 70549.00 ( 0.00%) 37430.00 ( 46.94%)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>
Andrew Morton
maintainerRe: [PATCHv13 3/4] zswap: add to mm/
Quoted 16 lines · On Mon, 17 Jun 2013 14:20:05 +0800 Bob Liu <[email protected]> wrote:
Hi Seth,
Quoted 12 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
Quoted 8 lines
Quoted 2 lines
This patch adds the zswap driver to
mm/Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
I found zswap will cause performance drop when using mmtests-0.10 to test it. The config file I'm using is: config-global-dhp__parallelio-memcachetest
Thanks for testing.
Quoted 39 lines
The result is:
(v3.10-rc4-2G-nozswap was without zswap but the performance is better.)v3.10-rc4 v3.10-rc4 2G-zswap-base 2G-nozswap Ops memcachetest-0M 604.00 ( 0.00%) 1077.00 ( 78.31%) Ops memcachetest-198M 630.00 ( 0.00%) 1007.00 ( 59.84%) Ops memcachetest-430M 609.00 ( 0.00%) 939.00 ( 54.19%) Ops memcachetest-661M 604.00 ( 0.00%) 845.00 ( 39.90%) Ops memcachetest-893M 591.00 ( 0.00%) 839.00 ( 41.96%) Ops memcachetest-1125M 599.00 ( 0.00%) 781.00 ( 30.38%) Ops memcachetest-1356M 588.00 ( 0.00%) 771.00 ( 31.12%) Ops io-duration-0M 0.00 ( 0.00%) 1.00 (-99.00%) Ops io-duration-198M 177.00 ( 0.00%) 21.00 ( 88.14%) Ops io-duration-430M 168.00 ( 0.00%) 25.00 ( 85.12%) Ops io-duration-661M 214.00 ( 0.00%) 30.00 ( 85.98%) Ops io-duration-893M 186.00 ( 0.00%) 32.00 ( 82.80%) Ops io-duration-1125M 175.00 ( 0.00%) 42.00 ( 76.00%) Ops io-duration-1356M 245.00 ( 0.00%) 51.00 ( 79.18%) Ops swaptotal-0M 487760.00 ( 0.00%) 459754.00 ( 5.74%) Ops swaptotal-198M 563581.00 ( 0.00%) 485194.00 ( 13.91%) Ops swaptotal-430M 579472.00 ( 0.00%) 500817.00 ( 13.57%) Ops swaptotal-661M 568086.00 ( 0.00%) 524209.00 ( 7.72%) Ops swaptotal-893M 584405.00 ( 0.00%) 509846.00 ( 12.76%) Ops swaptotal-1125M 572992.00 ( 0.00%) 534115.00 ( 6.78%) Ops swaptotal-1356M 573259.00 ( 0.00%) 529814.00 ( 7.58%) Ops swapin-0M 231250.00 ( 0.00%) 236069.00 ( -2.08%) Ops swapin-198M 312259.00 ( 0.00%) 239149.00 ( 23.41%) Ops swapin-430M 327178.00 ( 0.00%) 246803.00 ( 24.57%) Ops swapin-661M 319575.00 ( 0.00%) 273644.00 ( 14.37%) Ops swapin-893M 328195.00 ( 0.00%) 257327.00 ( 21.59%) Ops swapin-1125M 317345.00 ( 0.00%) 271109.00 ( 14.57%) Ops swapin-1356M 312858.00 ( 0.00%) 266050.00 ( 14.96%) Ops minorfaults-0M 592150.00 ( 0.00%) 646076.00 ( -9.11%) Ops minorfaults-198M 637339.00 ( 0.00%) 676441.00 ( -6.14%) Ops minorfaults-430M 626228.00 ( 0.00%) 684715.00 ( -9.34%) Ops minorfaults-661M 625089.00 ( 0.00%) 670639.00 ( -7.29%) Ops minorfaults-893M 612877.00 ( 0.00%) 669723.00 ( -9.28%) Ops minorfaults-1125M 624800.00 ( 0.00%) 667025.00 ( -6.76%)
Quoted 8 lines
Ops minorfaults-1356M 618800.00 ( 0.00%) 657600.00 ( -6.27%) Ops majorfaults-0M 67664.00 ( 0.00%) 40060.00 ( 40.80%) Ops majorfaults-198M 72377.00 ( 0.00%) 39517.00 ( 45.40%) Ops majorfaults-430M 71822.00 ( 0.00%) 38895.00 ( 45.85%) Ops majorfaults-661M 70009.00 ( 0.00%) 39625.00 ( 43.40%) Ops majorfaults-893M 74988.00 ( 0.00%) 38073.00 ( 49.23%) Ops majorfaults-1125M 72458.00 ( 0.00%) 38206.00 ( 47.27%) Ops majorfaults-1356M 70549.00 ( 0.00%) 37430.00 ( 46.94%)
So the minor fault rate improved and everything else got worse?
I'm not sure how representative this is of real workloads, but it does look rather fatal for zswap. The differences are so large, I wonder if it's just some silly bug or config issue.
--
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: [PATCHv13 3/4] zswap: add to mm/
Quoted 2 lines
So the minor fault rate improved and everything else got worse?
I did the test again, in a new clean environment. I'm sure the config files are the same except enabled zswap.
v3.10-rc4 v3.10-rc4
2G-parallio-zswapbas 2G-parallio-nozswap
Ops memcachetest-0M 819.00 ( 0.00%) 1041.00 ( 27.11%)
Ops memcachetest-198M 736.00 ( 0.00%) 973.00 ( 32.20%)
Ops memcachetest-430M 700.00 ( 0.00%) 892.00 ( 27.43%)
Ops memcachetest-661M 672.00 ( 0.00%) 819.00 ( 21.88%)
Ops memcachetest-893M 675.00 ( 0.00%) 775.00 ( 14.81%)
Ops memcachetest-1125M 665.00 ( 0.00%) 764.00 ( 14.89%)
Ops memcachetest-1356M 641.00 ( 0.00%) 749.00 ( 16.85%)
Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops io-duration-198M 111.00 ( 0.00%) 21.00 ( 81.08%)
Ops io-duration-430M 125.00 ( 0.00%) 29.00 ( 76.80%)
Ops io-duration-661M 153.00 ( 0.00%) 34.00 ( 77.78%)
Ops io-duration-893M 118.00 ( 0.00%) 36.00 ( 69.49%)
Ops io-duration-1125M 142.00 ( 0.00%) 43.00 ( 69.72%)
Ops io-duration-1356M 156.00 ( 0.00%) 50.00 ( 67.95%)
Ops swaptotal-0M 462237.00 ( 0.00%) 469193.00 ( -1.50%)
Ops swaptotal-198M 490462.00 ( 0.00%) 496201.00 ( -1.17%)
Ops swaptotal-430M 500469.00 ( 0.00%) 520400.00 ( -3.98%)
Ops swaptotal-661M 506038.00 ( 0.00%) 538872.00 ( -6.49%)
Ops swaptotal-893M 514930.00 ( 0.00%) 522590.00 ( -1.49%)
Ops swaptotal-1125M 521010.00 ( 0.00%) 526934.00 ( -1.14%)
Ops swaptotal-1356M 513128.00 ( 0.00%) 525241.00 ( -2.36%)
Ops swapin-0M 246425.00 ( 0.00%) 251226.00 ( -1.95%)
Ops swapin-198M 266446.00 ( 0.00%) 236126.00 ( 11.38%)
Ops swapin-430M 271586.00 ( 0.00%) 265193.00 ( 2.35%)
Ops swapin-661M 263404.00 ( 0.00%) 280281.00 ( -6.41%)
Ops swapin-893M 263958.00 ( 0.00%) 263004.00 ( 0.36%)
Ops swapin-1125M 276149.00 ( 0.00%) 261962.00 ( 5.14%)
Ops swapin-1356M 264214.00 ( 0.00%) 262571.00 ( 0.62%)
Ops minorfaults-0M 629965.00 ( 0.00%) 625759.00 ( 0.67%)
Ops minorfaults-198M 641320.00 ( 0.00%) 769752.00 (-20.03%)
Ops minorfaults-430M 635270.00 ( 0.00%) 678590.00 ( -6.82%)
Ops minorfaults-661M 625123.00 ( 0.00%) 669308.00 ( -7.07%)
Ops minorfaults-893M 625165.00 ( 0.00%) 656343.00 ( -4.99%)
Ops minorfaults-1125M 624358.00 ( 0.00%) 657954.00 ( -5.38%)
Ops minorfaults-1356M 619724.00 ( 0.00%) 672035.00 ( -8.44%)
Ops majorfaults-0M 57664.00 ( 0.00%) 39395.00 ( 31.68%)
Ops majorfaults-198M 59747.00 ( 0.00%) 38758.00 ( 35.13%)
Ops majorfaults-430M 63453.00 ( 0.00%) 39819.00 ( 37.25%)
Ops majorfaults-661M 61310.00 ( 0.00%) 40171.00 ( 34.48%)
Ops majorfaults-893M 62544.00 ( 0.00%) 37576.00 ( 39.92%)
Ops majorfaults-1125M 60866.00 ( 0.00%) 36891.00 ( 39.39%)
Ops majorfaults-1356M 66598.00 ( 0.00%) 37123.00 ( 44.26%)It shows clearly that swaptotal and minorfaults get improved a little if enabled zswap.
But with the cost that the performance of everything else dropped a lot.
--
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>
Re: [PATCHv13 3/4] zswap: add to mm/
In reply to Andrew MortonQuoted 5 lines
I'm not sure how representative this is of real workloads, but it does look rather fatal for zswap. The differences are so large, I wonder if it's just some silly bug or config issue.
In my observation, zswap_pool_pages always close to zswap_stored_pages in this testing.
I think it means that the fragmentation of zswap is heavy.
Since in idea state number of zswap pool pages should be half of stored pages.
The reason may be this workload is not suitable for compression. The data of it can't be compressed to a low percent.
It can only compressed to around 70% percent(not exactly but at least above 50%).
I made a simple patch to limit the fragment of zswap to 70%. The result can be better but still not positive.
v3.10-rc4 v3.10-rc4
2G-parallio-nozswap 2G-parallio-zswapdefrag
Ops memcachetest-0M 1041.00 ( 0.00%) 1058.00 ( 1.63%)
Ops memcachetest-198M 973.00 ( 0.00%) 1019.00 ( 4.73%)
Ops memcachetest-430M 892.00 ( 0.00%) 831.00 ( -6.84%)
Ops memcachetest-661M 819.00 ( 0.00%) 850.00 ( 3.79%)
Ops memcachetest-893M 775.00 ( 0.00%) 784.00 ( 1.16%)
Ops memcachetest-1125M 764.00 ( 0.00%) 766.00 ( 0.26%)
Ops memcachetest-1356M 749.00 ( 0.00%) 782.00 ( 4.41%)
Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops io-duration-198M 21.00 ( 0.00%) 28.00 (-33.33%)
Ops io-duration-430M 29.00 ( 0.00%) 32.00 (-10.34%)
Ops io-duration-661M 34.00 ( 0.00%) 34.00 ( 0.00%)
Ops io-duration-893M 36.00 ( 0.00%) 42.00 (-16.67%)
Ops io-duration-1125M 43.00 ( 0.00%) 47.00 ( -9.30%)
Ops io-duration-1356M 50.00 ( 0.00%) 49.00 ( 2.00%)
Ops swaptotal-0M 469193.00 ( 0.00%) 461146.00 ( 1.72%)
Ops swaptotal-198M 496201.00 ( 0.00%) 495692.00 ( 0.10%)
Ops swaptotal-430M 520400.00 ( 0.00%) 520252.00 ( 0.03%)
Ops swaptotal-661M 538872.00 ( 0.00%) 513541.00 ( 4.70%)
Ops swaptotal-893M 522590.00 ( 0.00%) 532311.00 ( -1.86%)
Ops swaptotal-1125M 526934.00 ( 0.00%) 527089.00 ( -0.03%)
Ops swaptotal-1356M 525241.00 ( 0.00%) 525747.00 ( -0.10%)
Ops swapin-0M 251226.00 ( 0.00%) 248426.00 ( 1.11%)
Ops swapin-198M 236126.00 ( 0.00%) 239031.00 ( -1.23%)
Ops swapin-430M 265193.00 ( 0.00%) 266174.00 ( -0.37%)
Ops swapin-661M 280281.00 ( 0.00%) 263151.00 ( 6.11%)
Ops swapin-893M 263004.00 ( 0.00%) 268473.00 ( -2.08%)
Ops swapin-1125M 261962.00 ( 0.00%) 264925.00 ( -1.13%)
Ops swapin-1356M 262571.00 ( 0.00%) 266695.00 ( -1.57%)
Ops minorfaults-0M 625759.00 ( 0.00%) 620448.00 ( 0.85%)
Ops minorfaults-198M 769752.00 ( 0.00%) 703458.00 ( 8.61%)
Ops minorfaults-430M 678590.00 ( 0.00%) 686257.00 ( -1.13%)
Ops minorfaults-661M 669308.00 ( 0.00%) 668845.00 ( 0.07%)
Ops minorfaults-893M 656343.00 ( 0.00%) 680286.00 ( -3.65%)
Ops minorfaults-1125M 657954.00 ( 0.00%) 655280.00 ( 0.41%)
Ops minorfaults-1356M 672035.00 ( 0.00%) 659861.00 ( 1.81%)
Ops majorfaults-0M 39395.00 ( 0.00%) 38828.00 ( 1.44%)
Ops majorfaults-198M 38758.00 ( 0.00%) 42876.00 (-10.62%)
Ops majorfaults-430M 39819.00 ( 0.00%) 38668.00 ( 2.89%)
Ops majorfaults-661M 40171.00 ( 0.00%) 38443.00 ( 4.30%)
Ops majorfaults-893M 37576.00 ( 0.00%) 37664.00 ( -0.23%)
Ops majorfaults-1125M 36891.00 ( 0.00%) 37527.00 ( -1.72%)
Ops majorfaults-1356M 37123.00 ( 0.00%) 37779.00 ( -1.77%)--
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>
Re: [PATCHv13 3/4] zswap: add to mm/
In reply to Bob LiuQuoted 16 lines · Bob Liu
Hi Seth,
Quoted 12 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
Quoted 5 lines
Quoted 2 lines
This patch adds the zswap driver to
mm/Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
The two I've done or kernbench and SPECjbb. I'm trying out the memtests now. I'd like to be able to explain the numbers you are seeing at least.
Sorry for the delay. I'll get back to you once I've figured out how to using mmtests and get some results/explanations.
Also, how much physical RAM did this box have? I see 2G in the profile name but not sure if that is the workload size or the RAM size. I seems that the test is overcommitted from the beginning as indicated by the swap activity. I know that the parallelio-memcachetest default profile only uses 80% of physical memory, so you have apparently made a change yes?
Seth
Quoted 52 lines
I found zswap will cause performance drop when using mmtests-0.10 to test it. The config file I'm using is: config-global-dhp__parallelio-memcachetest
The result is:
(v3.10-rc4-2G-nozswap was without zswap but the performance is better.)v3.10-rc4 v3.10-rc4 2G-zswap-base 2G-nozswap Ops memcachetest-0M 604.00 ( 0.00%) 1077.00 ( 78.31%) Ops memcachetest-198M 630.00 ( 0.00%) 1007.00 ( 59.84%) Ops memcachetest-430M 609.00 ( 0.00%) 939.00 ( 54.19%) Ops memcachetest-661M 604.00 ( 0.00%) 845.00 ( 39.90%) Ops memcachetest-893M 591.00 ( 0.00%) 839.00 ( 41.96%) Ops memcachetest-1125M 599.00 ( 0.00%) 781.00 ( 30.38%) Ops memcachetest-1356M 588.00 ( 0.00%) 771.00 ( 31.12%) Ops io-duration-0M 0.00 ( 0.00%) 1.00 (-99.00%) Ops io-duration-198M 177.00 ( 0.00%) 21.00 ( 88.14%) Ops io-duration-430M 168.00 ( 0.00%) 25.00 ( 85.12%) Ops io-duration-661M 214.00 ( 0.00%) 30.00 ( 85.98%) Ops io-duration-893M 186.00 ( 0.00%) 32.00 ( 82.80%) Ops io-duration-1125M 175.00 ( 0.00%) 42.00 ( 76.00%) Ops io-duration-1356M 245.00 ( 0.00%) 51.00 ( 79.18%) Ops swaptotal-0M 487760.00 ( 0.00%) 459754.00 ( 5.74%) Ops swaptotal-198M 563581.00 ( 0.00%) 485194.00 ( 13.91%) Ops swaptotal-430M 579472.00 ( 0.00%) 500817.00 ( 13.57%) Ops swaptotal-661M 568086.00 ( 0.00%) 524209.00 ( 7.72%) Ops swaptotal-893M 584405.00 ( 0.00%) 509846.00 ( 12.76%) Ops swaptotal-1125M 572992.00 ( 0.00%) 534115.00 ( 6.78%) Ops swaptotal-1356M 573259.00 ( 0.00%) 529814.00 ( 7.58%) Ops swapin-0M 231250.00 ( 0.00%) 236069.00 ( -2.08%) Ops swapin-198M 312259.00 ( 0.00%) 239149.00 ( 23.41%) Ops swapin-430M 327178.00 ( 0.00%) 246803.00 ( 24.57%) Ops swapin-661M 319575.00 ( 0.00%) 273644.00 ( 14.37%) Ops swapin-893M 328195.00 ( 0.00%) 257327.00 ( 21.59%) Ops swapin-1125M 317345.00 ( 0.00%) 271109.00 ( 14.57%) Ops swapin-1356M 312858.00 ( 0.00%) 266050.00 ( 14.96%) Ops minorfaults-0M 592150.00 ( 0.00%) 646076.00 ( -9.11%) Ops minorfaults-198M 637339.00 ( 0.00%) 676441.00 ( -6.14%) Ops minorfaults-430M 626228.00 ( 0.00%) 684715.00 ( -9.34%) Ops minorfaults-661M 625089.00 ( 0.00%) 670639.00 ( -7.29%) Ops minorfaults-893M 612877.00 ( 0.00%) 669723.00 ( -9.28%) Ops minorfaults-1125M 624800.00 ( 0.00%) 667025.00 ( -6.76%) Ops minorfaults-1356M 618800.00 ( 0.00%) 657600.00 ( -6.27%) Ops majorfaults-0M 67664.00 ( 0.00%) 40060.00 ( 40.80%) Ops majorfaults-198M 72377.00 ( 0.00%) 39517.00 ( 45.40%) Ops majorfaults-430M 71822.00 ( 0.00%) 38895.00 ( 45.85%) Ops majorfaults-661M 70009.00 ( 0.00%) 39625.00 ( 43.40%) Ops majorfaults-893M 74988.00 ( 0.00%) 38073.00 ( 49.23%) Ops majorfaults-1125M 72458.00 ( 0.00%) 38206.00 ( 47.27%) Ops majorfaults-1356M 70549.00 ( 0.00%) 37430.00 ( 46.94%)
Quoted 2 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>
Re: [PATCHv13 3/4] zswap: add to mm/
Quoted 17 lines · Seth Jennings
Quoted 16 lines · Bob Liu
Hi Seth,
Quoted 12 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This patch adds the zswap driver to
mm/Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
The two I've done or kernbench and SPECjbb. I'm trying out the memtests
Thanks, I'll try to setup them.
Quoted 7 lines
now. I'd like to be able to explain the numbers you are seeing at least.
Sorry for the delay. I'll get back to you once I've figured out how to using mmtests and get some results/explanations.
Also, how much physical RAM did this box have? I see 2G in the profile name but not sure if that is the workload size or the RAM size. I seems that the
2G RAM size.
Quoted 4 lines
test is overcommitted from the beginning as indicated by the swap activity. I know that the parallelio-memcachetest default profile only uses 80% of physical memory, so you have apparently made a change yes?
No, I just "cp configs/config-global-dhp__parallelio-memcachetest config" and then run mmtests.sh with monitor.
I'm using mmtests version 0.10.
--
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>
Re: [PATCHv13 3/4] zswap: add to mm/
In reply to Bob LiuQuoted 64 lines · Bob Liu
Hi Seth,
Quoted 6 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
Quoted 8 lines
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
This patch adds the zswap driver to
mm/Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
I found zswap will cause performance drop when using mmtests-0.10 to test it. The config file I'm using is: config-global-dhp__parallelio-memcachetest
The result is:
(v3.10-rc4-2G-nozswap was without zswap but the performance is better.)v3.10-rc4 v3.10-rc4 2G-zswap-base 2G-nozswap Ops memcachetest-0M 604.00 ( 0.00%) 1077.00 ( 78.31%) Ops memcachetest-198M 630.00 ( 0.00%) 1007.00 ( 59.84%) Ops memcachetest-430M 609.00 ( 0.00%) 939.00 ( 54.19%) Ops memcachetest-661M 604.00 ( 0.00%) 845.00 ( 39.90%) Ops memcachetest-893M 591.00 ( 0.00%) 839.00 ( 41.96%) Ops memcachetest-1125M 599.00 ( 0.00%) 781.00 ( 30.38%) Ops memcachetest-1356M 588.00 ( 0.00%) 771.00 ( 31.12%) Ops io-duration-0M 0.00 ( 0.00%) 1.00 (-99.00%) Ops io-duration-198M 177.00 ( 0.00%) 21.00 ( 88.14%) Ops io-duration-430M 168.00 ( 0.00%) 25.00 ( 85.12%) Ops io-duration-661M 214.00 ( 0.00%) 30.00 ( 85.98%) Ops io-duration-893M 186.00 ( 0.00%) 32.00 ( 82.80%) Ops io-duration-1125M 175.00 ( 0.00%) 42.00 ( 76.00%) Ops io-duration-1356M 245.00 ( 0.00%) 51.00 ( 79.18%) Ops swaptotal-0M 487760.00 ( 0.00%) 459754.00 ( 5.74%) Ops swaptotal-198M 563581.00 ( 0.00%) 485194.00 ( 13.91%) Ops swaptotal-430M 579472.00 ( 0.00%) 500817.00 ( 13.57%) Ops swaptotal-661M 568086.00 ( 0.00%) 524209.00 ( 7.72%) Ops swaptotal-893M 584405.00 ( 0.00%) 509846.00 ( 12.76%) Ops swaptotal-1125M 572992.00 ( 0.00%) 534115.00 ( 6.78%) Ops swaptotal-1356M 573259.00 ( 0.00%) 529814.00 ( 7.58%) Ops swapin-0M 231250.00 ( 0.00%) 236069.00 ( -2.08%) Ops swapin-198M 312259.00 ( 0.00%) 239149.00 ( 23.41%) Ops swapin-430M 327178.00 ( 0.00%) 246803.00 ( 24.57%) Ops swapin-661M 319575.00 ( 0.00%) 273644.00 ( 14.37%) Ops swapin-893M 328195.00 ( 0.00%) 257327.00 ( 21.59%) Ops swapin-1125M 317345.00 ( 0.00%) 271109.00 ( 14.57%) Ops swapin-1356M 312858.00 ( 0.00%) 266050.00 ( 14.96%) Ops minorfaults-0M 592150.00 ( 0.00%) 646076.00 ( -9.11%) Ops minorfaults-198M 637339.00 ( 0.00%) 676441.00 ( -6.14%) Ops minorfaults-430M 626228.00 ( 0.00%) 684715.00 ( -9.34%) Ops minorfaults-661M 625089.00 ( 0.00%) 670639.00 ( -7.29%) Ops minorfaults-893M 612877.00 ( 0.00%) 669723.00 ( -9.28%) Ops minorfaults-1125M 624800.00 ( 0.00%) 667025.00 ( -6.76%)
Quoted 8 lines
Ops minorfaults-1356M 618800.00 ( 0.00%) 657600.00 ( -6.27%) Ops majorfaults-0M 67664.00 ( 0.00%) 40060.00 ( 40.80%) Ops majorfaults-198M 72377.00 ( 0.00%) 39517.00 ( 45.40%) Ops majorfaults-430M 71822.00 ( 0.00%) 38895.00 ( 45.85%) Ops majorfaults-661M 70009.00 ( 0.00%) 39625.00 ( 43.40%) Ops majorfaults-893M 74988.00 ( 0.00%) 38073.00 ( 49.23%) Ops majorfaults-1125M 72458.00 ( 0.00%) 38206.00 ( 47.27%) Ops majorfaults-1356M 70549.00 ( 0.00%) 37430.00 ( 46.94%)
Just made a mmtests run of my own and got very different results:
parallelio-memcachetest
v3.10-rc6 v3.10-rc6
base zswap
Ops memcachetest-0M 7815.00 ( 0.00%) 7843.00 ( 0.36%)
Ops memcachetest-596M 12116.00 ( 0.00%) 12158.00 ( 0.35%)
Ops memcachetest-1989M 2226.00 ( 0.00%) 5314.00 (138.72%)
Ops memcachetest-3382M 1910.00 ( 0.00%) 4427.00 (131.78%)
Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops io-duration-596M 18.00 ( 0.00%) 12.00 ( 33.33%)
Ops io-duration-1989M 82.00 ( 0.00%) 57.00 ( 30.49%)
Ops io-duration-3382M 91.00 ( 0.00%) 94.00 ( -3.30%)
Ops swaptotal-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops swaptotal-596M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops swaptotal-1989M 305182.00 ( 0.00%) 91508.00 ( 70.02%)
Ops swaptotal-3382M 353389.00 ( 0.00%) 74932.00 ( 78.80%)
Ops swapin-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops swapin-596M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops swapin-1989M 131071.00 ( 0.00%) 45657.00 ( 65.17%)
Ops swapin-3382M 135003.00 ( 0.00%) 37245.00 ( 72.41%)
Ops minorfaults-0M 1201113.00 ( 0.00%) 1201229.00 ( -0.01%)
Ops minorfaults-596M 1218437.00 ( 0.00%) 1218824.00 ( -0.03%)
Ops minorfaults-1989M 1260652.00 ( 0.00%) 1270762.00 ( -0.80%)
Ops minorfaults-3382M 1251389.00 ( 0.00%) 1248756.00 ( 0.21%)
Ops majorfaults-0M 0.00 ( 0.00%) 0.00 ( 0.00%)
Ops majorfaults-596M 34.00 ( 0.00%) 0.00 ( 0.00%)
Ops majorfaults-1989M 16561.00 ( 0.00%) 7789.00 ( 52.97%)
Ops majorfaults-3382M 17031.00 ( 0.00%) 6372.00 ( 62.59%)Basically the results show that once swapping starts (which happens even in the 0MB case in your results which is puzzling), zswap reduces swapins by around 70% (and as a result swaptotal and majorfaults) and increases memcached throughput by over 130% compared to the normal swapping case w/o zswap.
This test illustrates a great use case for zswap. The test is really designed to detect suboptimal page reclaim decisions. Ideally the memcached pages would never reach the end of the inactive LRU and be swapped out. However, since there is a lot of I/O going on, if a memcached page does get put on the inactive list, it can quickly move to the end. In this case, zswap catches the page and memcached has a chance to fault it back in from the compressed cache before actual swapping to disk occurs.
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>
Re: [PATCHv13 3/4] zswap: add to mm/
Quoted 74 lines · Seth Jennings
Quoted 64 lines · Bob Liu
Hi Seth,
Quoted 6 lines · Seth Jennings
zswap is a thin backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress them and store them in a RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster than reading from the swap device, can also improve workload performance.
Quoted 8 lines
It also has support for evicting swap pages that are currently compressed in zswap to the swap device on an LRU(ish) basis. This functionality makes zswap a true cache in that, once the cache is full, the oldest pages can be moved out of zswap to the swap device so newer pages can be compressed and stored in zswap.
This patch adds the zswap driver to
mm/Do you have any more benchmark can share with me ? To figure out that we can benefit from zswap.
I found zswap will cause performance drop when using mmtests-0.10 to test it. The config file I'm using is: config-global-dhp__parallelio-memcachetest
The result is:
(v3.10-rc4-2G-nozswap was without zswap but the performance is better.)v3.10-rc4 v3.10-rc4 2G-zswap-base 2G-nozswap Ops memcachetest-0M 604.00 ( 0.00%) 1077.00 ( 78.31%) Ops memcachetest-198M 630.00 ( 0.00%) 1007.00 ( 59.84%) Ops memcachetest-430M 609.00 ( 0.00%) 939.00 ( 54.19%) Ops memcachetest-661M 604.00 ( 0.00%) 845.00 ( 39.90%) Ops memcachetest-893M 591.00 ( 0.00%) 839.00 ( 41.96%) Ops memcachetest-1125M 599.00 ( 0.00%) 781.00 ( 30.38%) Ops memcachetest-1356M 588.00 ( 0.00%) 771.00 ( 31.12%) Ops io-duration-0M 0.00 ( 0.00%) 1.00 (-99.00%) Ops io-duration-198M 177.00 ( 0.00%) 21.00 ( 88.14%) Ops io-duration-430M 168.00 ( 0.00%) 25.00 ( 85.12%) Ops io-duration-661M 214.00 ( 0.00%) 30.00 ( 85.98%) Ops io-duration-893M 186.00 ( 0.00%) 32.00 ( 82.80%) Ops io-duration-1125M 175.00 ( 0.00%) 42.00 ( 76.00%) Ops io-duration-1356M 245.00 ( 0.00%) 51.00 ( 79.18%) Ops swaptotal-0M 487760.00 ( 0.00%) 459754.00 ( 5.74%) Ops swaptotal-198M 563581.00 ( 0.00%) 485194.00 ( 13.91%) Ops swaptotal-430M 579472.00 ( 0.00%) 500817.00 ( 13.57%) Ops swaptotal-661M 568086.00 ( 0.00%) 524209.00 ( 7.72%) Ops swaptotal-893M 584405.00 ( 0.00%) 509846.00 ( 12.76%) Ops swaptotal-1125M 572992.00 ( 0.00%) 534115.00 ( 6.78%) Ops swaptotal-1356M 573259.00 ( 0.00%) 529814.00 ( 7.58%) Ops swapin-0M 231250.00 ( 0.00%) 236069.00 ( -2.08%) Ops swapin-198M 312259.00 ( 0.00%) 239149.00 ( 23.41%) Ops swapin-430M 327178.00 ( 0.00%) 246803.00 ( 24.57%) Ops swapin-661M 319575.00 ( 0.00%) 273644.00 ( 14.37%) Ops swapin-893M 328195.00 ( 0.00%) 257327.00 ( 21.59%) Ops swapin-1125M 317345.00 ( 0.00%) 271109.00 ( 14.57%) Ops swapin-1356M 312858.00 ( 0.00%) 266050.00 ( 14.96%) Ops minorfaults-0M 592150.00 ( 0.00%) 646076.00 ( -9.11%) Ops minorfaults-198M 637339.00 ( 0.00%) 676441.00 ( -6.14%) Ops minorfaults-430M 626228.00 ( 0.00%) 684715.00 ( -9.34%) Ops minorfaults-661M 625089.00 ( 0.00%) 670639.00 ( -7.29%) Ops minorfaults-893M 612877.00 ( 0.00%) 669723.00 ( -9.28%) Ops minorfaults-1125M 624800.00 ( 0.00%) 667025.00 ( -6.76%)Quoted 8 lines
Ops minorfaults-1356M 618800.00 ( 0.00%) 657600.00 ( -6.27%) Ops majorfaults-0M 67664.00 ( 0.00%) 40060.00 ( 40.80%) Ops majorfaults-198M 72377.00 ( 0.00%) 39517.00 ( 45.40%) Ops majorfaults-430M 71822.00 ( 0.00%) 38895.00 ( 45.85%) Ops majorfaults-661M 70009.00 ( 0.00%) 39625.00 ( 43.40%) Ops majorfaults-893M 74988.00 ( 0.00%) 38073.00 ( 49.23%) Ops majorfaults-1125M 72458.00 ( 0.00%) 38206.00 ( 47.27%) Ops majorfaults-1356M 70549.00 ( 0.00%) 37430.00 ( 46.94%)
Quoted 2 lines
Just made a mmtests run of my own and got very different results:
It's strange, I'll update to rc6 and try again.
By the way, are you using 824 hardware compressor instead of lzo?
Quoted 41 lines
parallelio-memcachetest
v3.10-rc6 v3.10-rc6 base zswap Ops memcachetest-0M 7815.00 ( 0.00%) 7843.00 ( 0.36%) Ops memcachetest-596M 12116.00 ( 0.00%) 12158.00 ( 0.35%) Ops memcachetest-1989M 2226.00 ( 0.00%) 5314.00 (138.72%) Ops memcachetest-3382M 1910.00 ( 0.00%) 4427.00 (131.78%) Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops io-duration-596M 18.00 ( 0.00%) 12.00 ( 33.33%) Ops io-duration-1989M 82.00 ( 0.00%) 57.00 ( 30.49%) Ops io-duration-3382M 91.00 ( 0.00%) 94.00 ( -3.30%) Ops swaptotal-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops swaptotal-596M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops swaptotal-1989M 305182.00 ( 0.00%) 91508.00 ( 70.02%) Ops swaptotal-3382M 353389.00 ( 0.00%) 74932.00 ( 78.80%) Ops swapin-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops swapin-596M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops swapin-1989M 131071.00 ( 0.00%) 45657.00 ( 65.17%) Ops swapin-3382M 135003.00 ( 0.00%) 37245.00 ( 72.41%) Ops minorfaults-0M 1201113.00 ( 0.00%) 1201229.00 ( -0.01%) Ops minorfaults-596M 1218437.00 ( 0.00%) 1218824.00 ( -0.03%) Ops minorfaults-1989M 1260652.00 ( 0.00%) 1270762.00 ( -0.80%) Ops minorfaults-3382M 1251389.00 ( 0.00%) 1248756.00 ( 0.21%) Ops majorfaults-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops majorfaults-596M 34.00 ( 0.00%) 0.00 ( 0.00%) Ops majorfaults-1989M 16561.00 ( 0.00%) 7789.00 ( 52.97%) Ops majorfaults-3382M 17031.00 ( 0.00%) 6372.00 ( 62.59%)Basically the results show that once swapping starts (which happens even in the 0MB case in your results which is puzzling), zswap reduces swapins by around 70% (and as a result swaptotal and majorfaults) and increases memcached throughput by over 130% compared to the normal swapping case w/o zswap.
This test illustrates a great use case for zswap. The test is really designed to detect suboptimal page reclaim decisions. Ideally the memcached pages would never reach the end of the inactive LRU and be swapped out. However, since there is a lot of I/O going on, if a memcached page does get put on the inactive list, it can quickly move to the end. In this case, zswap catches the page and memcached has a chance to fault it back in from the compressed cache before actual swapping to disk occurs.
Quoted 2 lines
Seth
--
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>
Re: [PATCHv13 3/4] zswap: add to mm/
Quoted 5 lines · Bob Liu
Quoted 2 lines
Just made a mmtests run of my own and got very different results:
It's strange, I'll update to rc6 and try again.
By the way, are you using 824 hardware compressor instead of lzo?
My results where using lzo software compression.
Seth
Re: [PATCHv13 3/4] zswap: add to mm/
Quoted 9 lines · Seth Jennings
Quoted 5 lines · Bob Liu
Quoted 2 lines
Just made a mmtests run of my own and got very different results:
It's strange, I'll update to rc6 and try again.
By the way, are you using 824 hardware compressor instead of lzo?My results where using lzo software compression.
Thanks, and today I used another machine to test zswap. The total ram size of that machine is around 4G. This time the result is better:
rc6 rc6
zswap base
Ops memcachetest-0M 14619.00 ( 0.00%) 15602.00 ( 6.72%) Ops memcachetest-435M 14727.00 ( 0.00%) 15860.00 ( 7.69%) Ops memcachetest-944M 12452.00 ( 0.00%) 11812.00 ( -5.14%) Ops memcachetest-1452M 12183.00 ( 0.00%) 9829.00 (-19.32%) Ops memcachetest-1961M 11953.00 ( 0.00%) 9337.00 (-21.89%) Ops memcachetest-2469M 11201.00 ( 0.00%) 7509.00 (-32.96%) Ops memcachetest-2978M 9738.00 ( 0.00%) 5981.00 (-38.58%) Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops io-duration-435M 10.00 ( 0.00%) 6.00 ( 40.00%) Ops io-duration-944M 19.00 ( 0.00%) 19.00 ( 0.00%) Ops io-duration-1452M 31.00 ( 0.00%) 26.00 ( 16.13%) Ops io-duration-1961M 40.00 ( 0.00%) 35.00 ( 12.50%) Ops io-duration-2469M 45.00 ( 0.00%) 43.00 ( 4.44%) Ops io-duration-2978M 58.00 ( 0.00%) 53.00 ( 8.62%) Ops swaptotal-0M 56711.00 ( 0.00%) 8.00 ( 99.99%) Ops swaptotal-435M 19218.00 ( 0.00%) 2101.00 ( 89.07%) Ops swaptotal-944M 53233.00 ( 0.00%) 98055.00 (-84.20%) Ops swaptotal-1452M 52064.00 ( 0.00%) 145624.00 (-179.70%) Ops swaptotal-1961M 54960.00 ( 0.00%) 153907.00 (-180.03%) Ops swaptotal-2469M 57485.00 ( 0.00%) 176340.00 (-206.76%) Ops swaptotal-2978M 77704.00 ( 0.00%) 182996.00 (-135.50%) Ops swapin-0M 24834.00 ( 0.00%) 8.00 ( 99.97%) Ops swapin-435M 9038.00 ( 0.00%) 0.00 ( 0.00%) Ops swapin-944M 26230.00 ( 0.00%) 42953.00 (-63.76%) Ops swapin-1452M 25766.00 ( 0.00%) 68440.00 (-165.62%) Ops swapin-1961M 27258.00 ( 0.00%) 68129.00 (-149.94%) Ops swapin-2469M 28508.00 ( 0.00%) 82234.00 (-188.46%) Ops swapin-2978M 37970.00 ( 0.00%) 89280.00 (-135.13%) Ops minorfaults-0M 1460163.00 ( 0.00%) 927966.00 ( 36.45%) Ops minorfaults-435M 954058.00 ( 0.00%) 936182.00 ( 1.87%) Ops minorfaults-944M 972818.00 ( 0.00%) 1005956.00 ( -3.41%) Ops minorfaults-1452M 966597.00 ( 0.00%) 1035465.00 ( -7.12%) Ops minorfaults-1961M 976158.00 ( 0.00%) 1049441.00 ( -7.51%) Ops minorfaults-2469M 967815.00 ( 0.00%) 1051752.00 ( -8.67%) Ops minorfaults-2978M 988712.00 ( 0.00%) 1034615.00 ( -4.64%) Ops majorfaults-0M 5899.00 ( 0.00%) 9.00 ( 99.85%) Ops majorfaults-435M 2684.00 ( 0.00%) 67.00 ( 97.50%) Ops majorfaults-944M 4380.00 ( 0.00%) 5790.00 (-32.19%) Ops majorfaults-1452M 4161.00 ( 0.00%) 9222.00 (-121.63%) Ops majorfaults-1961M 4435.00 ( 0.00%) 8800.00 (-98.42%) Ops majorfaults-2469M 4555.00 ( 0.00%) 10541.00 (-131.42%) Ops majorfaults-2978M 6182.00 ( 0.00%) 11618.00 (-87.93%)
But the performance of the first machine I used whose total ram size is 2G is still bad.
I need more time to summarize those testing results.
Maybe you can also have a try with lower total ram size.
--
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>
RE: [PATCHv13 3/4] zswap: add to mm/
Quoted 1 line
From: Bob Liu [mailto:[email protected]]
Subject: Re: [PATCHv13 3/4] zswap: add to mm/
Quoted 66 lines
Quoted 9 lines · Seth Jennings
Quoted 5 lines · Bob Liu
Quoted 2 lines
Just made a mmtests run of my own and got very different results:
It's strange, I'll update to rc6 and try again.
By the way, are you using 824 hardware compressor instead of lzo?My results where using lzo software compression.
Thanks, and today I used another machine to test zswap. The total ram size of that machine is around 4G. This time the result is better:
rc6 rc6
zswap baseOps memcachetest-0M 14619.00 ( 0.00%) 15602.00 ( 6.72%) Ops memcachetest-435M 14727.00 ( 0.00%) 15860.00 ( 7.69%) Ops memcachetest-944M 12452.00 ( 0.00%) 11812.00 ( -5.14%) Ops memcachetest-1452M 12183.00 ( 0.00%) 9829.00 (-19.32%) Ops memcachetest-1961M 11953.00 ( 0.00%) 9337.00 (-21.89%) Ops memcachetest-2469M 11201.00 ( 0.00%) 7509.00 (-32.96%) Ops memcachetest-2978M 9738.00 ( 0.00%) 5981.00 (-38.58%) Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops io-duration-435M 10.00 ( 0.00%) 6.00 ( 40.00%) Ops io-duration-944M 19.00 ( 0.00%) 19.00 ( 0.00%) Ops io-duration-1452M 31.00 ( 0.00%) 26.00 ( 16.13%) Ops io-duration-1961M 40.00 ( 0.00%) 35.00 ( 12.50%) Ops io-duration-2469M 45.00 ( 0.00%) 43.00 ( 4.44%) Ops io-duration-2978M 58.00 ( 0.00%) 53.00 ( 8.62%) Ops swaptotal-0M 56711.00 ( 0.00%) 8.00 ( 99.99%) Ops swaptotal-435M 19218.00 ( 0.00%) 2101.00 ( 89.07%) Ops swaptotal-944M 53233.00 ( 0.00%) 98055.00 (-84.20%) Ops swaptotal-1452M 52064.00 ( 0.00%) 145624.00 (-179.70%) Ops swaptotal-1961M 54960.00 ( 0.00%) 153907.00 (-180.03%) Ops swaptotal-2469M 57485.00 ( 0.00%) 176340.00 (-206.76%) Ops swaptotal-2978M 77704.00 ( 0.00%) 182996.00 (-135.50%) Ops swapin-0M 24834.00 ( 0.00%) 8.00 ( 99.97%) Ops swapin-435M 9038.00 ( 0.00%) 0.00 ( 0.00%) Ops swapin-944M 26230.00 ( 0.00%) 42953.00 (-63.76%) Ops swapin-1452M 25766.00 ( 0.00%) 68440.00 (-165.62%) Ops swapin-1961M 27258.00 ( 0.00%) 68129.00 (-149.94%) Ops swapin-2469M 28508.00 ( 0.00%) 82234.00 (-188.46%) Ops swapin-2978M 37970.00 ( 0.00%) 89280.00 (-135.13%) Ops minorfaults-0M 1460163.00 ( 0.00%) 927966.00 ( 36.45%) Ops minorfaults-435M 954058.00 ( 0.00%) 936182.00 ( 1.87%) Ops minorfaults-944M 972818.00 ( 0.00%) 1005956.00 ( -3.41%) Ops minorfaults-1452M 966597.00 ( 0.00%) 1035465.00 ( -7.12%) Ops minorfaults-1961M 976158.00 ( 0.00%) 1049441.00 ( -7.51%) Ops minorfaults-2469M 967815.00 ( 0.00%) 1051752.00 ( -8.67%) Ops minorfaults-2978M 988712.00 ( 0.00%) 1034615.00 ( -4.64%) Ops majorfaults-0M 5899.00 ( 0.00%) 9.00 ( 99.85%) Ops majorfaults-435M 2684.00 ( 0.00%) 67.00 ( 97.50%) Ops majorfaults-944M 4380.00 ( 0.00%) 5790.00 (-32.19%) Ops majorfaults-1452M 4161.00 ( 0.00%) 9222.00 (-121.63%) Ops majorfaults-1961M 4435.00 ( 0.00%) 8800.00 (-98.42%) Ops majorfaults-2469M 4555.00 ( 0.00%) 10541.00 (-131.42%) Ops majorfaults-2978M 6182.00 ( 0.00%) 11618.00 (-87.93%)But the performance of the first machine I used whose total ram size is 2G is still bad.
I need more time to summarize those testing results.
Quoted 5 lines
Maybe you can also have a try with lower total ram size.
--
Regards,
--Bob
A very important factor that you are not considering and that might account for your different results is the "initial conditions". For example, I always ran my benchmarks after a default-configured EL6 boot, which launches many services at boot time, each of which creates many anonymous pages, and these "service anonymous pages" are often the pages that are selected by LRU for swapping, and compressed by zcache/zswap. Someone else may run the benchmarks on a minimally-configured embedded system, and someone else on a single-user system with no services running at all. A single-user system with no services is often best for reproducing benchmark results but may not be at all representative of the real world.
At a minimum, it would be good to always record "Active(anon)" and "Inactive(anon)" in addition to the amount of physical RAM in the system. (Note, in /proc/meminfo on my system, the sum of these don't add up to "AnonPages"... I'm not sure why.)
And of course, even if the number of anonymous pages is the same, the _contents_ of those pages may be very different, which will affect zcache/zswap density which may have a large impact on benchmark results.
Thanks,
Dan (T-minus two weeks and counting)
--
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: [PATCHv13 3/4] zswap: add to mm/
Quoted 75 lines · Dan Magenheimer
Quoted 1 line
From: Bob Liu [mailto:[email protected]]
Subject: Re: [PATCHv13 3/4] zswap: add to
mm/Quoted 66 lines
Quoted 9 lines · Seth Jennings
Quoted 5 lines · Bob Liu
Quoted 2 lines
Just made a mmtests run of my own and got very different results:
It's strange, I'll update to rc6 and try again.
By the way, are you using 824 hardware compressor instead of lzo?My results where using lzo software compression.
Thanks, and today I used another machine to test zswap. The total ram size of that machine is around 4G. This time the result is better:
rc6 rc6
zswap baseOps memcachetest-0M 14619.00 ( 0.00%) 15602.00 ( 6.72%) Ops memcachetest-435M 14727.00 ( 0.00%) 15860.00 ( 7.69%) Ops memcachetest-944M 12452.00 ( 0.00%) 11812.00 ( -5.14%) Ops memcachetest-1452M 12183.00 ( 0.00%) 9829.00 (-19.32%) Ops memcachetest-1961M 11953.00 ( 0.00%) 9337.00 (-21.89%) Ops memcachetest-2469M 11201.00 ( 0.00%) 7509.00 (-32.96%) Ops memcachetest-2978M 9738.00 ( 0.00%) 5981.00 (-38.58%) Ops io-duration-0M 0.00 ( 0.00%) 0.00 ( 0.00%) Ops io-duration-435M 10.00 ( 0.00%) 6.00 ( 40.00%) Ops io-duration-944M 19.00 ( 0.00%) 19.00 ( 0.00%) Ops io-duration-1452M 31.00 ( 0.00%) 26.00 ( 16.13%) Ops io-duration-1961M 40.00 ( 0.00%) 35.00 ( 12.50%) Ops io-duration-2469M 45.00 ( 0.00%) 43.00 ( 4.44%) Ops io-duration-2978M 58.00 ( 0.00%) 53.00 ( 8.62%) Ops swaptotal-0M 56711.00 ( 0.00%) 8.00 ( 99.99%) Ops swaptotal-435M 19218.00 ( 0.00%) 2101.00 ( 89.07%) Ops swaptotal-944M 53233.00 ( 0.00%) 98055.00 (-84.20%) Ops swaptotal-1452M 52064.00 ( 0.00%) 145624.00 (-179.70%) Ops swaptotal-1961M 54960.00 ( 0.00%) 153907.00 (-180.03%) Ops swaptotal-2469M 57485.00 ( 0.00%) 176340.00 (-206.76%) Ops swaptotal-2978M 77704.00 ( 0.00%) 182996.00 (-135.50%) Ops swapin-0M 24834.00 ( 0.00%) 8.00 ( 99.97%) Ops swapin-435M 9038.00 ( 0.00%) 0.00 ( 0.00%) Ops swapin-944M 26230.00 ( 0.00%) 42953.00 (-63.76%) Ops swapin-1452M 25766.00 ( 0.00%) 68440.00 (-165.62%) Ops swapin-1961M 27258.00 ( 0.00%) 68129.00 (-149.94%) Ops swapin-2469M 28508.00 ( 0.00%) 82234.00 (-188.46%) Ops swapin-2978M 37970.00 ( 0.00%) 89280.00 (-135.13%) Ops minorfaults-0M 1460163.00 ( 0.00%) 927966.00 ( 36.45%) Ops minorfaults-435M 954058.00 ( 0.00%) 936182.00 ( 1.87%) Ops minorfaults-944M 972818.00 ( 0.00%) 1005956.00 ( -3.41%) Ops minorfaults-1452M 966597.00 ( 0.00%) 1035465.00 ( -7.12%) Ops minorfaults-1961M 976158.00 ( 0.00%) 1049441.00 ( -7.51%) Ops minorfaults-2469M 967815.00 ( 0.00%) 1051752.00 ( -8.67%) Ops minorfaults-2978M 988712.00 ( 0.00%) 1034615.00 ( -4.64%) Ops majorfaults-0M 5899.00 ( 0.00%) 9.00 ( 99.85%) Ops majorfaults-435M 2684.00 ( 0.00%) 67.00 ( 97.50%) Ops majorfaults-944M 4380.00 ( 0.00%) 5790.00 (-32.19%) Ops majorfaults-1452M 4161.00 ( 0.00%) 9222.00 (-121.63%) Ops majorfaults-1961M 4435.00 ( 0.00%) 8800.00 (-98.42%) Ops majorfaults-2469M 4555.00 ( 0.00%) 10541.00 (-131.42%) Ops majorfaults-2978M 6182.00 ( 0.00%) 11618.00 (-87.93%)But the performance of the first machine I used whose total ram size is 2G is still bad.
I need more time to summarize those testing results.Quoted 5 lines
Maybe you can also have a try with lower total ram size.
--
Regards,
--Bob
Quoted 12 lines
A very important factor that you are not considering and that might account for your different results is the "initial conditions". For example, I always ran my benchmarks after a default-configured EL6 boot, which launches many services at boot time, each of which creates many anonymous pages, and these "service anonymous pages" are often the pages that are selected by LRU for swapping, and compressed by zcache/zswap. Someone else may run the benchmarks on a minimally-configured embedded system, and someone else on a single-user system with no services running at all. A single-user system with no services is often best for reproducing benchmark results but may not be at all representative of the real world.
Right. And interestingly enough the kernbench recommends that model so that it is easier to reproduce.
Quoted 7 lines
At a minimum, it would be good to always record "Active(anon)" and "Inactive(anon)" in addition to the amount of physical RAM in the system. (Note, in
/proc/meminfoon my system, the sum of these don't add up to "AnonPages"... I'm not sure why.)
Quoted 8 lines
And of course, even if the number of anonymous pages is the same, the _contents_ of those pages may be very different, which will affect zcache/zswap density which may have a large impact on benchmark results.
Thanks,
Dan (T-minus two weeks and counting)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v13 4/4 zswap: add documentation
In reply to Seth JenningsThis patch adds the documentation file for the zswap functionality
--- Documentation/vm/zswap.txt | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/vm/zswap.txt
Documentation/vm/zswap.txt new file +68 -0
@@ -0,0 +1,68 @@ +Overview: + +Zswap is a lightweight compressed cache for swap pages. It takes pages that are +in the process of being swapped out and attempts to compress them into a +dynamically allocated RAM-based memory pool. zswap basically trades CPU cycles +for potentially reduced swap I/O.A This trade-off can also result in a +significant performance improvement if reads from the compressed cache are +faster than reads from a swap device. + +NOTE: Zswap is a new feature as of v3.11 and interacts heavily with memory +reclaim. This interaction has not be fully explored on the large set of +potential configurations and workloads that exist. For this reason, zswap +is a work in progress and should be considered experimental. + +Some potential benefits: +* Desktop/laptop users with limited RAM capacities can mitigate the +A A A performance impact of swapping. +* Overcommitted guests that share a common I/O resource can +A A A dramatically reduce their swap I/O pressure, avoiding heavy handed I/O + throttling by the hypervisor.A This allows more work to get done with less + impact to the guest workload and guests sharing the I/O subsystem +* Users with SSDs as swap devices can extend the life of the device by +A A A drastically reducing life-shortening writes. + +Zswap evicts pages from compressed cache on an LRU basis to the backing swap +device when the compressed pool reaches it size limit. This requirement had +been identified in prior community discussions. + +To enabled zswap, the "enabled" attribute must be set to 1 at boot time. e.g. +zswap.enabled=1 + +Design: + +Zswap receives pages for compression through the Frontswap API and is able to +evict pages from its own compressed pool on an LRU basis and write them back to +the backing swap device in the case that the compressed pool is full. + +Zswap makes use of zbud for the managing the compressed memory pool. Each +allocation in zbud is not directly accessible by address. Rather, a handle is +return by the allocation routine and that handle must be mapped before being +accessed. The compressed memory pool grows on demand and shrinks as compressed +pages are freed. The pool is not preallocated. + +When a swap page is passed from frontswap to zswap, zswap maintains a mapping +of the swap entry, a combination of the swap type and swap offset, to the zbud +handle that references that compressed swap page. This mapping is achieved +with a red-black tree per swap type. The swap offset is the search key for the +tree nodes. + +During a page fault on a PTE that is a swap entry, frontswap calls the zswap +load function to decompress the page into the page allocated by the page fault +handler. + +Once there are no PTEs referencing a swap page stored in zswap (i.e. the count +in the swap_map goes to 0) the swap code calls the zswap invalidate function, +via frontswap, to free the compressed entry. + +Zswap seeks to be simple in its policies. Sysfs attributes allow for one user +controlled policies: +* max_pool_percent - The maximum percentage of memory that the compressed + pool can occupy. + +Zswap allows the compressor to be selected at kernel boot time by setting the +a??compressora?? attribute. The default compressor is lzo. e.g. +zswap.compressor=deflate + +A debugfs interface is provided for various statistic about pool size, number +of pages stored, and various counters for the reasons pages are rejected.
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>
Hi Seth,
Quoted 3 lines · Seth Jennings
This is the latest version of the zswap patchset for compressed swap caching. This is submitted for merging into linux-next and inclusion in v3.11.
Have you noticed that pool_pages >> stored_pages, like this:
[root@ca-dev32 zswap]# cat *
0
424057
99538
0
2749448
0
24
60018
16837
[root@ca-dev32 zswap]# cat pool_pages
97372
[root@ca-dev32 zswap]# cat stored_pages
53701
[root@ca-dev32 zswap]#
I think it's unreasonable to use more pool pages than stored pages!
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 24 lines · Bob Liu
Hi Seth,
Quoted 3 lines · Seth Jennings
This is the latest version of the zswap patchset for compressed swap caching. This is submitted for merging into linux-next and inclusion in v3.11.
Have you noticed that
pool_pages>>stored_pages, like this:
[root@ca-dev32 zswap]# cat *
0
424057
99538
0
2749448
0
24
60018
16837
[root@ca-dev32 zswap]# catpool_pages
97372
[root@ca-dev32 zswap]# catstored_pages
53701
[root@ca-dev32 zswap]#
Quoted 1 line
I think it's unreasonable to use more pool pages than stored pages!
Gah, in the moving of the zbud metadata for v13, I forgot to init the new under_reclaim field of the zbud header. Patch going out now.
Thanks for reporting!
Seth