arm64: make section size configurable for memory hotplug
Subsystems (2)
cover arm64: make section size configurable for memory hotplug
The section size defines the granularity of memory hotplug. This is currently hard coded to 1GB on arm64 linux, which defines that the least size of memblock that can be hotplugged out is 1GB. Some DDR configurations (especially low RAM and dual-rank DDRs) may have section sizes that are less than 1GB (ex. 512MB, 256MB etc.). Having an option to reduce the memblock size to section size or lower gives more granularity of memory hotplug. For example, a system with DDR section size of 512MB and kernel memblock size of 1GB, we would have to remove two segments of DDR sections in order to hotplug out atleast 1 memblock from kernel POV.
Section sizes of DDRs vary based on specs (number of ranks, channels, regions etc.) Making this section size configurable helps users to assign based on the DDR being used. The default is set to 1GB which is the current memblock size.
Sudarshan Rajagopalan (1):
arm64: Make section size configurable for memory hotplug
arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/1 arm64: make section size configurable for memory hotplug
Currently on arm64, memory section size is hard-coded to 1GB. Make this configurable if memory-hotplug is enabled, to support more finer granularity for hotplug-able memory.
--- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)
arch/arm64/Kconfig +11 -0
@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool y +config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)" + depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 30 + default 30 + help + Selects granularity of hotplug memory. Block size for + memory hotplug is represent as a power of 2. + If unsure, stick with default value. + config KERNEL_MODE_NEON def_bool y
arch/arm64/include/asm/sparsemem.h +4 -0
@@ -7,7 +7,11 @@#ifdef CONFIG_SPARSEMEM #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS +#ifndef CONFIG_MEMORY_HOTPLUG #define SECTION_SIZE_BITS 30 +#else +#define SECTION_SIZE_BITS CONFIG_HOTPLUG_SIZE_BITS +#endif #endif #endif
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 298
Quoted 10 lines · Sudarshan Rajagopalan
arch/arm64/Kconfig +2
-0@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool y +config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)"
block size (29 => 512MB, 30 => 1GB)"
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 305
Quoted 7 lines
arch/arm64/Kconfig +7
-0+ depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 30 + default 30 + help + Selects granularity of hotplug memory. Block size for + memory hotplug is represent as a power of 2.
represented
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 306
Quoted 1 line
arch/arm64/Kconfig +1
-0+ If unsure, stick with default value.
and all of the help text should be indented with 1 tab + 2 spaces.
thanks.
Signature · 1 line
~Randy
Hi Sudershan,
This patch (and the cover letter) does not copy LAKML even though the entire change here is arm64 specific. Please do copy all applicable mailing lists for a given patch.
Quoted 3 lines · Sudarshan Rajagopalan
Currently on arm64, memory section size is hard-coded to 1GB. Make this configurable if memory-hotplug is enabled, to support more finer granularity for hotplug-able memory.
Section size has always been decided by the platform. It cannot be a configurable option because the user would not know the constraints for memory representation on the platform and besides it also cannot be trusted.
Quoted 12 lines
Signed-off-by Sudarshan Rajagopalan <[email protected]>--- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)arch/arm64/Kconfig +0
-0
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 301
Quoted 8 lines
arch/arm64/Kconfig +5
-0@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool y +config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)" + depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 30
28 would not work for 64K pages.
Quoted 16 lines
arch/arm64/Kconfig +6
-0+ default 30 + help + Selects granularity of hotplug memory. Block size for + memory hotplug is represent as a power of 2. + If unsure, stick with default value. + config KERNEL_MODE_NEON def_bool yarch/arm64/include/asm/sparsemem.h +0
-0@@ -7,7 +7,11 @@
arch/arm64/include/asm/sparsemem.h line 17
Quoted 10 lines
arch/arm64/include/asm/sparsemem.h +4
-0#ifdef CONFIG_SPARSEMEM #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS +#ifndef CONFIG_MEMORY_HOTPLUG #define SECTION_SIZE_BITS 30 +#else +#define SECTION_SIZE_BITS CONFIG_HOTPLUG_SIZE_BITS +#endif #endif #endif
There was an inconclusive discussion regarding this last month.
https://lore.kernel.org/linux-arm-kernel/[email protected]/
I have been wondering if this would solve the problem for 4K page size config which requires PMD mapping for the vmemmap mapping while making section size bits dependent on max order. But this has not been tested properly.
arch/arm64/include/asm/sparsemem.h +13 -2
@@ -7,7 +7,18 @@#ifdef CONFIG_SPARSEMEM #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS -#define SECTION_SIZE_BITS 30 -#endif + +#ifdef CONFIG_ARM64_4K_PAGES +#define SECTION_SIZE_BITS 27 +#else +#ifdef CONFIG_FORCE_MAX_ZONEORDER +#define SECTION_SIZE_BITS (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) +#else +#define SECTION_SIZE_BITS 30 +#endif /* CONFIG_FORCE_MAX_ZONEORDER */ + +#endif /* CONFIG_ARM64_4K_PAGES */ + +#endif /* CONFIG_SPARSEMEM*/ #endif
Quoted 31 lines · Anshuman Khandual
Hi Sudershan,
This patch (and the cover letter) does not copy LAKML even though the entire change here is arm64 specific. Please do copy all applicable mailing lists for a given patch.
Quoted 3 lines · Sudarshan Rajagopalan
Currently on arm64, memory section size is hard-coded to 1GB. Make this configurable if memory-hotplug is enabled, to support more finer granularity for hotplug-able memory.
Section size has always been decided by the platform. It cannot be a configurable option because the user would not know the constraints for memory representation on the platform and besides it also cannot be trusted.
Quoted 15 lines
Signed-off-by Sudarshan Rajagopalan <[email protected]>--- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)arch/arm64/Kconfig +0
-0@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool y
Quoted 2 lines
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 298
Quoted 2 lines
arch/arm64/Kconfig +2
-0+config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)"
"Memory hotplug block size" and "HOTPLUG_SIZE_BITS" is confusing. It's the section size. Please use that terminology.
(if at all, it would have to be "minimum memory hot(un)plug granularity", but even that is somewhat misleading)
"SECTION_SIZE_BITS"
But I agree that letting the user configure it is sub-optimal.
Quoted 5 lines
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 301
Quoted 3 lines
arch/arm64/Kconfig +3
-0+ depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 3028 would not work for 64K pages.
@Anshuman, what's your feeling about changing this to 128 MB for 4k/16k base pages (as we have on x86-64 right now) and 512 MB for 64k as default for now?
(If we worry about the number of section bits in page->flags, we could glue it to vmemmap support where that does not matter)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 51 lines · David Hildenbrand
Quoted 31 lines · Anshuman Khandual
Hi Sudershan,
This patch (and the cover letter) does not copy LAKML even though the entire change here is arm64 specific. Please do copy all applicable mailing lists for a given patch.
Quoted 3 lines · Sudarshan Rajagopalan
Currently on arm64, memory section size is hard-coded to 1GB. Make this configurable if memory-hotplug is enabled, to support more finer granularity for hotplug-able memory.
Section size has always been decided by the platform. It cannot be a configurable option because the user would not know the constraints for memory representation on the platform and besides it also cannot be trusted.
Quoted 15 lines
Signed-off-by Sudarshan Rajagopalan <[email protected]>--- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)arch/arm64/Kconfig +0
-0@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool yQuoted 2 lines
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 298
Quoted 2 lines
arch/arm64/Kconfig +2
-0+config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)""Memory hotplug block size" and "
HOTPLUG_SIZE_BITS" is confusing. It's the section size. Please use that terminology.(if at all, it would have to be "minimum memory hot(un)plug granularity", but even that is somewhat misleading)
"
SECTION_SIZE_BITS"But I agree that letting the user configure it is sub-optimal.
Quoted 5 lines
arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 301
Quoted 3 lines
arch/arm64/Kconfig +3
-0+ depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 3028 would not work for 64K pages.
Quoted 3 lines
@Anshuman, what's your feeling about changing this to 128 MB for 4k/16k base pages (as we have on x86-64 right now) and 512 MB for 64k as default for now?
To summarize, the section size bits for each base page size config should always
a. Avoid (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
b. Provide minimum possible section size for a given base page config to
have increased agility during memory hotplug operations and reduced vmemmap wastage for sections with holes.
c. Allow 4K base page configs to have PMD based vmemmap mappings
Because CONFIG_FORCE_MAX_ZONEORDER is always defined on arm64 platform, the following would always avoid the condition (a)
SECTION_SIZE_BITS (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT)
- 22 (11 - 1 + 12) for 4K pages
- 24 (11 - 1 + 14) for 16K pages without THP
- 25 (12 - 1 + 14) for 16K pages with THP
- 26 (11 - 1 + 16) for 64K pages without THP
- 29 (14 - 1 + 16) for 64K pages with THP
Apart from overriding 4K base page size config to have 27 as section size bits, should not all other values be okay here ? But then wondering what benefit 128MB (27 bits) section size for 16K config would have ? OR the objective here is to match 16K page size config with default x86-64.
Quoted 3 lines
(If we worry about the number of section bits in
page->flags, we could glue it to vmemmap support where that does not matter)
Could you please elaborate ? Could smaller section size bits numbers like 22 or 24 create problems in page->flags without changing other parameters like NR_CPUS or NODES_SHIFT ? A quick test with 64K base page without THP i.e 26 bits in section size, fails to boot.
As you have suggested, probably constant defaults (128MB for 4K/16K, 512MB for 64K) might be better than depending on the CONFIG_FORCE_MAX_ZONEORDER, at least for now.
Quoted 4 lines
To summarize, the section size bits for each base page size config should always
a. Avoid (
MAX_ORDER- 1 +PAGE_SHIFT) >SECTION_SIZE_BITS
Pageblocks must also always fall completely into a section.
Quoted 4 lines
b. Provide minimum possible section size for a given base page config to
have increased agility during memory hotplug operations and reduced vmemmap wastage for sections with holes.
OTOH, making the section size too small (e.g., 16MB) creates way to many memory block devices in /sys/devices/system/memory/, and might consume too many page->flags bits in the !vmemmap case.
For bigger setups, we might, similar to x86-64 (e.g., >= 64 GiB), determine the memory_block_size_bytes() at runtime (spanning multiple sections then), once it becomes relevant.
Quoted 2 lines
c. Allow 4K base page configs to have PMD based vmemmap mappings
Agreed.
Quoted 12 lines
Because
CONFIG_FORCE_MAX_ZONEORDERis always defined on arm64 platform, the following would always avoid the condition (a)
SECTION_SIZE_BITS(CONFIG_FORCE_MAX_ZONEORDER- 1 +PAGE_SHIFT)- 22 (11 - 1 + 12) for 4K pages
- 24 (11 - 1 + 14) for 16K pages without THP
- 25 (12 - 1 + 14) for 16K pages with THP
- 26 (11 - 1 + 16) for 64K pages without THP
- 29 (14 - 1 + 16) for 64K pages with THP
Quoted 4 lines
Apart from overriding 4K base page size config to have 27 as section size bits, should not all other values be okay here ? But then wondering what benefit 128MB (27 bits) section size for 16K config would have ? OR the objective here is to match 16K page size config with default x86-64.
We don't want to have sections that are too small. We don't want to have sections that are too big :)
Not sure if we really want to allow setting e.g., a section size of 4 MB. That's just going to hurt. IMHO, something in the range of 64..256 MB is quite a good choice, where possible.
Quoted 8 lines
Quoted 4 lines
(If we worry about the number of section bits in
page->flags, we could glue it to vmemmap support where that does not matter)Could you please elaborate ? Could smaller section size bits numbers like 22 or 24 create problems in
page->flagswithout changing other parameters likeNR_CPUSorNODES_SHIFT? A quick test with 64K base page without THP
Yes, in the !vmemmap case, we have to store the section_nr in there. IIRC, it's less of an issue with section sizes like 128 MB.
Quoted 1 line
i.e 26 bits in section size, fails to boot.
26 bits would mean 64 MB, no? Not sure if that's possible even without THP (MAX_ORDER - 1, pageblock_order ...) on 64k pages. I'd assume 512 MB is the lowest we can go. I'd assume this would crash :)
Quoted 4 lines
As you have suggested, probably constant defaults (128MB for 4K/16K, 512MB for 64K) might be better than depending on the
CONFIG_FORCE_MAX_ZONEORDER, at least for now.
That's also what I would prefer, keeping it simple.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 68 lines · David Hildenbrand
Quoted 4 lines
To summarize, the section size bits for each base page size config should always
a. Avoid (
MAX_ORDER- 1 +PAGE_SHIFT) >SECTION_SIZE_BITSPageblocks must also always fall completely into a section.
Quoted 4 lines
b. Provide minimum possible section size for a given base page config to
have increased agility during memory hotplug operations and reduced vmemmap wastage for sections with holes.OTOH, making the section size too small (e.g., 16MB) creates way to many memory block devices in
/sys/devices/system/memory/, and might consume too manypage->flagsbits in the !vmemmap case.For bigger setups, we might, similar to x86-64 (e.g., >= 64 GiB), determine the
memory_block_size_bytes()at runtime (spanning multiple sections then), once it becomes relevant.Quoted 2 lines
c. Allow 4K base page configs to have PMD based vmemmap mappings
Agreed.
Quoted 12 lines
Because
CONFIG_FORCE_MAX_ZONEORDERis always defined on arm64 platform, the following would always avoid the condition (a)
SECTION_SIZE_BITS(CONFIG_FORCE_MAX_ZONEORDER- 1 +PAGE_SHIFT)- 22 (11 - 1 + 12) for 4K pages
- 24 (11 - 1 + 14) for 16K pages without THP
- 25 (12 - 1 + 14) for 16K pages with THP
- 26 (11 - 1 + 16) for 64K pages without THP
- 29 (14 - 1 + 16) for 64K pages with THPQuoted 4 lines
Apart from overriding 4K base page size config to have 27 as section size bits, should not all other values be okay here ? But then wondering what benefit 128MB (27 bits) section size for 16K config would have ? OR the objective here is to match 16K page size config with default x86-64.
We don't want to have sections that are too small. We don't want to have sections that are too big :)
Not sure if we really want to allow setting e.g., a section size of 4 MB. That's just going to hurt. IMHO, something in the range of 64..256 MB is quite a good choice, where possible.
Quoted 8 lines
Quoted 4 lines
(If we worry about the number of section bits in
page->flags, we could glue it to vmemmap support where that does not matter)Could you please elaborate ? Could smaller section size bits numbers like 22 or 24 create problems in
page->flagswithout changing other parameters likeNR_CPUSorNODES_SHIFT? A quick test with 64K base page without THPYes, in the !vmemmap case, we have to store the
section_nrin there. IIRC, it's less of an issue with section sizes like 128 MB.Quoted 1 line
i.e 26 bits in section size, fails to boot.
26 bits would mean 64 MB, no? Not sure if that's possible even without THP (
MAX_ORDER- 1,pageblock_order...) on 64k pages. I'd assume 512 MB is the lowest we can go. I'd assume this would crash :)Quoted 1 line
Quoted 5 lines
Quoted 3 lines
As you have suggested, probably constant defaults (128MB for 4K/16K, 512MB for 64K) might be better than depending on the
CONFIG_FORCE_MAX_ZONEORDER, at least for now.That's also what I would prefer, keeping it simple.
Okay sure, will send a RFC to begin with.
Quoted 71 lines · Anshuman Khandual
Quoted 68 lines · David Hildenbrand
Quoted 4 lines
To summarize, the section size bits for each base page size config should always
a. Avoid (
MAX_ORDER- 1 +PAGE_SHIFT) >SECTION_SIZE_BITSPageblocks must also always fall completely into a section.
Quoted 4 lines
b. Provide minimum possible section size for a given base page config to
have increased agility during memory hotplug operations and reduced vmemmap wastage for sections with holes.OTOH, making the section size too small (e.g., 16MB) creates way to many memory block devices in
/sys/devices/system/memory/, and might consume too manypage->flagsbits in the !vmemmap case.For bigger setups, we might, similar to x86-64 (e.g., >= 64 GiB), determine the
memory_block_size_bytes()at runtime (spanning multiple sections then), once it becomes relevant.Quoted 2 lines
c. Allow 4K base page configs to have PMD based vmemmap mappings
Agreed.
Quoted 12 lines
Because
CONFIG_FORCE_MAX_ZONEORDERis always defined on arm64 platform, the following would always avoid the condition (a)
SECTION_SIZE_BITS(CONFIG_FORCE_MAX_ZONEORDER- 1 +PAGE_SHIFT)- 22 (11 - 1 + 12) for 4K pages
- 24 (11 - 1 + 14) for 16K pages without THP
- 25 (12 - 1 + 14) for 16K pages with THP
- 26 (11 - 1 + 16) for 64K pages without THP
- 29 (14 - 1 + 16) for 64K pages with THPQuoted 4 lines
Apart from overriding 4K base page size config to have 27 as section size bits, should not all other values be okay here ? But then wondering what benefit 128MB (27 bits) section size for 16K config would have ? OR the objective here is to match 16K page size config with default x86-64.
We don't want to have sections that are too small. We don't want to have sections that are too big :)
Not sure if we really want to allow setting e.g., a section size of 4 MB. That's just going to hurt. IMHO, something in the range of 64..256 MB is quite a good choice, where possible.
Quoted 8 lines
Quoted 4 lines
(If we worry about the number of section bits in
page->flags, we could glue it to vmemmap support where that does not matter)Could you please elaborate ? Could smaller section size bits numbers like 22 or 24 create problems in
page->flagswithout changing other parameters likeNR_CPUSorNODES_SHIFT? A quick test with 64K base page without THPYes, in the !vmemmap case, we have to store the
section_nrin there. IIRC, it's less of an issue with section sizes like 128 MB.Quoted 1 line
i.e 26 bits in section size, fails to boot.
26 bits would mean 64 MB, no? Not sure if that's possible even without THP (
MAX_ORDER- 1,pageblock_order...) on 64k pages. I'd assume 512 MB is the lowest we can go. I'd assume this would crash :)Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
As you have suggested, probably constant defaults (128MB for 4K/16K, 512MB for 64K) might be better than depending on the
CONFIG_FORCE_MAX_ZONEORDER, at least for now.That's also what I would prefer, keeping it simple.
Okay sure, will send a RFC to begin with.
Note that there is
(Sudarshan missed to cc linux-mm)
Signature · 3 lines
Thanks, David / dhildenb
Quoted 78 lines · David Hildenbrand
Quoted 77 lines · Anshuman Khandual
Quoted 73 lines · David Hildenbrand
Quoted 4 lines
To summarize, the section size bits for each base page size config should always
a. Avoid (
MAX_ORDER- 1 +PAGE_SHIFT) >SECTION_SIZE_BITSPageblocks must also always fall completely into a section.
Quoted 4 lines
b. Provide minimum possible section size for a given base page config to
have increased agility during memory hotplug operations and reduced vmemmap wastage for sections with holes.OTOH, making the section size too small (e.g., 16MB) creates way to many memory block devices in
/sys/devices/system/memory/, and might consume too manypage->flagsbits in the !vmemmap case.For bigger setups, we might, similar to x86-64 (e.g., >= 64 GiB), determine the
memory_block_size_bytes()at runtime (spanning multiple sections then), once it becomes relevant.Quoted 2 lines
c. Allow 4K base page configs to have PMD based vmemmap mappings
Agreed.
Quoted 12 lines
Because
CONFIG_FORCE_MAX_ZONEORDERis always defined on arm64 platform, the following would always avoid the condition (a)
SECTION_SIZE_BITS(CONFIG_FORCE_MAX_ZONEORDER- 1 +PAGE_SHIFT)- 22 (11 - 1 + 12) for 4K pages
- 24 (11 - 1 + 14) for 16K pages without THP
- 25 (12 - 1 + 14) for 16K pages with THP
- 26 (11 - 1 + 16) for 64K pages without THP
- 29 (14 - 1 + 16) for 64K pages with THPQuoted 4 lines
Apart from overriding 4K base page size config to have 27 as section size bits, should not all other values be okay here ? But then wondering what benefit 128MB (27 bits) section size for 16K config would have ? OR the objective here is to match 16K page size config with default x86-64.
We don't want to have sections that are too small. We don't want to have sections that are too big :)
Not sure if we really want to allow setting e.g., a section size of 4 MB. That's just going to hurt. IMHO, something in the range of 64..256 MB is quite a good choice, where possible.
Quoted 8 lines
Quoted 4 lines
(If we worry about the number of section bits in
page->flags, we could glue it to vmemmap support where that does not matter)Could you please elaborate ? Could smaller section size bits numbers like 22 or 24 create problems in
page->flagswithout changing other parameters likeNR_CPUSorNODES_SHIFT? A quick test with 64K base page without THPYes, in the !vmemmap case, we have to store the
section_nrin there. IIRC, it's less of an issue with section sizes like 128 MB.Quoted 1 line
i.e 26 bits in section size, fails to boot.
26 bits would mean 64 MB, no? Not sure if that's possible even without THP (
MAX_ORDER- 1,pageblock_order...) on 64k pages. I'd assume 512 MB is the lowest we can go. I'd assume this would crash :)Quoted 4 lines
As you have suggested, probably constant defaults (128MB for 4K/16K, 512MB for 64K) might be better than depending on the
CONFIG_FORCE_MAX_ZONEORDER, at least for now.That's also what I would prefer, keeping it simple.
Quoted 9 lines
Quoted 2 lines
Okay sure, will send a RFC to begin with.
Note that there is
(Sudarshan missed to cc linux-mm)
Right, some how missed that. Anyways, ended up spending some time testing the change for various configs.
On 2021-01-05 22:11, Anshuman Khandual wrote:
Hello Anshuman, thanks for your response.
(+ Will)
Quoted 5 lines
Hi Sudershan,
This patch (and the cover letter) does not copy LAKML even though the entire change here is arm64 specific. Please do copy all applicable mailing lists for a given patch.
I used ./scripts/get_maintainer.pl patch.patch to get the maintainers list. It somehow didn't mention LAKML. I've added the mailing list to this thread.
Quoted 58 lines · Sudarshan Rajagopalan
Quoted 3 lines
Currently on arm64, memory section size is hard-coded to 1GB. Make this configurable if memory-hotplug is enabled, to support more finer granularity for hotplug-able memory.
Section size has always been decided by the platform. It cannot be a configurable option because the user would not know the constraints for memory representation on the platform and besides it also cannot be trusted.
Quoted 12 lines
Signed-off-by Sudarshan Rajagopalan <[email protected]>--- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/sparsemem.h | 4 ++++ 2 files changed, 15 insertions(+)arch/arm64/Kconfig +0
-0arch/arm64/Kconfig config ARCH_ENABLE_MEMORY_HOTREMOVE · line 301
Quoted 8 lines
arch/arm64/Kconfig +5
-0@@ -294,6 +294,17 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE config SMP def_bool y +config HOTPLUG_SIZE_BITS + int "Memory hotplug block size(29 => 512MB 30 => 1GB)" + depends on SPARSEMEM + depends on MEMORY_HOTPLUG + range 28 3028 would not work for 64K pages.
Quoted 24 lines
arch/arm64/Kconfig +6
-0+ default 30 + help + Selects granularity of hotplug memory. Block size for + memory hotplug is represent as a power of 2. + If unsure, stick with default value. + config KERNEL_MODE_NEON def_bool yarch/arm64/include/asm/sparsemem.h +4
-0@@ -7,7 +7,11 @@#ifdef CONFIG_SPARSEMEM #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS +#ifndef CONFIG_MEMORY_HOTPLUG #define SECTION_SIZE_BITS 30 +#else +#define SECTION_SIZE_BITS CONFIG_HOTPLUG_SIZE_BITS +#endif #endif
Quoted 6 lines
arch/arm64/include/asm/sparsemem.h line 17
Quoted 2 lines
arch/arm64/include/asm/sparsemem.h +0
-0#endif There was an inconclusive discussion regarding this last month.
Thanks for pointing out this thread. Looking into all the comments, major concern with reducing the section size seems to be risk of running out of bits in the page flags. And while SECTION_SIZE must be greater or equal to highest order page in the buddy, it must also satisfy cases for 4K page size where it doesn't break PMD mapping for vmemmap - and hence SECTION_SIZE_BITS of 27 could be set for 4K page size that could allow 2MB PMD mappings for each 128M(2^27) block size.
While this is the least value that can be set (27 for 4K_PAGE, MAX_ZONEORDER - 1 + PAGE_SHIFT for 16K or 64K_PAGE), are there any concerns with setting higher values (but <= 30bits). It seems like any arbitrary number between this range could be applied that wouldn't break vmemmaps. That's why we were thinking of letting the user configure it since this directly impacts memory hotplug about the granularity or least size that can be hot (up)plugged. The current setting of 1GB for arm64 does poses a lot of challenges in utilizing memory hotplug via a driver, esp. for low RAM targets. I agree its sub-optimal in some sense but wanted to know the maintainers opinion on this.
Also, the patch introduced in that thread does seem to help reduce vmemmap memory if there are large holes. So there is some merit in reducing the section size along with memory hotplug leveraging it.
Quoted 32 lines
I have been wondering if this would solve the problem for 4K page size config which requires PMD mapping for the vmemmap mapping while making section size bits dependent on max order. But this has not been tested properly.
arch/arm64/include/asm/sparsemem.h +13
-2@@ -7,7 +7,18 @@#ifdef CONFIG_SPARSEMEM #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS -#define SECTION_SIZE_BITS 30 -#endif + +#ifdef CONFIG_ARM64_4K_PAGES +#define SECTION_SIZE_BITS 27 +#else +#ifdef CONFIG_FORCE_MAX_ZONEORDER +#define SECTION_SIZE_BITS (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) +#else +#define SECTION_SIZE_BITS 30 +#endif /* CONFIG_FORCE_MAX_ZONEORDER */ + +#endif /* CONFIG_ARM64_4K_PAGES */ + +#endif /* CONFIG_SPARSEMEM*/
Quoted 1 line
#endif
SECTION_SIZE_BITS of 27 for 4K_PAGES should be fine for us. Would you know if there's possibility of this patch above being applied in upstream anytime soon? This is in regards with Generic Kernel Image (GKI) that we are working with Google. If this patch would positively end up in upstream, we could apply it in aosp kernel.
Sudarshan
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project