Skip to content

Commit 65d3632

Browse files
graysky2robimarko
authored andcommitted
x86: make CONFIG_NR_CPUS a tunable (2-512)
Add KERNEL_NR_CPUS option in Global build settings → Kernel build options, allowing users to set maximum CPU count (2-512) for the image. Defaults: - x86_64: 512 CPUs (backward compatible) - x86: 8 CPUs (fix broken single-CPU default) Per-CPU data structures consume ~100-200KB each. On a 4-core system configured to NR_CPUS=4, this frees approx 76 MB of RAM: (512 - 4) × 150 KB = ~76 MB Note: CONFIG_NR_CPUS_RANGE_{BEGIN,END}= and CONFIG_NR_CPUS_DEFAULT= are set by the build system and will default to 2/512/64 per arch/x86/Kconfig These are harmless metadata and don't affect memory allocation. Note pending openwrt/openwrt#21407 Signed-off-by: John Audia <therealgraysky@proton.me> Link: openwrt/openwrt#21078 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent c907579 commit 65d3632

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

config/Config-kernel.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ config KERNEL_RISCV_PMU_SBI
6464
bool
6565
depends on riscv64
6666

67+
config KERNEL_NR_CPUS
68+
int "Maximum number of CPUs (2-512)" if TARGET_x86
69+
range 2 512 if TARGET_x86
70+
default 512 if TARGET_x86_64
71+
default 8 if TARGET_x86
72+
help
73+
Maximum number of CPUs supported by the kernel.
74+
Each CPU allocates approximately 100-200KB of RAM for
75+
per-CPU data structures.
76+
77+
Sample values:
78+
4 - Ultra-low-level desktops e.g. Intel N150
79+
8 - Low-level desktops e.g. Intel N305
80+
16 - Mid-level dekstops e.g. AMD Ryzen 7
81+
32 - High-level desktops e.g. AMD Ryzen 9/Intel Core i9
82+
384 - High-level server e.g. AMD EPYC 9965
83+
84+
Lower values reduce memory usage. Set to match your hardware
85+
for optimal memory efficiency.
86+
6787
config KERNEL_X86_VSYSCALL_EMULATION
6888
bool "Enable vsyscall emulation"
6989
depends on x86_64

target/linux/x86/config-6.18

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,6 @@ CONFIG_NLS=y
328328
# CONFIG_NOHIGHMEM is not set
329329
CONFIG_NO_HZ=y
330330
CONFIG_NO_HZ_IDLE=y
331-
CONFIG_NR_CPUS=1
332-
CONFIG_NR_CPUS_DEFAULT=1
333-
CONFIG_NR_CPUS_RANGE_BEGIN=1
334-
CONFIG_NR_CPUS_RANGE_END=1
335331
# CONFIG_NSC_GPIO is not set
336332
CONFIG_NVRAM=y
337333
# CONFIG_OF is not set

0 commit comments

Comments
 (0)