]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
x86: make CONFIG_NR_CPUS a tunable (2-512)
authorJohn Audia <therealgraysky@proton.me>
Sun, 4 Jan 2026 15:31:43 +0000 (10:31 -0500)
committerRobert Marko <robimarko@gmail.com>
Sat, 28 Mar 2026 10:51:11 +0000 (11:51 +0100)
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 https://github.com/openwrt/openwrt/pull/21407

Signed-off-by: John Audia <therealgraysky@proton.me>
Link: https://github.com/openwrt/openwrt/pull/21078
Signed-off-by: Robert Marko <robimarko@gmail.com>
config/Config-kernel.in
target/linux/x86/config-6.18

index 15aa1896727576a1659d3e88224bace4104b0d30..c7e7682d1f721d8c16a4174639787fbf19ba519f 100644 (file)
@@ -64,6 +64,26 @@ config KERNEL_RISCV_PMU_SBI
        bool
        depends on riscv64
 
+config KERNEL_NR_CPUS
+       int "Maximum number of CPUs (2-512)" if TARGET_x86
+       range 2 512 if TARGET_x86
+       default 512 if TARGET_x86_64
+       default 8 if TARGET_x86
+       help
+         Maximum number of CPUs supported by the kernel.
+         Each CPU allocates approximately 100-200KB of RAM for
+         per-CPU data structures.
+
+         Sample values:
+           4   - Ultra-low-level desktops e.g. Intel N150
+           8   - Low-level desktops e.g. Intel N305
+           16  - Mid-level dekstops e.g. AMD Ryzen 7
+           32  - High-level desktops e.g. AMD Ryzen 9/Intel Core i9
+           384 - High-level server e.g. AMD EPYC 9965
+
+         Lower values reduce memory usage. Set to match your hardware
+         for optimal memory efficiency.
+
 config KERNEL_X86_VSYSCALL_EMULATION
        bool "Enable vsyscall emulation"
        depends on x86_64
index 9930e45c5079dd95876dbd5c0229da5d1cc0cf70..0486c5749aae8bb140471b966eeeedcde72c5f24 100644 (file)
@@ -328,10 +328,6 @@ CONFIG_NLS=y
 # CONFIG_NOHIGHMEM is not set
 CONFIG_NO_HZ=y
 CONFIG_NO_HZ_IDLE=y
-CONFIG_NR_CPUS=1
-CONFIG_NR_CPUS_DEFAULT=1
-CONFIG_NR_CPUS_RANGE_BEGIN=1
-CONFIG_NR_CPUS_RANGE_END=1
 # CONFIG_NSC_GPIO is not set
 CONFIG_NVRAM=y
 # CONFIG_OF is not set