[PATCH] arm: allow single CPU configuration by adjusting NR_CPUS range and defaults

Suchit Karunakaran posted 1 patch 2 months, 1 week ago
arch/arm/Kconfig | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] arm: allow single CPU configuration by adjusting NR_CPUS range and defaults
Posted by Suchit Karunakaran 2 months, 1 week ago
Previously, the NR_CPUS config for ARM required a minimum of 2 CPUs.
This patch changes the minimum NR_CPUS to 1 when SMP is not enabled,
sets range to exactly 1 if !SMP, allowing only a single CPU setting and
adds conditional defaults:
    - default to 1 if SMP is disabled (uniprocessor)
    - default to 4 if SMP is enabled (multiprocessor)

Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
---
 arch/arm/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3072731fe09c..23acee38721e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1063,11 +1063,13 @@ config KASAN_SHADOW_OFFSET
 	default 0xffffffff
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
+	int "Maximum number of CPUs (1-32)"
+	range 1 1 if !SMP
 	range 2 16 if DEBUG_KMAP_LOCAL
 	range 2 32 if !DEBUG_KMAP_LOCAL
 	depends on SMP
-	default "4"
+	default "1" if !SMP
+	default "4" if SMP
 	help
 	  The maximum number of CPUs that the kernel can support.
 	  Up to 32 CPUs can be supported, or up to 16 if kmap_local()
-- 
2.50.1
Re: [PATCH] arm: allow single CPU configuration by adjusting NR_CPUS range and defaults
Posted by Russell King (Oracle) 2 months, 1 week ago
On Thu, Jul 24, 2025 at 10:56:03PM +0530, Suchit Karunakaran wrote:
> Previously, the NR_CPUS config for ARM required a minimum of 2 CPUs.
> This patch changes the minimum NR_CPUS to 1 when SMP is not enabled,
> sets range to exactly 1 if !SMP, allowing only a single CPU setting and
> adds conditional defaults:
>     - default to 1 if SMP is disabled (uniprocessor)
>     - default to 4 if SMP is enabled (multiprocessor)
> 
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>

This hasn't been tested. NR_CPUS depends on SMP, so if SMP is not
enabled, then NR_CPUS doesn't exist in the configuration. Therefore,
providing a default for !SMP is meaningless. 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH] arm: allow single CPU configuration by adjusting NR_CPUS range and defaults
Posted by Suchit K 2 months, 1 week ago
On Thu, 24 Jul 2025 at 23:16, Russell King (Oracle)
<linux@armlinux.org.uk> wrote:
>
> On Thu, Jul 24, 2025 at 10:56:03PM +0530, Suchit Karunakaran wrote:
> > Previously, the NR_CPUS config for ARM required a minimum of 2 CPUs.
> > This patch changes the minimum NR_CPUS to 1 when SMP is not enabled,
> > sets range to exactly 1 if !SMP, allowing only a single CPU setting and
> > adds conditional defaults:
> >     - default to 1 if SMP is disabled (uniprocessor)
> >     - default to 4 if SMP is enabled (multiprocessor)
> >
> > Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
>
> This hasn't been tested. NR_CPUS depends on SMP, so if SMP is not
> enabled, then NR_CPUS doesn't exist in the configuration. Therefore,
> providing a default for !SMP is meaningless.
>

Oops, I think I misunderstood the intent of commit
278d1ed65e25d80af7c3a112d707b3f70516ddb4(cpumask: make CONFIG_NR_CPUS
always valid). And sorry for not testing it, I wasn't exactly sure how
to test it. Could you please point out the issues so I can fix them
properly? I appreciate your patience. I’m still learning my way around
kernel development and trying to improve. Thanks!