linux-stable/arch
Joel Fernandes (Google) 2c91bd4a4e mm: speed up mremap by 20x on large regions
Android needs to mremap large regions of memory during memory management
related operations.  The mremap system call can be really slow if THP is
not enabled.  The bottleneck is move_page_tables, which is copying each
pte at a time, and can be really slow across a large map.  Turning on
THP may not be a viable option, and is not for us.  This patch speeds up
the performance for non-THP system by copying at the PMD level when
possible.

The speedup is an order of magnitude on x86 (~20x).  On a 1GB mremap,
the mremap completion times drops from 3.4-3.6 milliseconds to 144-160
microseconds.

Before:
Total mremap time for 1GB data: 3521942 nanoseconds.
Total mremap time for 1GB data: 3449229 nanoseconds.
Total mremap time for 1GB data: 3488230 nanoseconds.

After:
Total mremap time for 1GB data: 150279 nanoseconds.
Total mremap time for 1GB data: 144665 nanoseconds.
Total mremap time for 1GB data: 158708 nanoseconds.

If THP is enabled the optimization is mostly skipped except in certain
situations.

[joel@joelfernandes.org: fix 'move_normal_pmd' unused function warning]
  Link: http://lkml.kernel.org/r/20181108224457.GB209347@google.com
Link: http://lkml.kernel.org/r/20181108181201.88826-3-joelaf@google.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 13:13:48 -08:00
..
alpha mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
arc mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
arm mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
arm64 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
c6x fls: change parameter to unsigned int 2019-01-04 13:13:46 -08:00
csky fls: change parameter to unsigned int 2019-01-04 13:13:46 -08:00
h8300 kgdb patches for 4.20-rc1 2019-01-01 15:38:14 -08:00
hexagon mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
ia64 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
m68k mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
microblaze mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
mips mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
nds32 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
nios2 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
openrisc mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
parisc mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
powerpc mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
riscv mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
s390 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
sh mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
sparc mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
um mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
unicore32 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
x86 mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
xtensa mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
.gitignore
Kconfig mm: speed up mremap by 20x on large regions 2019-01-04 13:13:48 -08:00