diff for duplicates of <20180830140825.GA3529@redhat.com> diff --git a/a/1.txt b/N1/1.txt index ad4a203..21352a7 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -47,102 +47,3 @@ You need to invalidate outside page table lock so before the call to page_check_address(). For instance like below patch, which also only do the range invalidation for huge page which would avoid too much of a behavior change for user of mmu notifier. - ->From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com> -Date: Thu, 31 Aug 2017 17:17:27 -0400 -Subject: [PATCH] mm/rmap: update to new mmu_notifier semantic v2 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -commit 369ea8242c0fb5239b4ddf0dc568f694bd244de4 upstrea. - -Please note that this patch differs from the mainline because we do not -really replace mmu_notifier_invalidate_page by mmu_notifier_invalidate_range -because that requires changes to most of existing mmu notifiers. We also -do not want to change the semantic of this API in old kernels. Anyway -Jérôme has suggested that it should be sufficient to simply wrap -mmu_notifier_invalidate_page by *_invalidate_range_start()/end() to fix -invalidation of larger than pte mappings (e.g. THP/hugetlb pages during -migration). We need this change to handle large (hugetlb/THP) pages -migration properly. - -Note that because we can not presume the pmd value or pte value we have -to assume the worst and unconditionaly report an invalidation as -happening. - -Changed since v2: - - try_to_unmap_one() only one call to mmu_notifier_invalidate_range() - - compute end with PAGE_SIZE << compound_order(page) - - fix PageHuge() case in try_to_unmap_one() - -Signed-off-by: Jérôme Glisse <jglisse@redhat.com> -Reviewed-by: Andrea Arcangeli <aarcange@redhat.com> -Cc: Dan Williams <dan.j.williams@intel.com> -Cc: Ross Zwisler <ross.zwisler@linux.intel.com> -Cc: Bernhard Held <berny156@gmx.de> -Cc: Adam Borowski <kilobyte@angband.pl> -Cc: Radim Krčmář <rkrcmar@redhat.com> -Cc: Wanpeng Li <kernellwp@gmail.com> -Cc: Paolo Bonzini <pbonzini@redhat.com> -Cc: Takashi Iwai <tiwai@suse.de> -Cc: Nadav Amit <nadav.amit@gmail.com> -Cc: Mike Galbraith <efault@gmx.de> -Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> -Cc: axie <axie@amd.com> -Cc: Andrew Morton <akpm@linux-foundation.org> -Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> -Signed-off-by: Michal Hocko <mhocko@suse.com> # backport to 4.4 ---- - mm/rmap.c | 20 +++++++++++++++++++- - 1 file changed, 19 insertions(+), 1 deletion(-) - -diff --git a/mm/rmap.c b/mm/rmap.c -index b577fbb98d4b..a77f15dc0cf1 100644 ---- a/mm/rmap.c -+++ b/mm/rmap.c -@@ -1302,15 +1302,30 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, - pte_t pteval; - spinlock_t *ptl; - int ret = SWAP_AGAIN; -+ unsigned long start = address, end; - enum ttu_flags flags = (enum ttu_flags)arg; - - /* munlock has nothing to gain from examining un-locked vmas */ - if ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED)) - goto out; - -+ if (unlikely(PageHuge(page))) { -+ /* -+ * We have to assume the worse case ie pmd for invalidation. -+ * Note that the page can not be free in this function as call -+ * of try_to_unmap() must hold a reference on the page. -+ * -+ * This is ok to invalidate even if are not unmapping anything -+ * ie below page_check_address() returning NULL. -+ */ -+ end = min(vma->vm_end, start + (PAGE_SIZE << -+ compound_order(page))); -+ mmu_notifier_invalidate_range_start(vma->vm_mm, start, end); -+ } -+ - pte = page_check_address(page, mm, address, &ptl, 0); - if (!pte) -- goto out; -+ goto out_notify; - - /* - * If the page is mlock()d, we cannot swap it out. -@@ -1427,6 +1442,9 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, - pte_unmap_unlock(pte, ptl); - if (ret != SWAP_FAIL && ret != SWAP_MLOCK && !(flags & TTU_MUNLOCK)) - mmu_notifier_invalidate_page(mm, address); -+out_notify: -+ if (unlikely(PageHuge(page))) -+ mmu_notifier_invalidate_range_end(vma->vm_mm, start, end); - out: - return ret; - } --- -2.17.1 diff --git a/a/content_digest b/N1/content_digest index 5c45d25..2471e3e 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -75,105 +75,6 @@ "You need to invalidate outside page table lock so before the call to\n" "page_check_address(). For instance like below patch, which also only\n" "do the range invalidation for huge page which would avoid too much of\n" - "a behavior change for user of mmu notifier.\n" - "\n" - ">From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001\n" - "From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com>\n" - "Date: Thu, 31 Aug 2017 17:17:27 -0400\n" - "Subject: [PATCH] mm/rmap: update to new mmu_notifier semantic v2\n" - "MIME-Version: 1.0\n" - "Content-Type: text/plain; charset=UTF-8\n" - "Content-Transfer-Encoding: 8bit\n" - "\n" - "commit 369ea8242c0fb5239b4ddf0dc568f694bd244de4 upstrea.\n" - "\n" - "Please note that this patch differs from the mainline because we do not\n" - "really replace mmu_notifier_invalidate_page by mmu_notifier_invalidate_range\n" - "because that requires changes to most of existing mmu notifiers. We also\n" - "do not want to change the semantic of this API in old kernels. Anyway\n" - "J\303\251r\303\264me has suggested that it should be sufficient to simply wrap\n" - "mmu_notifier_invalidate_page by *_invalidate_range_start()/end() to fix\n" - "invalidation of larger than pte mappings (e.g. THP/hugetlb pages during\n" - "migration). We need this change to handle large (hugetlb/THP) pages\n" - "migration properly.\n" - "\n" - "Note that because we can not presume the pmd value or pte value we have\n" - "to assume the worst and unconditionaly report an invalidation as\n" - "happening.\n" - "\n" - "Changed since v2:\n" - " - try_to_unmap_one() only one call to mmu_notifier_invalidate_range()\n" - " - compute end with PAGE_SIZE << compound_order(page)\n" - " - fix PageHuge() case in try_to_unmap_one()\n" - "\n" - "Signed-off-by: J\303\251r\303\264me Glisse <jglisse@redhat.com>\n" - "Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>\n" - "Cc: Dan Williams <dan.j.williams@intel.com>\n" - "Cc: Ross Zwisler <ross.zwisler@linux.intel.com>\n" - "Cc: Bernhard Held <berny156@gmx.de>\n" - "Cc: Adam Borowski <kilobyte@angband.pl>\n" - "Cc: Radim Kr\304\215m\303\241\305\231 <rkrcmar@redhat.com>\n" - "Cc: Wanpeng Li <kernellwp@gmail.com>\n" - "Cc: Paolo Bonzini <pbonzini@redhat.com>\n" - "Cc: Takashi Iwai <tiwai@suse.de>\n" - "Cc: Nadav Amit <nadav.amit@gmail.com>\n" - "Cc: Mike Galbraith <efault@gmx.de>\n" - "Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>\n" - "Cc: axie <axie@amd.com>\n" - "Cc: Andrew Morton <akpm@linux-foundation.org>\n" - "Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n" - "Signed-off-by: Michal Hocko <mhocko@suse.com> # backport to 4.4\n" - "---\n" - " mm/rmap.c | 20 +++++++++++++++++++-\n" - " 1 file changed, 19 insertions(+), 1 deletion(-)\n" - "\n" - "diff --git a/mm/rmap.c b/mm/rmap.c\n" - "index b577fbb98d4b..a77f15dc0cf1 100644\n" - "--- a/mm/rmap.c\n" - "+++ b/mm/rmap.c\n" - "@@ -1302,15 +1302,30 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,\n" - " \tpte_t pteval;\n" - " \tspinlock_t *ptl;\n" - " \tint ret = SWAP_AGAIN;\n" - "+\tunsigned long start = address, end;\n" - " \tenum ttu_flags flags = (enum ttu_flags)arg;\n" - " \n" - " \t/* munlock has nothing to gain from examining un-locked vmas */\n" - " \tif ((flags & TTU_MUNLOCK) && !(vma->vm_flags & VM_LOCKED))\n" - " \t\tgoto out;\n" - " \n" - "+\tif (unlikely(PageHuge(page))) {\n" - "+\t\t/*\n" - "+\t\t * We have to assume the worse case ie pmd for invalidation.\n" - "+\t\t * Note that the page can not be free in this function as call\n" - "+\t\t * of try_to_unmap() must hold a reference on the page.\n" - "+\t\t *\n" - "+\t\t * This is ok to invalidate even if are not unmapping anything\n" - "+\t\t * ie below page_check_address() returning NULL.\n" - "+\t\t */\n" - "+\t\tend = min(vma->vm_end, start + (PAGE_SIZE <<\n" - "+\t\t\t\t\t\tcompound_order(page)));\n" - "+\t\tmmu_notifier_invalidate_range_start(vma->vm_mm, start, end);\n" - "+\t}\n" - "+\n" - " \tpte = page_check_address(page, mm, address, &ptl, 0);\n" - " \tif (!pte)\n" - "-\t\tgoto out;\n" - "+\t\tgoto out_notify;\n" - " \n" - " \t/*\n" - " \t * If the page is mlock()d, we cannot swap it out.\n" - "@@ -1427,6 +1442,9 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,\n" - " \tpte_unmap_unlock(pte, ptl);\n" - " \tif (ret != SWAP_FAIL && ret != SWAP_MLOCK && !(flags & TTU_MUNLOCK))\n" - " \t\tmmu_notifier_invalidate_page(mm, address);\n" - "+out_notify:\n" - "+\tif (unlikely(PageHuge(page)))\n" - "+\t\tmmu_notifier_invalidate_range_end(vma->vm_mm, start, end);\n" - " out:\n" - " \treturn ret;\n" - " }\n" - "-- \n" - 2.17.1 + a behavior change for user of mmu notifier. -86e15832bf2b8fd1ca2e5c16c544aeba14924e400bfbdb4dbdea1ca9ca9e19fe +036a22649d8999e6c15ec1d76745a5a44b5438cc95c356ed41388faadf2b6a57
diff --git a/a/1.txt b/N2/1.txt index ad4a203..3d6e2ca 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -48,7 +48,7 @@ page_check_address(). For instance like below patch, which also only do the range invalidation for huge page which would avoid too much of a behavior change for user of mmu notifier. ->From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001 +From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com> Date: Thu, 31 Aug 2017 17:17:27 -0400 Subject: [PATCH] mm/rmap: update to new mmu_notifier semantic v2 diff --git a/a/content_digest b/N2/content_digest index 5c45d25..ee54ff9 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -77,7 +77,7 @@ "do the range invalidation for huge page which would avoid too much of\n" "a behavior change for user of mmu notifier.\n" "\n" - ">From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001\n" + "From 1be4109cfbf1c475ad67a5a57c87c74fd183ab1d Mon Sep 17 00:00:00 2001\n" "From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com>\n" "Date: Thu, 31 Aug 2017 17:17:27 -0400\n" "Subject: [PATCH] mm/rmap: update to new mmu_notifier semantic v2\n" @@ -176,4 +176,4 @@ "-- \n" 2.17.1 -86e15832bf2b8fd1ca2e5c16c544aeba14924e400bfbdb4dbdea1ca9ca9e19fe +5308617ea684af21aecae572e185c3f28a68e743dec96889528088ae0da40b56
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.