All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <20161120233015.GA14113@bbox>

diff --git a/a/1.txt b/N1/1.txt
index 7bf38df..d2a9770 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -40,3 +40,95 @@ Right you are!!
 
 I toally agree.
 Here is new one.
+
+>From 90b43e41a9fd8091e39246add583886c23360cdd Mon Sep 17 00:00:00 2001
+From: Minchan Kim <minchan@kernel.org>
+Date: Fri, 11 Nov 2016 15:02:57 +0900
+Subject: [PATCH v2] mm: support anonymous stable page
+
+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>
+---
+* from v1
+ * use swap_info_struct instead of swapper_space->host inode - Hugh
+
+ include/linux/swap.h |  3 ++-
+ mm/swapfile.c        | 20 +++++++++++++++++++-
+ 2 files changed, 21 insertions(+), 2 deletions(-)
+
+diff --git a/include/linux/swap.h b/include/linux/swap.h
+index a56523cefb9b..55ff5593c193 100644
+--- a/include/linux/swap.h
++++ b/include/linux/swap.h
+@@ -150,8 +150,9 @@ enum {
+ 	SWP_FILE	= (1 << 7),	/* set after swap_activate success */
+ 	SWP_AREA_DISCARD = (1 << 8),	/* single-time swap area discards */
+ 	SWP_PAGE_DISCARD = (1 << 9),	/* freed swap page-cluster discards */
++	SWP_STABLE_WRITES = (1 << 10),	/* no overwrite PG_writeback pages */
+ 					/* add others here before... */
+-	SWP_SCANNING	= (1 << 10),	/* refcount in scan_swap_map */
++	SWP_SCANNING	= (1 << 11),	/* refcount in scan_swap_map */
+ };
+ 
+ #define SWAP_CLUSTER_MAX 32UL
+diff --git a/mm/swapfile.c b/mm/swapfile.c
+index 2210de290b54..66bc330c0b65 100644
+--- a/mm/swapfile.c
++++ b/mm/swapfile.c
+@@ -943,11 +943,25 @@ bool reuse_swap_page(struct page *page, int *total_mapcount)
+ 	count = page_trans_huge_mapcount(page, total_mapcount);
+ 	if (count <= 1 && PageSwapCache(page)) {
+ 		count += page_swapcount(page);
+-		if (count == 1 && !PageWriteback(page)) {
++		if (count != 1)
++			goto out;
++		if (!PageWriteback(page)) {
+ 			delete_from_swap_cache(page);
+ 			SetPageDirty(page);
++		} else {
++			swp_entry_t entry;
++			struct swap_info_struct *p;
++
++			entry.val = page_private(page);
++			p = swap_info_get(entry);
++			if (p->flags & SWP_STABLE_WRITES) {
++				spin_unlock(&p->lock);
++				return false;
++			}
++			spin_unlock(&p->lock);
+ 		}
+ 	}
++out:
+ 	return count <= 1;
+ }
+ 
+@@ -2447,6 +2461,10 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
+ 		error = -ENOMEM;
+ 		goto bad_swap;
+ 	}
++
++	if (bdi_cap_stable_pages_required(inode_to_bdi(inode)))
++		p->flags |= SWP_STABLE_WRITES;
++
+ 	if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
+ 		int cpu;
+ 
+-- 
+2.7.4
diff --git a/a/content_digest b/N1/content_digest
index cc799e5..920024c 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -51,6 +51,98 @@
  "> \n"
  "\n"
  "I toally agree.\n"
