arch/arm64/Kconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
The arm64 Kconfig for NR_CPUS previously required a minimum of 2 CPUs.
This patch changes the minimum allowed CPUs to 1, enabling single-core
non-SMP configurations.
Additionally, the default value for NR_CPUS is now conditional:
- Defaults to 1 if SMP is not selected (non-SMP systems)
- Defaults to 512 if SMP is enabled
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
---
arch/arm64/Kconfig | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 393d71124f5d..9b2970f7c5ec 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1528,9 +1528,10 @@ config SCHED_SMT
places. If unsure say N here.
config NR_CPUS
- int "Maximum number of CPUs (2-4096)"
- range 2 4096
- default "512"
+ int "Maximum number of CPUs (1-4096)"
+ range 1 4096
+ default "1" if !SMP
+ default "512" if SMP
config HOTPLUG_CPU
bool "Support for hot-pluggable CPUs"
--
2.50.1
On Thu, Jul 24, 2025 at 10:26:39PM +0530, Suchit Karunakaran wrote: > The arm64 Kconfig for NR_CPUS previously required a minimum of 2 CPUs. > This patch changes the minimum allowed CPUs to 1, enabling single-core > non-SMP configurations. Do you have such single-core system? > config NR_CPUS > - int "Maximum number of CPUs (2-4096)" > - range 2 4096 > - default "512" > + int "Maximum number of CPUs (1-4096)" > + range 1 4096 > + default "1" if !SMP > + default "512" if SMP It's been some time since we forced CONFIG_SMP always on for arm64. -- Catalin
On Fri, 25 Jul 2025 at 14:06, Catalin Marinas <catalin.marinas@arm.com> wrote: > > On Thu, Jul 24, 2025 at 10:26:39PM +0530, Suchit Karunakaran wrote: > > The arm64 Kconfig for NR_CPUS previously required a minimum of 2 CPUs. > > This patch changes the minimum allowed CPUs to 1, enabling single-core > > non-SMP configurations. > > Do you have such single-core system? No, I don't have a single core system. I've just used single core VMs using QEMU, etc, but I don't know if it's equivalent. > > > config NR_CPUS > > - int "Maximum number of CPUs (2-4096)" > > - range 2 4096 > > - default "512" > > + int "Maximum number of CPUs (1-4096)" > > + range 1 4096 > > + default "1" if !SMP > > + default "512" if SMP > > It's been some time since we forced CONFIG_SMP always on for arm64. > I'm sorry, I wasn't aware of it. Thanks for the clarification.
On 24/07/25 10:26 PM, Suchit Karunakaran wrote: > The arm64 Kconfig for NR_CPUS previously required a minimum of 2 CPUs. > This patch changes the minimum allowed CPUs to 1, enabling single-core > non-SMP configurations. > > Additionally, the default value for NR_CPUS is now conditional: > - Defaults to 1 if SMP is not selected (non-SMP systems) > - Defaults to 512 if SMP is enabled Just curious - what actually prompted this change ? > > Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com> > --- > arch/arm64/Kconfig | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 393d71124f5d..9b2970f7c5ec 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -1528,9 +1528,10 @@ config SCHED_SMT > places. If unsure say N here. > > config NR_CPUS > - int "Maximum number of CPUs (2-4096)" > - range 2 4096 > - default "512" > + int "Maximum number of CPUs (1-4096)" > + range 1 4096 > + default "1" if !SMP > + default "512" if SMP > > config HOTPLUG_CPU > bool "Support for hot-pluggable CPUs"
On Fri, 25 Jul 2025 at 07:46, Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> On 24/07/25 10:26 PM, Suchit Karunakaran wrote:
> > The arm64 Kconfig for NR_CPUS previously required a minimum of 2 CPUs.
> > This patch changes the minimum allowed CPUs to 1, enabling single-core
> > non-SMP configurations.
> >
> > Additionally, the default value for NR_CPUS is now conditional:
> > - Defaults to 1 if SMP is not selected (non-SMP systems)
> > - Defaults to 512 if SMP is enabled
>
> Just curious - what actually prompted this change ?
>
Hi, sorry I think I should've explained it in the commit message. So,
in linux/include/linux/threads.h, there's this fixme comment:
/*
* Maximum supported processors. Setting this smaller saves quite a
* bit of memory. Use nr_cpu_ids instead of this except for static bitmaps.
*/
#ifndef CONFIG_NR_CPUS
/* FIXME: This should be fixed in the arch's Kconfig */
#define CONFIG_NR_CPUS 1
#endif
And the original commit is as follows:
commit 278d1ed65e25d80af7c3a112d707b3f70516ddb4
Author: Rusty Russell <rusty@rustcorp.com.au>
Date: Tue Dec 30 09:05:12 2008 +1030
cpumask: make CONFIG_NR_CPUS always valid.
Impact: cleanup
Currently we have NR_CPUS, which is 1 on UP, and CONFIG_NR_CPUS on
SMP. If we make CONFIG_NR_CPUS always valid (and always 1 on !SMP),
we can skip the middleman.
This also allows us to find and check all the unaudited NR_CPUS usage
as we prepare for v. large NR_CPUS.
To avoid breaking every arch, we cheat and do this for the moment
in the header if the arch doesn't.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mike Travis <travis@sgi.com>
diff --git a/include/linux/threads.h b/include/linux/threads.h
index 38d1a5d6568e..052b12bec8bd 100644
--- a/include/linux/threads.h
+++ b/include/linux/threads.h
@@ -8,17 +8,17 @@
*/
/*
- * 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.
+ * Maximum supported processors. Setting this smaller saves quite a
+ * bit of memory. Use nr_cpu_ids instead of this except for static bitmaps.
*/
-#ifdef CONFIG_SMP
-#define NR_CPUS CONFIG_NR_CPUS
-#else
-#define NR_CPUS 1
+#ifndef CONFIG_NR_CPUS
+/* FIXME: This should be fixed in the arch's Kconfig */
+#define CONFIG_NR_CPUS 1
#endif
+/* Places which use this should consider cpumask_var_t. */
+#define NR_CPUS CONFIG_NR_CPUS
+
#define MIN_THREADS_LEFT_FOR_ROOT 4
/*
This motivated me to do this. Please let me know if I misunderstood
something or I'm doing something incorrectly.
© 2016 - 2026 Red Hat, Inc.