Skip to content

Commit d432b8d

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64: mm: Reclaim unused vmemmap region for vmalloc use
The vmemmap array is statically sized based on the maximum supported size of the virtual address space, but it is located inside the upper VA region, which is statically sized based on the *minimum* supported size of the VA space. This doesn't matter much when using 64k pages, which is the only configuration that currently supports 52-bit virtual addressing. However, upcoming LPA2 support will change this picture somewhat, as in that case, the vmemmap array will take up more than 25% of the upper VA region when using 4k pages. Given that most of this space is never used when running on a system that does not support 52-bit virtual addressing, let's reclaim the unused vmemmap area in that case. Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Acked-by: Mark Rutland <[email protected]>
1 parent 32697ff commit d432b8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
* VMALLOC range.
1919
*
2020
* VMALLOC_START: beginning of the kernel vmalloc space
21-
* VMALLOC_END: extends to the available space below vmemmap, PCI I/O space
22-
* and fixed mappings
21+
* VMALLOC_END: extends to the available space below vmemmap
2322
*/
2423
#define VMALLOC_START (MODULES_END)
24+
#if VA_BITS == VA_BITS_MIN
2525
#define VMALLOC_END (VMEMMAP_START - SZ_8M)
26+
#else
27+
#define VMEMMAP_UNUSED_NPAGES ((_PAGE_OFFSET(vabits_actual) - PAGE_OFFSET) >> PAGE_SHIFT)
28+
#define VMALLOC_END (VMEMMAP_START + VMEMMAP_UNUSED_NPAGES * sizeof(struct page) - SZ_8M)
29+
#endif
2630

2731
#define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
2832

0 commit comments

Comments
 (0)