Re: [External] Re: [PATCH v12 00/11] Parallel CPU bringup for x86_64

From: Usama Arif
Date: Mon Feb 27 2023 - 11:33:17 EST




On 27/02/2023 15:29, David Woodhouse wrote:
On Mon, 2023-02-27 at 06:14 +0000, Usama Arif wrote:

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 17bdd6122dca..5d709aa67df4 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -273,7 +273,11 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify,
SYM_L_GLOBAL)
         cmpl    (%rbx,%rcx,4), %edx
         jz      .Lsetup_cpu
         inc     %ecx
+#if (NR_CPUS == 1) || defined(CONFIG_FORCE_NR_CPUS)
+       cmpl    $NR_CPUS, %ecx
+#else
         cmpl    nr_cpu_ids(%rip), %ecx
+#endif
         jb      .Lfind_cpunr

         /*  APIC ID not found in the table. Drop the trampoline lock
and bail. */

The whitespace looks dodgy there but maybe that's just your mail client?

Given this code is already in #ifdef CONFIG_SMP, can NR_CPUS be 1?

Ah yes, we have

config NR_CPUS_RANGE_BEGIN
int
default NR_CPUS_RANGE_END if MAXSMP
default 1 if !SMP
default 2

in arch/x86/Kconfig which doesn't let us select 1 for NR_CPUS if SMP is enabled, so this should be enough
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 17bdd6122dca..c79ae67492e1 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -273,7 +273,11 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
cmpl (%rbx,%rcx,4), %edx
jz .Lsetup_cpu
inc %ecx
+#if defined(CONFIG_FORCE_NR_CPUS)
+ cmpl $NR_CPUS, %ebx
+#else
cmpl nr_cpu_ids(%rip), %ecx
+#endif
jb .Lfind_cpunr