summaryrefslogtreecommitdiff |
diff options
author | Vlastimil Babka <vbabka@suse.cz> | 2019-01-14 10:07:57 +0100 |
---|---|---|
committer | Vlastimil Babka <vbabka@suse.cz> | 2019-01-14 10:08:28 +0100 |
commit | 6fbf3d58294c7e64bac07824fa97866b4757a347 (patch) | |
tree | c8497864a5a026cf2e49ce833a47cc50d0f1b1ee | |
parent | 418db51f8b57ec33f90bc040adcae419f70667f8 (diff) |
mm/khugepaged: collapse_shmem() stop if punched or truncated
(VM Functionality, bsc#1121599).
-rw-r--r-- | patches.fixes/mm-khugepaged-collapse_shmem-stop-if-punched-or-truncated.patch | 60 | ||||
-rw-r--r-- | series.conf | 1 |
2 files changed, 61 insertions, 0 deletions
diff --git a/patches.fixes/mm-khugepaged-collapse_shmem-stop-if-punched-or-truncated.patch b/patches.fixes/mm-khugepaged-collapse_shmem-stop-if-punched-or-truncated.patch new file mode 100644 index 0000000000..c746dde23f --- /dev/null +++ b/patches.fixes/mm-khugepaged-collapse_shmem-stop-if-punched-or-truncated.patch @@ -0,0 +1,60 @@ +From: Hugh Dickins <hughd@google.com> +Date: Fri, 30 Nov 2018 14:10:25 -0800 +Subject: mm/khugepaged: collapse_shmem() stop if punched or truncated +Git-commit: 701270fa193aadf00bdcf607738f64997275d4c7 +Patch-mainline: v4.20-rc5 +References: VM Functionality, bsc#1121599 + +[ vbabka@suse.cz: use the 4.14 pre-xarray stable backport ] + +Huge tmpfs testing showed that although collapse_shmem() recognizes a +concurrently truncated or hole-punched page correctly, its handling of +holes was liable to refill an emptied extent. Add check to stop that. + +Link: http://lkml.kernel.org/r/alpine.LSU.2.11.1811261522040.2275@eggly.anvils +Fixes: f3f0e1d2150b2 ("khugepaged: add support of collapse for tmpfs/shmem pages") +Signed-off-by: Hugh Dickins <hughd@google.com> +Reviewed-by: Matthew Wilcox <willy@infradead.org> +Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> +Cc: Jerome Glisse <jglisse@redhat.com> +Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> +Cc: <stable@vger.kernel.org> [4.8+] +Signed-off-by: Andrew Morton <akpm@linux-foundation.org> +Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> +Signed-off-by: Sasha Levin <sashal@kernel.org> +Signed-off-by: Vlastimil Babka <vbabka@suse.cz> +--- + mm/khugepaged.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -1348,6 +1348,16 @@ static void collapse_shmem(struct mm_str + int n = min(iter.index, end) - index; + + /* ++ * Stop if extent has been hole-punched, and is now completely ++ * empty (the more obvious i_size_read() check would take an ++ * irq-unsafe seqlock on 32-bit). ++ */ ++ if (n >= HPAGE_PMD_NR) { ++ result = SCAN_TRUNCATED; ++ goto tree_locked; ++ } ++ ++ /* + * Handle holes in the radix tree: charge it from shmem and + * insert relevant subpage of new_page into the radix-tree. + */ +@@ -1458,6 +1468,11 @@ out_unlock: + if (result == SCAN_SUCCEED && index < end) { + int n = end - index; + ++ /* Stop if extent has been truncated, and is now empty */ ++ if (n >= HPAGE_PMD_NR) { ++ result = SCAN_TRUNCATED; ++ goto tree_locked; ++ } + if (!shmem_charge(mapping->host, n)) { + result = SCAN_FAIL; + goto tree_locked; diff --git a/series.conf b/series.conf index 6c64b90dca..e61800fbe1 100644 --- a/series.conf +++ b/series.conf @@ -19366,6 +19366,7 @@ patches.fixes/mm-huge_memory-rename-freeze_page-to-unmap_page.patch patches.fixes/mm-huge_memory-splitting-set-mapping-index-before-unfreeze.patch patches.fixes/mm-huge_memory-fix-lockdep-complaint-on-32-bit-i_size_read.patch + patches.fixes/mm-khugepaged-collapse_shmem-stop-if-punched-or-truncated.patch patches.drivers/pci-imx6-fix-link-training-status-detection-in-link-up-check patches.fixes/fs-fix-lost-error-code-in-dio_complete.patch patches.fixes/nvme-free-ctrl-device-name-on-init-failure.patch |