x86/Kconfig: Allow NR_CPUS between 512 and 8192
PATCH 1/1 x86/Kconfig: Allow NR_CPUS between 512 and 8192
Today there is no way one can choose any value between 512 to 8192 for NR_CPUS seamlessly. NR_CPUS is guarded by NR_CPUS_RANGE_END which is further dependent on CPUMASK_OFFSTACK to allow NR_CPUs > 512.
For x86, CPUMASK_OFFSTACK can only be enabled either by selecting MAXSMP or DEBUG_PER_CPU_MAPS. Both of these options has a cost to pay. MAXSMP will increase the NR_CPUS to 8192 which will have impact on kernel image size whereas DEBUG_PER_CPU_MAPS will have additional run time overheads. Thus there is no good way to have NR_CPUS anything between 512 to 8192.
Fix this by selecting CPUMASK_OFFSTACK if NR_CPUS > 512 and let NR_CPUS_RANGE_END set to 8192.
On a Hyper-V system where max number of CPUs are only 2048, this patch saves around 1 MB of kernel image size, compare to MAXSMP.
---
I want to mention that in ARM and other archs its very simple to select any value for NR_CPUS. This is an attempt to have more flexibilty in x86 arch as well to choose NR_CPUS.
Some of the earlier discussions reated to it which could be of interest:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
Another approach I can think of is to allow CPUMASK_OFFSTACK to be enabled more freely like the below patch of Libo Chen, that will also solve the problem I am addressing. But I feel this patch may have impact on other archs as well and I am not sure if that is in best interest of all the archs.
https://lore.kernel.org/lkml/[email protected]/
arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/Kconfig +2 -2
@@ -34,6 +34,7 @@ config X86_64 select SWIOTLB select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 + select CPUMASK_OFFSTACK if NR_CPUS > 512 config FORCE_DYNAMIC_FTRACE def_bool y
@@ -1006,8 +1007,7 @@ config NR_CPUS_RANGE_END config NR_CPUS_RANGE_END int depends on X86_64 - default 8192 if SMP && CPUMASK_OFFSTACK - default 512 if SMP && !CPUMASK_OFFSTACK + default 8192 if SMP default 1 if !SMP config NR_CPUS_DEFAULT
Signature · 1 line
2.34.1
Quoted 63 lines · Saurabh Sengar
Today there is no way one can choose any value between 512 to 8192 for
NR_CPUSseamlessly.NR_CPUSis guarded byNR_CPUS_RANGE_ENDwhich is further dependent onCPUMASK_OFFSTACKto allowNR_CPUs> 512.For x86,
CPUMASK_OFFSTACKcan only be enabled either by selecting MAXSMP orDEBUG_PER_CPU_MAPS. Both of these options has a cost to pay. MAXSMP will increase theNR_CPUSto 8192 which will have impact on kernel image size whereasDEBUG_PER_CPU_MAPSwill have additional run time overheads. Thus there is no good way to haveNR_CPUSanything between 512 to 8192.Fix this by selecting
CPUMASK_OFFSTACKifNR_CPUS> 512 and letNR_CPUS_RANGE_ENDset to 8192.On a Hyper-V system where max number of CPUs are only 2048, this patch saves around 1 MB of kernel image size, compare to MAXSMP.
Signed-off-by Saurabh Sengar <[email protected]>---
I want to mention that in ARM and other archs its very simple to select any value for
NR_CPUS. This is an attempt to have more flexibilty in x86 arch as well to chooseNR_CPUS.Some of the earlier discussions reated to it which could be of interest:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/Another approach I can think of is to allow
CPUMASK_OFFSTACKto be enabled more freely like the below patch of Libo Chen, that will also solve the problem I am addressing. But I feel this patch may have impact on other archs as well and I am not sure if that is in best interest of all the archs.https://lore.kernel.org/lkml/[email protected]/
arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/Kconfig +2
-2@@ -34,6 +34,7 @@ config X86_64 select SWIOTLB select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 + select CPUMASK_OFFSTACK if NR_CPUS > 512 config FORCE_DYNAMIC_FTRACE def_bool y@@ -1006,8 +1007,7 @@ config NR_CPUS_RANGE_END config NR_CPUS_RANGE_END int depends on X86_64 - default 8192 if SMP && CPUMASK_OFFSTACK - default 512 if SMP && !CPUMASK_OFFSTACK + default 8192 if SMP default 1 if !SMP config NR_CPUS_DEFAULTSignature · 2 lines
-- 2.34.1
x86 Maintainers,
Kind reminder to have your feedback on this patch.
- Saurabh
Quoted 67 lines · Saurabh Singh Sengar
Quoted 63 lines · Saurabh Sengar
Today there is no way one can choose any value between 512 to 8192 for
NR_CPUSseamlessly.NR_CPUSis guarded byNR_CPUS_RANGE_ENDwhich is further dependent onCPUMASK_OFFSTACKto allowNR_CPUs> 512.For x86,
CPUMASK_OFFSTACKcan only be enabled either by selecting MAXSMP orDEBUG_PER_CPU_MAPS. Both of these options has a cost to pay. MAXSMP will increase theNR_CPUSto 8192 which will have impact on kernel image size whereasDEBUG_PER_CPU_MAPSwill have additional run time overheads. Thus there is no good way to haveNR_CPUSanything between 512 to 8192.Fix this by selecting
CPUMASK_OFFSTACKifNR_CPUS> 512 and letNR_CPUS_RANGE_ENDset to 8192.On a Hyper-V system where max number of CPUs are only 2048, this patch saves around 1 MB of kernel image size, compare to MAXSMP.
Signed-off-by Saurabh Sengar <[email protected]>---
I want to mention that in ARM and other archs its very simple to select any value for
NR_CPUS. This is an attempt to have more flexibilty in x86 arch as well to chooseNR_CPUS.Some of the earlier discussions reated to it which could be of interest:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/Another approach I can think of is to allow
CPUMASK_OFFSTACKto be enabled more freely like the below patch of Libo Chen, that will also solve the problem I am addressing. But I feel this patch may have impact on other archs as well and I am not sure if that is in best interest of all the archs.https://lore.kernel.org/lkml/[email protected]/
arch/x86/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/Kconfig +2
-2@@ -34,6 +34,7 @@ config X86_64 select SWIOTLB select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 + select CPUMASK_OFFSTACK if NR_CPUS > 512 config FORCE_DYNAMIC_FTRACE def_bool y@@ -1006,8 +1007,7 @@ config NR_CPUS_RANGE_END config NR_CPUS_RANGE_END int depends on X86_64 - default 8192 if SMP && CPUMASK_OFFSTACK - default 512 if SMP && !CPUMASK_OFFSTACK + default 8192 if SMP default 1 if !SMP config NR_CPUS_DEFAULTSignature · 2 lines
-- 2.34.1x86 Maintainers,
Quoted 4 lines
Kind reminder to have your feedback on this patch.
- Saurabh
ping
Hello Maintainers,
Please review the patch and share your feedback.
Some of the earlier discussions related to this patch:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
Thanks,
Hardik