From: Liam R. Howlett Date: Mon, 21 Sep 2020 16:22:15 +0000 (-0400) Subject: mm: Change mmap do_brk_flags() to populate the existing VMA X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d854db8bd54b39b72ae421edd5287667b68c6cb6;p=users%2Fjedix%2Flinux-maple.git mm: Change mmap do_brk_flags() to populate the existing VMA do_brk_flags has already located the modified VMA, so just populate the region. Add mm_populate_vma() to mm/gup.c and call the new function which ignores errors. Benckmarks in KVM before: $ ./mmtests/work/sources/wis-0-installed/brk1_threads testcase:brk increase/decrease of one page warmup min:886150 max:886150 total:886150 min:901488 max:901488 total:901488 min:897594 max:897594 total:897594 min:897422 max:897422 total:897422 min:900700 max:900700 total:900700 min:900714 max:900714 total:900714 measurement min:903016 max:903016 total:903016 min:901224 max:901224 total:901224 min:902626 max:902626 total:902626 min:900518 max:900518 total:900518 Benchmark in KVM after change: /mmtests/work/sources/wis-0-installed/brk1_threads testcase:brk increase/decrease of one page warmup min:895650 max:895650 total:895650 min:904936 max:904936 total:904936 min:904776 max:904776 total:904776 min:905358 max:905358 total:905358 min:908792 max:908792 total:908792 min:907648 max:907648 total:907648 measurement min:904368 max:904368 total:904368 min:903936 max:903936 total:903936 min:904720 max:904720 total:904720 min:906626 max:906626 total:906626 Signed-off-by: Liam R. Howlett --- diff --git a/mm/gup.c b/mm/gup.c index 102877ed77a4..522f8fd491ea 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1431,6 +1431,26 @@ long populate_vma_page_range(struct vm_area_struct *vma, NULL, NULL, locked); } +/* + * mm_populate_vma() - Populate a single range in a single vma. + * @vma: The vma to populate. + * @start: The start address to populate + * @end: The end address to stop populating + * + * Note: Ignores errors. + */ +void mm_populate_vma(struct vm_area_struct *vma, unsigned long start, + unsigned long end) +{ + struct mm_struct *mm = current->mm; + int locked = 1; + + mmap_read_lock(mm); + populate_vma_page_range(vma, start, end, &locked); + if (locked) + mmap_read_unlock(mm); +} + /* * __mm_populate - populate and/or mlock pages within a range of address space. * diff --git a/mm/mmap.c b/mm/mmap.c index cffa49eaf2b8..3e8426baba8b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -277,7 +277,7 @@ success: mmap_write_unlock(mm); userfaultfd_unmap_complete(mm, &uf); if (populate) - mm_populate(oldbrk, newbrk - oldbrk); + mm_populate_vma(vma_brk, oldbrk, newbrk); return brk; out: