]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/hugetlb.c: fix unnecessary address expansion of pmd sharing
authorLi Xinhai <lixinhai.lxh@gmail.com>
Thu, 31 Dec 2020 22:04:09 +0000 (22:04 +0000)
committerJohannes Weiner <hannes@cmpxchg.org>
Thu, 31 Dec 2020 22:04:09 +0000 (22:04 +0000)
commit71067a4b74571c15ce65fd6a3bbbf54e2b8f50df
treec77ded37dc80007d1b039d926e0b8ced94736a18
parenta168fae5c5d2d75b4d4df5133ac2ac9c09ffb81d
mm/hugetlb.c: fix unnecessary address expansion of pmd sharing

The current code would unnecessarily expand the address range.  Consider
one example, (start, end) = (1G-2M, 3G+2M), and (vm_start, vm_end) =
(1G-4M, 3G+4M), the expected adjustment should be keep (1G-2M, 3G+2M)
without expand.  But the current result will be (1G-4M, 3G+4M).  Actually,
the range (1G-4M, 1G) and (3G, 3G+4M) would never been involved in pmd
sharing.

After this patch, if pud aligned *start across vm_start, then we know the
*start and vm_start are in same pud_index, and vm_start is not pud
aligned, so don't adjust *start.  Same logic applied to *end.

Mike said:

: The 'adjusted range' is used for calls to mmu notifiers and cache(tlb)
: flushing.  Since the current code unnecessarily expands the range in
: some cases, more entries than necessary would be flushed.  This
: would/could result in performance degradation.  However, this is highly
: dependent on the user runtime.  Is there a combination of vma layout
: and calls to actually hit this issue?  If the issue is hit, will those
: entries unnecessarily flushed be used again and need to be
: unnecessarily reloaded?

Link: https://lkml.kernel.org/r/20201229042125.2663029-1-lixinhai.lxh@gmail.com
Fixes: commit 75802ca66354 ("mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible")
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c