mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible
This is found by code observation only. Firstly, the worst case scenario should assume the whole range was covered by pmd sharing. The old algorithm might not work as expected for ranges like (1g-2m, 1g+2m), where the adjusted range should be (0, 1g+2m) but the expected range should be (0, 2g). Since at it, remove the loop since it should not be required. With that, the new code should be faster too when the invalidating range is huge. Mike said: : With range (1g-2m, 1g+2m) within a vma (0, 2g) the existing code will only : adjust to (0, 1g+2m) which is incorrect. : : We should cc stable. The original reason for adjusting the range was to : prevent data corruption (getting wrong page). Since the range is not : always adjusted correctly, the potential for corruption still exists. : : However, I am fairly confident that adjust_range_if_pmd_sharing_possible : is only gong to be called in two cases: : : 1) for a single page : 2) for range == entire vma : : In those cases, the current code should produce the correct results. : : To be safe, let's just cc stable. Fixes: 017b1660 ("mm: migration: fix migration of huge PMD shared pages") Signed-off-by:Peter Xu <peterx@redhat.com> Signed-off-by:
Andrew Morton <akpm@linux-foundation.org> Reviewed-by:
Mike Kravetz <mike.kravetz@oracle.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: <stable@vger.kernel.org> Link: http://lkml.kernel.org/r/20200730201636.74778-1-peterx@redhat.com Signed-off-by:
Linus Torvalds <torvalds@linux-foundation.org>
parent
42742d9b
-
mentioned in commit 85ce79dd
-
mentioned in commit 734654ae
-
mentioned in commit e3796644
-
mentioned in commit fe5f83b1
-
mentioned in commit d6bca2a8
-
mentioned in commit d9821110
-
mentioned in commit 66a01387
-
mentioned in commit 1b1347c0
-
mentioned in commit d645eb72
-
mentioned in commit e335952d
-
mentioned in commit 0697f123
-
mentioned in commit 2e235c3a
Please register or sign in to comment