mm: speedup mremap on 1GB or larger regions
authorKalesh Singh <>
Tue, 15 Dec 2020 03:07:30 +0000 (19:07 -0800)
committerLinus Torvalds <>
Tue, 15 Dec 2020 20:13:40 +0000 (12:13 -0800)
mm: speedup mremap on 1GB or larger regions

Android needs to move large memory regions for garbage collection.  The GC
requires moving physical pages of multi-gigabyte heap using mremap.
During this move, the application threads have to be paused for
correctness.  It is critical to keep this pause as short as possible to
avoid jitters during user interaction.

Optimize mremap for >= 1GB-sized regions by moving at the PUD/PGD level if
the source and destination addresses are PUD-aligned.  For
CONFIG_PGTABLE_LEVELS == 3, moving at the PUD level in effect moves PGD
entries, since the PUD entry is “folded back” onto the PGD entry.  Add
HAVE_MOVE_PUD so that architectures where moving at the PUD level isn't
supported/tested can turn this off by not selecting the config.

Signed-off-by: Kalesh Singh <>
Acked-by: Kirill A. Shutemov <>
Reported-by: kernel test robot <>
Cc: Aneesh Kumar K.V <>
Cc: Anshuman Khandual <>
Cc: Arnd Bergmann <>
Cc: Borislav Petkov <>
Cc: Brian Geffon <>
Cc: Catalin Marinas <>
Cc: Christian Brauner <>
Cc: Dave Hansen <>
Cc: Frederic Weisbecker <>
Cc: Gavin Shan <>
Cc: Hassan Naveed <>
Cc: "H. Peter Anvin" <>
Cc: Ingo Molnar <>
Cc: Jia He <>
Cc: John Hubbard <>
Cc: Kees Cook <>
Cc: Krzysztof Kozlowski <>
Cc: Lokesh Gidra <>
Cc: Mark Rutland <>
Cc: Masahiro Yamada <>
Cc: Masami Hiramatsu <>
Cc: Mike Rapoport <>
Cc: Mina Almasry <>
Cc: Minchan Kim <>
Cc: Peter Zijlstra (Intel) <>
Cc: Ralph Campbell <>
Cc: Ram Pai <>
Cc: Sami Tolvanen <>
Cc: Sandipan Das <>
Cc: SeongJae Park <>
Cc: Shuah Khan <>
Cc: Steven Price <>
Cc: Suren Baghdasaryan <>
Cc: Thomas Gleixner <>
Cc: Will Deacon <>
Cc: Zi Yan <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>