关于第二点,zswap 在写回时似乎会对页面进行解压缩,证实了@Cbhihe的评论。
mm/zswap.c,第828行:
/*
* Attempts to free an entry by adding a page to the swap cache,
* decompressing the entry data into the page, and issuing a
* bio write to write the page back to the swap device.
* ...
*/
static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
{
...
case ZSWAP_SWAPCACHE_NEW: /* page is locked */
/* decompress */
...
ret = crypto_comp_decompress(tfm, src, entry->length,
dst, &dlen);
...
kunmap_atomic(dst);
$ git show
commit 1573d2caf713874cfe0d1336c823d0fb548d8bed
Merge: 4cdf8db 0a86248
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Tue Oct 11 23:59:07 2016 -0700
所以zswap在压缩的内存缓存很快被写回磁盘之前很可能会被遗忘的情况下非常有用。
它不适用于具有大型、长期存在的堆栈,这些堆栈最终需要由实际的交换设备支持的应用程序。