2.5-dj: configurable NR_CPUS
Subsystems (5)
PATCH 1/1 2.5-dj: configurable NR_CPUS
Dave,
Attached patch is a lovely rendition of the CONFIG_NR_CPUS patch Andrew and I have been tossing around.
The patch allows the user to set a sane value for NR_CPUS at compile-time if building an SMP kernel. The benefits are saved cycles and memory/object size reduction.
Further, this patch defines a per-arch default value for NR_CPUS thus 64-bit architectures can support a value of 64 instead of the current global 32.
The patch is tested on i386 with various values for NR_CPUS. Other 32-bit architectures will be fine with the default but may need minor fixing of poor assumptions to boot with other values. 64-bit architectures may need further fixing as I defaulted them to 64.
Patch is against 2.5.23-dj2. Enjoy,
Robert Love
arch/alpha/config.in +1 -0
@@ -232,6 +232,7 @@ if [ "$CONFIG_SMP" = "y" ]; then define_bool CONFIG_HAVE_DEC_LOCK y + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 fi if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
arch/i386/Config.help +8 -0
@@ -25,6 +25,14 @@ If you don't know what to do here, say N. +CONFIG_NR_CPUS + This allows you to specify the maximum number of CPUs which this + kernel will support. The maximum supported value is 32 and the + minimum value which makes sense is 2. + + This is purely to save memory - each supported CPU adds + approximately eight kilobytes to the kernel image. + CONFIG_PREEMPT This option reduces the latency of the kernel when reacting to real-time or interactive events by allowing a low priority process to
arch/i386/config.in +1 -0
@@ -164,6 +164,7 @@ define_bool CONFIG_X86_IO_APIC y fi else + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 bool 'Multiquad NUMA system' CONFIG_MULTIQUAD fi
arch/i386/defconfig +1 -0
@@ -74,6 +74,7 @@ # CONFIG_PREEMPT is not set # CONFIG_MULTIQUAD is not set CONFIG_HAVE_DEC_LOCK=y +CONFIG_NR_CPUS=32 # # General options
arch/ia64/config.in +4 -0
@@ -95,6 +95,10 @@ tristate '/proc/pal support' CONFIG_IA64_PALINFO tristate '/proc/efi/vars support' CONFIG_EFI_VARS +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 +fi + tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC
arch/ia64/defconfig +1 -0
@@ -61,6 +61,7 @@ CONFIG_EFI_VARS=y CONFIG_BINFMT_ELF=y # CONFIG_BINFMT_MISC is not set +CONFIG_NR_CPUS=64 # # ACPI Support
arch/mips/config.in +2 -0
@@ -501,6 +501,8 @@ bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ if [ "$CONFIG_SMP" != "y" ]; then bool 'Run uncached' CONFIG_MIPS_UNCACHED +else + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 fi endmenu
arch/mips64/config.in +2 -0
@@ -248,6 +248,8 @@ bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ if [ "$CONFIG_SMP" != "y" ]; then bool 'Run uncached' CONFIG_MIPS_UNCACHED +else + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 fi endmenu
arch/mips64/defconfig +1 -0
@@ -32,6 +32,7 @@ # CONFIG_EISA is not set # CONFIG_MCA is not set # CONFIG_SBUS is not set +CONFIG_NR_CPUS=64 # # CPU selection
arch/parisc/config.in +4 -0
@@ -18,6 +18,10 @@ # bool 'Symmetric multi-processing support' CONFIG_SMP define_bool CONFIG_SMP n +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 +fi + bool 'Kernel Debugger support' CONFIG_KWDB # define_bool CONFIG_KWDB n
arch/ppc/config.in +1 -0
@@ -172,6 +172,7 @@ bool 'Symmetric multi-processing support' CONFIG_SMP if [ "$CONFIG_SMP" = "y" ]; then bool ' Distribute interrupts on all CPUs by default' CONFIG_IRQ_ALL_CPUS + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 fi if [ "$CONFIG_SMP" != "y" ]; then bool 'Preemptible Kernel' CONFIG_PREEMPT
arch/ppc64/config.in +1 -0
@@ -21,6 +21,7 @@ bool 'Symmetric multi-processing support' CONFIG_SMP if [ "$CONFIG_SMP" = "y" ]; then bool ' Distribute interrupts on all CPUs by default' CONFIG_IRQ_ALL_CPUS + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 if [ "$CONFIG_PPC_PSERIES" = "y" ]; then bool ' Hardware multithreading' CONFIG_HMT fi
arch/ppc64/defconfig +1 -0
@@ -38,6 +38,7 @@ CONFIG_IRQ_ALL_CPUS=y # CONFIG_HMT is not set # CONFIG_PREEMPT is not set +CONFIG_NR_CPUS=64 # # General setup
arch/s390/config.in +3 -0
@@ -20,6 +20,9 @@ comment 'Processor type and features' bool 'Symmetric multi-processing support' CONFIG_SMP bool 'IEEE FPU emulation' CONFIG_MATHEMU +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 +fi endmenu mainmenu_option next_comment
arch/s390/defconfig +1 -0
@@ -35,6 +35,7 @@ # CONFIG_SMP=y CONFIG_MATHEMU=y +CONFIG_NR_CPUS=64 # # Base setup
arch/s390x/config.in +3 -0
@@ -19,6 +19,9 @@ mainmenu_option next_comment comment 'Processor type and features' bool 'Symmetric multi-processing support' CONFIG_SMP +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 +fi bool 'Kernel support for 31 bit emulation' CONFIG_S390_SUPPORT if [ "$CONFIG_S390_SUPPORT" = "y" ]; then tristate 'Kernel support for 31 bit ELF binaries' CONFIG_BINFMT_ELF32
arch/s390x/defconfig +1 -0
@@ -36,6 +36,7 @@ CONFIG_SMP=y CONFIG_S390_SUPPORT=y CONFIG_BINFMT_ELF32=y +CONFIG_NR_CPUS=64 # # Base setup
arch/sparc/config.in +4 -0
@@ -17,6 +17,10 @@ bool 'Symmetric multi-processing support (does not work on sun4/sun4c)' CONFIG_SMP +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-32)' CONFIG_NR_CPUS 32 +fi + # Identify this as a Sparc32 build define_bool CONFIG_SPARC32 y
arch/sparc64/config.in +4 -0
@@ -17,6 +17,10 @@ bool 'Symmetric multi-processing support' CONFIG_SMP bool 'Preemptible kernel' CONFIG_PREEMPT +if [ "$CONFIG_SMP" = "y" ]; then + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 +fi + # Identify this as a Sparc64 build define_bool CONFIG_SPARC64 y
arch/sparc64/defconfig +1 -0
@@ -63,6 +63,7 @@ CONFIG_BINFMT_MISC=m # CONFIG_SUNOS_EMUL is not set CONFIG_SOLARIS_EMUL=m +CONFIG_NR_CPUS=64 # # Parallel port support
arch/x86_64/config.in +1 -0
@@ -54,6 +54,7 @@ fi if [ "$CONFIG_SMP" = "y" ]; then define_bool CONFIG_HAVE_DEC_LOCK y + int 'Maximum number of CPUs (2-64)' CONFIG_NR_CPUS 64 fi define_bool CONFIG_X86_MCE y
arch/x86_64/defconfig +1 -0
@@ -51,6 +51,7 @@ CONFIG_HAVE_DEC_LOCK=y CONFIG_X86_MCE=y # CONFIG_X86_MCE_NONFATAL is not set +CONFIG_NR_CPUS=64 # # Power management options
include/linux/threads.h +8 -2
@@ -8,10 +8,16 @@* /proc/sys/kernel/threads-max. */ +/* +* Maximum supported processors that can run under SMP. This value is +* set via configure setting. The maximum is equal to the size of the +* bitmasks used on that platform, i.e. 32 or 64. Setting this smaller +* saves quite a bit of memory. +*/ #ifdef CONFIG_SMP -#define NR_CPUS 32/* Max processors that can be running in SMP */ +#define NR_CPUS CONFIG_NR_CPUS#else -#define NR_CPUS 1 +#define NR_CPUS 1#endif #define MIN_THREADS_LEFT_FOR_ROOT 4
Quoted 5 lines · On 2002.06.20 Robert Love wrote:
Dave,
Attached patch is a lovely rendition of the
CONFIG_NR_CPUSpatch Andrew and I have been tossing around.
Default for alpha is missing ?
Signature · 4 lines
J.A. Magallon \ Software is like sex: It's better when it's free mailto:[email protected] \ -- Linus Torvalds, FSF T-shirt Linux werewolf 2.4.19-pre10-jam3, Mandrake Linux 8.3 (Cooker) for i586 gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk)
Quoted 7 lines · J.A. Magallon
Quoted 3 lines · On 2002.06.20 Robert Love wrote:
Attached patch is a lovely rendition of the
CONFIG_NR_CPUSpatch Andrew and I have been tossing around.Default for alpha is missing ?
No... the default in 64 in config.in. Do you mean there is no defconfig entry? Well that is because CONFIG_SMP is not set and CONFIG_NR_CPUS is dependent on it.
Robert Love
Quoted 8 lines · On 2002.06.20 Robert Love wrote:
Quoted 6 lines · J.A. Magallon
Quoted 3 lines · On 2002.06.20 Robert Love wrote:
Attached patch is a lovely rendition of the
CONFIG_NR_CPUSpatch Andrew and I have been tossing around.
Quoted 6 lines
Quoted 1 line
Default for alpha is missing ?
No... the default in 64 in config.in. Do you mean there is no defconfig entry? Well that is because
CONFIG_SMPis not set andCONFIG_NR_CPUSis dependent on it.
Ok.
Signature · 4 lines
J.A. Magallon \ Software is like sex: It's better when it's free mailto:[email protected] \ -- Linus Torvalds, FSF T-shirt Linux werewolf 2.4.19-pre10-jam3, Mandrake Linux 8.3 (Cooker) for i586 gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk)