关于2.,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在压缩的内存内高速缓存在写回磁盘之前可能会很快被遗忘的情况下非常有用。不适用于具有大而长寿命的堆的应用程序,这些应用程序最终将需要实际的交换设备来支持。