Zswap

From Wikipedia, the free encyclopedia

zswap is a Linux kernel feature providing a write-back compressed cache for swap pages. Instead of memory pages being directly written to the swap device when they are to be swapped out, zswap performs their compression and then stores them within a memory pool dynamically allocated inside system's RAM. Later writeback to the actual swap device is deferred or even completely avoided, resulting in a significantly reduced I/O for Linux systems that require swapping; the trade-off are additional CPU cycles required for compression.[1][2][3]

Internals

Internally, zswap is using compression modules provided by the Linux kernel's crypto API, making it possible (for example) to use any hardware compression accelerators supported by the Linux kernel. Selection of the desired compression module can be performed dynamically at the boot time, through value of the kernel boot parameter zswap.compressor; the default value is deflate, indicating use of LZO compression. Also, as of Linux kernel version 3.13, zswap needs to be explicitly enabled by specifying value 1 for the boot parameter zswap.enabled.[1][4]

Maximum size of the memory pool used by zswap is configurable through the sysfs parameter max_pool_percent, which specifies maximum percentage of total system RAM that can be occupied by the pool. The memory pool is not preallocated; instead, it grows and shrinks as required. When the configured maximum pool size is reached as the result of performed swapping, or when growing the pool is impossible due to out-of-memory conditions, pages are evicted from the memory pool to the swap device on a least recently used (LRU) basis. That makes zswap a true swap cache, as the oldest cached pages are evicted to the swap device once the cache is full, making room for newer swapped pages to be compressed and cached.[1][4][5]

zbud is a special-purpose memory allocator used internally by zswap for storing compressed pages; it was implemented as a rewrite of the zbud allocator used internally by the Oracle's zcache. zbud works by storing up to two compressed pages ("buddies", hence the allocator name) per physical memory page, what brings both advantages (easy coalescing and reusing of freed space) and disadvantages (possible lower memory utilization). However, due to its design, zbud cannot allocate more memory space than it would be originally used by uncompressed pages.[3][6]

History

Both zswap and zbud are developed by Seth Jennings. The first public announcement was in December 2012, and the development continued until May 2013 at which point the codebase reached its maturity though still being marked as an experimental kernel feature.[7][8]

zswap (together with zbud) was merged into the Linux kernel mainline in kernel version 3.11, released on 2 September 2013.[4][9]

See also

  • Linux swap
  • Swap partitions on SSDs
  • zram

References

  1. 1.0 1.1 1.2 Seth Jennings (2013-02-12). "The zswap compressed swap cache". LWN.net. Retrieved 2014-01-22. 
  2. Jenifer Hopper (2012-12-11). "New Linux zswap compression functionality". ibm.com. Retrieved 2014-01-31. 
  3. 3.0 3.1 Michael Larabel (2013-07-11). "Zswap Merged Into The Linux 3.11 Kernel". phoronix.com. Retrieved 2014-02-05. 
  4. 4.0 4.1 4.2 "Documentation/vm/zswap.txt". Linux kernel documentation. kernel.org. Retrieved 2014-01-22. 
  5. "kernel/git/torvalds/linux.git: zswap: add to mm/". Linux kernel source tree. kernel.org. 2013-07-11. Retrieved 2014-02-05. 
  6. "kernel/git/torvalds/linux.git: zbud: add to mm/". Linux kernel source tree. kernel.org. 2013-07-11. Retrieved 2014-02-05. 
  7. "[PATCH 0/8] zswap: compressed swap caching". gmane.org. 2012-12-11. Retrieved 2014-01-05. 
  8. "[PATCHv10 0/4] zswap: compressed swap caching". gmane.org. 2013-05-08. Retrieved 2014-01-05. 
  9. "9. Zswap: A compressed swap cache". Linux 3.11. kernelnewbies.org. 2013-09-02. Retrieved 2014-01-22. 

External links

This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.