Skip to content

Commit f0b13ee

Browse files
Sudarshan Rajagopalanwilldeacon
authored andcommitted
arm64/sparsemem: reduce SECTION_SIZE_BITS
memory_block_size_bytes() determines the memory hotplug granularity i.e the amount of memory which can be hot added or hot removed from the kernel. The generic value here being MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) for memory_block_size_bytes() on platforms like arm64 that does not override. Current SECTION_SIZE_BITS is 30 i.e 1GB which is large and a reduction here increases memory hotplug granularity, thus improving its agility. A reduced section size also reduces memory wastage in vmemmmap mapping for sections with large memory holes. So we try to set the least section size as possible. A section size bits selection must follow: (MAX_ORDER - 1 + PAGE_SHIFT) <= SECTION_SIZE_BITS CONFIG_FORCE_MAX_ZONEORDER is always defined on arm64 and so just following it would help achieve the smallest section size. SECTION_SIZE_BITS = (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) SECTION_SIZE_BITS = 22 (11 - 1 + 12) i.e 4MB for 4K pages SECTION_SIZE_BITS = 24 (11 - 1 + 14) i.e 16MB for 16K pages without THP SECTION_SIZE_BITS = 25 (12 - 1 + 14) i.e 32MB for 16K pages with THP SECTION_SIZE_BITS = 26 (11 - 1 + 16) i.e 64MB for 64K pages without THP SECTION_SIZE_BITS = 29 (14 - 1 + 16) i.e 512MB for 64K pages with THP But there are other problems in reducing SECTION_SIZE_BIT. Reducing it by too much would over populate /sys/devices/system/memory/ and also consume too many page->flags bits in the !vmemmap case. Also section size needs to be multiple of 128MB to have PMD based vmemmap mapping with CONFIG_ARM64_4K_PAGES. Given these constraints, lets just reduce the section size to 128MB for 4K and 16K base page size configs, and to 512MB for 64K base page size config. Signed-off-by: Sudarshan Rajagopalan <[email protected]> Suggested-by: Anshuman Khandual <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Logan Gunthorpe <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Steven Price <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Mike Rapoport <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/43843c5e092bfe3ec4c41e3c8c78a7ee35b69bb0.1611206601.git.sudaraja@codeaurora.org Signed-off-by: Will Deacon <[email protected]>
1 parent edb739e commit f0b13ee

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

arch/arm64/include/asm/sparsemem.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,26 @@
77

88
#ifdef CONFIG_SPARSEMEM
99
#define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS
10-
#define SECTION_SIZE_BITS 30
11-
#endif
10+
11+
/*
12+
* Section size must be at least 512MB for 64K base
13+
* page size config. Otherwise it will be less than
14+
* (MAX_ORDER - 1) and the build process will fail.
15+
*/
16+
#ifdef CONFIG_ARM64_64K_PAGES
17+
#define SECTION_SIZE_BITS 29
18+
19+
#else
20+
21+
/*
22+
* Section size must be at least 128MB for 4K base
23+
* page size config. Otherwise PMD based huge page
24+
* entries could not be created for vmemmap mappings.
25+
* 16K follows 4K for simplicity.
26+
*/
27+
#define SECTION_SIZE_BITS 27
28+
#endif /* CONFIG_ARM64_64K_PAGES */
29+
30+
#endif /* CONFIG_SPARSEMEM*/
1231

1332
#endif

0 commit comments

Comments
 (0)