[Devel] [PATCH rh7 2/3] tswap: shrink tswap page if swapcache page is uptodate

Vladimir Davydov vdavydov at parallels.com
Fri Jun 19 03:41:04 PDT 2015


On tswap shrink we attempt to move a tswap page back to swapcache. If
there is already a swapcache page at the given offset, we leave the
tswap page in frontswap while removing it from LRU, because we assume
that it will be loaded in a moment fron read_swap_cache_async.

However, it is not always true. The reclaimer could have failed to free
a swapcache page after successfully storing it to frontswap. In this
case, the swapcache page will be uptodate and there is no need in
keeping the backing page in frontswap. Quite the contrary, if we keep
such a page in frontswap, it will be dangling there until the swapcache
page it backs is reclaimed, which may take indefinitely long.

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

diff --git a/mm/tswap.c b/mm/tswap.c
index 222cf5b251aa..6b6c7143bda6 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -89,7 +89,17 @@ retry:
 		 * Hence, if the current page has not been loaded yet, it will
 		 * be in a moment (see read_swap_cache_async), so there is no
 		 * need to put it back to the lru list.
+		 *
+		 * There is one exception though - the reclaimer could have
+		 * failed to free a swap cache page after successfully storing
+		 * it to frontswap. In this case the swap cache page will be
+		 * uptodate and there is no need in keeping the backing page
+		 * in frontswap.
 		 */
+		if (PageUptodate(found_page) &&
+		    tswap_delete(entry, page) == page)
+			put_page(page);
+
 		put_page(found_page);
 		goto out;
 	}
-- 
2.1.4




More information about the Devel mailing list