linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: support anonymous stable page
@ 2016-11-11  5:30 Minchan Kim
  2016-11-11  6:06 ` Minchan Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Minchan Kim @ 2016-11-11  5:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Hyeoncheol Lee, yjay.kim, linux-mm, linux-kernel, Minchan Kim,
	Hugh Dickins, Darrick J . Wong

For developemnt for zram-swap asynchronous writeback, I found
strange corruption of compressed page. With investigation, it
reveals currently stable page doesn't support anonymous page.
IOW, reuse_swap_page can reuse the page without waiting
writeback completion so that it can corrupt data during
zram compression. It can affect every swap device which supports
asynchronous writeback and CRC checking as well as zRAM.

Unfortunately, reuse_swap_page should be atomic so that we
cannot wait on writeback in there so the approach in this patch
is simply return false if we found it needs stable page.
Although it increases memory footprint temporarily, it happens
rarely and it should be reclaimed easily althoug it happened.
Also, It would be better than waiting of IO completion, which
is critial path for application latency.

Cc: Hugh Dickins <hughd@google.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/swapfile.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index 816ca8663ae5..ea591435d8e0 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -949,7 +949,12 @@ bool reuse_swap_page(struct page *page, int *total_mapcount)
 			delete_from_swap_cache(page);
 			SetPageDirty(page);
 		} else {
-			wait_for_stable_page(page);
+			struct address_space *mapping;
+
+			mapping = page_mapping(page);
+			if (bdi_cap_stable_pages_required(
+					inode_to_bdi(mapping->host)))
+				return false;
 		}
 	}
 out:
@@ -2185,6 +2190,7 @@ static struct swap_info_struct *alloc_swap_info(void)
 static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
 {
 	int error;
+	struct address_space *swapper_space;
 
 	if (S_ISBLK(inode->i_mode)) {
 		p->bdev = bdgrab(I_BDEV(inode));
@@ -2207,6 +2213,9 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
 	} else
 		return -EINVAL;
 
+	swapper_space = &swapper_spaces[p->type];
+	swapper_space->host = inode;
+
 	return 0;
 }
 
-- 
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-18 21:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11  5:30 [PATCH] mm: support anonymous stable page Minchan Kim
2016-11-11  6:06 ` Minchan Kim
2016-11-18  4:35   ` Hugh Dickins
2016-11-18  6:58     ` Minchan Kim
2016-11-18 21:26       ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).