diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2020-09-16 19:04:09 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2020-09-16 19:04:09 -0400 |
commit | 324da3164a7da609072957afed08f11051b6c543 (patch) | |
tree | eeab9e8a9b1e80028a9ea0bc78112c2bbc0c8f88 | |
parent | 5facac77676ec9e5794c59e82b0a5a13bba7ad93 (diff) | |
download | longterm-queue-5.2-324da3164a7da609072957afed08f11051b6c543.tar.gz |
mm: khugepaged: drop commit n/a for v5.2
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r-- | queue/khugepaged-retract_page_tables-remember-to-test-exit.patch | 97 | ||||
-rw-r--r-- | queue/series | 1 |
2 files changed, 0 insertions, 98 deletions
diff --git a/queue/khugepaged-retract_page_tables-remember-to-test-exit.patch b/queue/khugepaged-retract_page_tables-remember-to-test-exit.patch deleted file mode 100644 index 135608e9..00000000 --- a/queue/khugepaged-retract_page_tables-remember-to-test-exit.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 18e77600f7a1ed69f8ce46c9e11cad0985712dfa Mon Sep 17 00:00:00 2001 -From: Hugh Dickins <hughd@google.com> -Date: Thu, 6 Aug 2020 23:26:22 -0700 -Subject: [PATCH] khugepaged: retract_page_tables() remember to test exit - -commit 18e77600f7a1ed69f8ce46c9e11cad0985712dfa upstream. - -Only once have I seen this scenario (and forgot even to notice what forced -the eventual crash): a sequence of "BUG: Bad page map" alerts from -vm_normal_page(), from zap_pte_range() servicing exit_mmap(); -pmd:00000000, pte values corresponding to data in physical page 0. - -The pte mappings being zapped in this case were supposed to be from a huge -page of ext4 text (but could as well have been shmem): my belief is that -it was racing with collapse_file()'s retract_page_tables(), found *pmd -pointing to a page table, locked it, but *pmd had become 0 by the time -start_pte was decided. - -In most cases, that possibility is excluded by holding mmap lock; but -exit_mmap() proceeds without mmap lock. Most of what's run by khugepaged -checks khugepaged_test_exit() after acquiring mmap lock: -khugepaged_collapse_pte_mapped_thps() and hugepage_vma_revalidate() do so, -for example. But retract_page_tables() did not: fix that. - -The fix is for retract_page_tables() to check khugepaged_test_exit(), -after acquiring mmap lock, before doing anything to the page table. -Getting the mmap lock serializes with __mmput(), which briefly takes and -drops it in __khugepaged_exit(); then the khugepaged_test_exit() check on -mm_users makes sure we don't touch the page table once exit_mmap() might -reach it, since exit_mmap() will be proceeding without mmap lock, not -expecting anyone to be racing with it. - -Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages") -Signed-off-by: Hugh Dickins <hughd@google.com> -Signed-off-by: Andrew Morton <akpm@linux-foundation.org> -Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> -Cc: Andrea Arcangeli <aarcange@redhat.com> -Cc: Mike Kravetz <mike.kravetz@oracle.com> -Cc: Song Liu <songliubraving@fb.com> -Cc: <stable@vger.kernel.org> [4.8+] -Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008021215400.27773@eggly.anvils -Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> - -diff --git a/mm/khugepaged.c b/mm/khugepaged.c -index a9aca9b71d6f..ac04b332a373 100644 ---- a/mm/khugepaged.c -+++ b/mm/khugepaged.c -@@ -1532,6 +1532,7 @@ out: - static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) - { - struct vm_area_struct *vma; -+ struct mm_struct *mm; - unsigned long addr; - pmd_t *pmd, _pmd; - -@@ -1560,7 +1561,8 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) - continue; - if (vma->vm_end < addr + HPAGE_PMD_SIZE) - continue; -- pmd = mm_find_pmd(vma->vm_mm, addr); -+ mm = vma->vm_mm; -+ pmd = mm_find_pmd(mm, addr); - if (!pmd) - continue; - /* -@@ -1570,17 +1572,19 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff) - * mmap_lock while holding page lock. Fault path does it in - * reverse order. Trylock is a way to avoid deadlock. - */ -- if (mmap_write_trylock(vma->vm_mm)) { -- spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd); -- /* assume page table is clear */ -- _pmd = pmdp_collapse_flush(vma, addr, pmd); -- spin_unlock(ptl); -- mmap_write_unlock(vma->vm_mm); -- mm_dec_nr_ptes(vma->vm_mm); -- pte_free(vma->vm_mm, pmd_pgtable(_pmd)); -+ if (mmap_write_trylock(mm)) { -+ if (!khugepaged_test_exit(mm)) { -+ spinlock_t *ptl = pmd_lock(mm, pmd); -+ /* assume page table is clear */ -+ _pmd = pmdp_collapse_flush(vma, addr, pmd); -+ spin_unlock(ptl); -+ mm_dec_nr_ptes(mm); -+ pte_free(mm, pmd_pgtable(_pmd)); -+ } -+ mmap_write_unlock(mm); - } else { - /* Try again later */ -- khugepaged_add_pte_mapped_thp(vma->vm_mm, addr); -+ khugepaged_add_pte_mapped_thp(mm, addr); - } - } - i_mmap_unlock_write(mapping); --- -2.27.0 - diff --git a/queue/series b/queue/series index 30622961..0295e0ed 100644 --- a/queue/series +++ b/queue/series @@ -97,7 +97,6 @@ mfd-dln2-Run-event-handler-loop-under-spinlock.patch ALSA-echoaudio-Fix-potential-Oops-in-snd_echo_resume.patch perf-bench-mem-Always-memset-source-before-memcpy.patch sh-landisk-Add-missing-initialization-of-sh_io_port_.patch -khugepaged-retract_page_tables-remember-to-test-exit.patch arm64-dts-marvell-espressobin-add-ethernet-alias.patch drm-Added-orientation-quirk-for-ASUS-tablet-model-T1.patch drm-fix-drm_dp_mst_port-refcount-leaks-in-drm_dp_mst.patch |