From 65d36329e36aee26629036c96a998fb507a74379 Mon Sep 17 00:00:00 2001 From: John Audia Date: Sun, 4 Jan 2026 10:31:43 -0500 Subject: [PATCH] x86: make CONFIG_NR_CPUS a tunable (2-512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Link: https://github.com/openwrt/openwrt/pull/21078 Signed-off-by: Robert Marko --- config/Config-kernel.in | 20 ++++++++++++++++++++ target/linux/x86/config-6.18 | 4 ---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 15aa189672..c7e7682d1f 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -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 diff --git a/target/linux/x86/config-6.18 b/target/linux/x86/config-6.18 index 9930e45c50..0486c5749a 100644 --- a/target/linux/x86/config-6.18 +++ b/target/linux/x86/config-6.18 @@ -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