On Thu, Aug 20, 2020 at 01:04:24PM -0700, Mike Kravetz wrote: > On 8/19/20 5:21 AM, gregkh@xxxxxxxxxxxxxxxxxxx wrote: > > > > The patch below does not apply to the 4.4-stable tree. > > If someone wants it applied there, or to any other stable or longterm > > tree, then please email the backport, including the original git commit > > id to <stable@xxxxxxxxxxxxxxx>. > > > > thanks, > > > > greg k-h > > >From d43b8a81c7f921aa52d55817390384053cd7be21 Mon Sep 17 00:00:00 2001 > From: Peter Xu <peterx@xxxxxxxxxx> > Date: Thu, 20 Aug 2020 10:38:02 -0700 > Subject: [PATCH] mm/hugetlb: fix calculation of > adjust_range_if_pmd_sharing_possible > > commit 75802ca66354a39ab8e35822747cd08b3384a99a upstream > > 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: 017b1660df89 ("mm: migration: fix migration of huge PMD shared pages") > Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> > Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Cc: <stable@xxxxxxxxxxxxxxx> > Link: http://lkml.kernel.org/r/20200730201636.74778-1-peterx@xxxxxxxxxx > Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> > --- > mm/hugetlb.c | 25 +++++++++++-------------- Thanks for all of the backports, now queued up. greg k-h