From 8801a1510bd35b935fd6621e8e38e7aee726d99e Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 21 Sep 2020 12:22:15 -0400 Subject: [PATCH] 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 --- mm/gup.c | 20 ++++++++++++++++++++ mm/mmap.c | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index 98eb8e6d2609..b06e2a6d9018 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 46ea4a9748d8..968305485c8c 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: -- 2.50.1