diff for duplicates of <20161111060644.GA24342@bbox> diff --git a/a/1.txt b/N1/1.txt index 876edb4..1967c6b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1 +1,77 @@ Sorry for sending a wrong version. Here is new one. + +>From 2d42ead9335cde51fd58d6348439ca03cf359ba2 Mon Sep 17 00:00:00 2001 +From: Minchan Kim <minchan@kernel.org> +Date: Fri, 11 Nov 2016 15:02:57 +0900 +Subject: [PATCH] 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> +--- + mm/swapfile.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/mm/swapfile.c b/mm/swapfile.c +index 2210de290b54..ea591435d8e0 100644 +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -943,11 +943,21 @@ 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 { ++ struct address_space *mapping; ++ ++ mapping = page_mapping(page); ++ if (bdi_cap_stable_pages_required( ++ inode_to_bdi(mapping->host))) ++ return false; + } + } ++out: + return count <= 1; + } + +@@ -2180,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)); +@@ -2202,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 diff --git a/a/content_digest b/N1/content_digest index 8e40427..3737090 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -4,13 +4,89 @@ "Date\0Fri, 11 Nov 2016 15:06:44 +0900\0" "To\0Andrew Morton <akpm@linux-foundation.org>\0" "Cc\0Hyeoncheol Lee <cheol.lee@lge.com>" - yjay.kim@lge.com - linux-mm@kvack.org - linux-kernel@vger.kernel.org + <yjay.kim@lge.com> + <linux-mm@kvack.org> + <linux-kernel@vger.kernel.org> Hugh Dickins <hughd@google.com> " Darrick J . Wong <darrick.wong@oracle.com>\0" "\00:1\0" "b\0" - Sorry for sending a wrong version. Here is new one. + "Sorry for sending a wrong version. Here is new one.\n" + "\n" + ">From 2d42ead9335cde51fd58d6348439ca03cf359ba2 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] 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" + " mm/swapfile.c | 16 +++++++++++++++-\n" + " 1 file changed, 15 insertions(+), 1 deletion(-)\n" + "\n" + "diff --git a/mm/swapfile.c b/mm/swapfile.c\n" + "index 2210de290b54..ea591435d8e0 100644\n" + "--- a/mm/swapfile.c\n" + "+++ b/mm/swapfile.c\n" + "@@ -943,11 +943,21 @@ 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\tstruct address_space *mapping;\n" + "+\n" + "+\t\t\tmapping = page_mapping(page);\n" + "+\t\t\tif (bdi_cap_stable_pages_required(\n" + "+\t\t\t\t\tinode_to_bdi(mapping->host)))\n" + "+\t\t\t\treturn false;\n" + " \t\t}\n" + " \t}\n" + "+out:\n" + " \treturn count <= 1;\n" + " }\n" + " \n" + "@@ -2180,6 +2190,7 @@ static struct swap_info_struct *alloc_swap_info(void)\n" + " static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)\n" + " {\n" + " \tint error;\n" + "+\tstruct address_space *swapper_space;\n" + " \n" + " \tif (S_ISBLK(inode->i_mode)) {\n" + " \t\tp->bdev = bdgrab(I_BDEV(inode));\n" + "@@ -2202,6 +2213,9 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)\n" + " \t} else\n" + " \t\treturn -EINVAL;\n" + " \n" + "+\tswapper_space = &swapper_spaces[p->type];\n" + "+\tswapper_space->host = inode;\n" + "+\n" + " \treturn 0;\n" + " }\n" + " \n" + "-- \n" + 2.7.4 -e9ee8f39c029f624249b1ee80c615b344e9d1dc573fe9abbe485671a5f0fb749 +236b264160d124930252e41330034781dfff0f9bb331d2b0124a1b81febd8e51
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.