- Here is new one.
+ "Here is new one.\n"
+ "\n"
+ ">From 90b43e41a9fd8091e39246add583886c23360cdd Mon Sep 17 00:00:00 2001\n"
+ "From: Minchan Kim <minchan@kernel.org>\n"
+ "Date: Fri, 11 Nov 2016 15:02:57 +0900\n"
+ "Subject: [PATCH v2] mm: support anonymous stable page\n"
+ "\n"
+ "For developemnt for zram-swap asynchronous writeback, I found\n"
+ "strange corruption of compressed page. With investigation, it\n"
+ "reveals currently stable page doesn't support anonymous page.\n"
+ "IOW, reuse_swap_page can reuse the page without waiting\n"
+ "writeback completion so that it can corrupt data during\n"
+ "zram compression. It can affect every swap device which supports\n"
+ "asynchronous writeback and CRC checking as well as zRAM.\n"
+ "\n"
+ "Unfortunately, reuse_swap_page should be atomic so that we\n"
+ "cannot wait on writeback in there so the approach in this patch\n"
+ "is simply return false if we found it needs stable page.\n"
+ "Although it increases memory footprint temporarily, it happens\n"
+ "rarely and it should be reclaimed easily althoug it happened.\n"
+ "Also, It would be better than waiting of IO completion, which\n"
+ "is critial path for application latency.\n"
+ "\n"
+ "Cc: Hugh Dickins <hughd@google.com>\n"
+ "Cc: Darrick J. Wong <darrick.wong@oracle.com>\n"
+ "Signed-off-by: Minchan Kim <minchan@kernel.org>\n"
+ "---\n"
+ "* from v1\n"
+ " * use swap_info_struct instead of swapper_space->host inode - Hugh\n"
+ "\n"
+ " include/linux/swap.h |  3 ++-\n"
+ " mm/swapfile.c        | 20 +++++++++++++++++++-\n"
+ " 2 files changed, 21 insertions(+), 2 deletions(-)\n"
+ "\n"
+ "diff --git a/include/linux/swap.h b/include/linux/swap.h\n"
+ "index a56523cefb9b..55ff5593c193 100644\n"
+ "--- a/include/linux/swap.h\n"
+ "+++ b/include/linux/swap.h\n"
+ "@@ -150,8 +150,9 @@ enum {\n"
+ " \tSWP_FILE\t= (1 << 7),\t/* set after swap_activate success */\n"
+ " \tSWP_AREA_DISCARD = (1 << 8),\t/* single-time swap area discards */\n"
+ " \tSWP_PAGE_DISCARD = (1 << 9),\t/* freed swap page-cluster discards */\n"
+ "+\tSWP_STABLE_WRITES = (1 << 10),\t/* no overwrite PG_writeback pages */\n"
+ " \t\t\t\t\t/* add others here before... */\n"
+ "-\tSWP_SCANNING\t= (1 << 10),\t/* refcount in scan_swap_map */\n"
+ "+\tSWP_SCANNING\t= (1 << 11),\t/* refcount in scan_swap_map */\n"
+ " };\n"
+ " \n"
+ " #define SWAP_CLUSTER_MAX 32UL\n"
+ "diff --git a/mm/swapfile.c b/mm/swapfile.c\n"
+ "index 2210de290b54..66bc330c0b65 100644\n"
+ "--- a/mm/swapfile.c\n"
+ "+++ b/mm/swapfile.c\n"
+ "@@ -943,11 +943,25 @@ bool reuse_swap_page(struct page *page, int *total_mapcount)\n"
+ " \tcount = page_trans_huge_mapcount(page, total_mapcount);\n"
+ " \tif (count <= 1 && PageSwapCache(page)) {\n"
+ " \t\tcount += page_swapcount(page);\n"
+ "-\t\tif (count == 1 && !PageWriteback(page)) {\n"
+ "+\t\tif (count != 1)\n"
+ "+\t\t\tgoto out;\n"
+ "+\t\tif (!PageWriteback(page)) {\n"
+ " \t\t\tdelete_from_swap_cache(page);\n"
+ " \t\t\tSetPageDirty(page);\n"
+ "+\t\t} else {\n"
+ "+\t\t\tswp_entry_t entry;\n"
+ "+\t\t\tstruct swap_info_struct *p;\n"
+ "+\n"
+ "+\t\t\tentry.val = page_private(page);\n"
+ "+\t\t\tp = swap_info_get(entry);\n"
+ "+\t\t\tif (p->flags & SWP_STABLE_WRITES) {\n"
+ "+\t\t\t\tspin_unlock(&p->lock);\n"
+ "+\t\t\t\treturn false;\n"
+ "+\t\t\t}\n"
+ "+\t\t\tspin_unlock(&p->lock);\n"
+ " \t\t}\n"
+ " \t}\n"
+ "+out:\n"
+ " \treturn count <= 1;\n"
+ " }\n"
+ " \n"
+ "@@ -2447,6 +2461,10 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)\n"
+ " \t\terror = -ENOMEM;\n"
+ " \t\tgoto bad_swap;\n"
+ " \t}\n"
+ "+\n"
+ "+\tif (bdi_cap_stable_pages_required(inode_to_bdi(inode)))\n"
+ "+\t\tp->flags |= SWP_STABLE_WRITES;\n"
+ "+\n"
+ " \tif (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {\n"
+ " \t\tint cpu;\n"
+ " \n"
+ "-- \n"
+ 2.7.4
 
-ea9421238d37f83deaf025e0461e201ab434411498bda665317faf48bce80a70
+82faccceba7ae1027175b3d80b04a03f7f313f3ed011c50b1731a39a30a97170

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.