[Devel] [PATCH rh7 2/7] tswap: enable exclusive gets

Vladimir Davydov vdavydov at parallels.com
Sat Jun 20 08:56:51 PDT 2015


By default, a frontswap backend is supposed to keep a loaded page in the
transcendent storage, but tswap invalidates loaded pages. As a result,
after a successful load we get an uptodate clean swapcache page that has
not been written to disk. This can result in userspace memory
corruption.

In case of tswap, there is no point in keeping loaded pages - it will
only double memory consumption, so we must force frontswap frontend to
dirty a page after loading it from backend.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/tswap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/tswap.c b/mm/tswap.c
index 6f8707367508..f2c450fa7757 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -329,6 +329,8 @@ static int __init tswap_init(void)
 	if (err)
 		goto out_free_lru;
 
+	frontswap_tmem_exclusive_gets(true);
+
 	old_ops = frontswap_register_ops(&tswap_frontswap_ops);
 	pr_info("tswap loaded\n");
 	if (old_ops)
-- 
2.1.4




More information about the Devel mailing list