[tip:,x86/apic] smp: Provide 'setup_max_cpus' definition on UP too

Message ID 170894808668.398.2149303099223176501.tip-bot2@tip-bot2
State New
Headers
Series [tip:,x86/apic] smp: Provide 'setup_max_cpus' definition on UP too |

Commit Message

tip-bot2 for Thomas Gleixner Feb. 26, 2024, 11:48 a.m. UTC
  The following commit has been merged into the x86/apic branch of tip:

Commit-ID:     429bb0269058e2e1f4ab69a0d33d374933aa15b9
Gitweb:        https://git.kernel.org/tip/429bb0269058e2e1f4ab69a0d33d374933aa15b9
Author:        Ingo Molnar <mingo@kernel.org>
AuthorDate:    Mon, 26 Feb 2024 12:07:31 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 26 Feb 2024 12:13:40 +01:00

smp: Provide 'setup_max_cpus' definition on UP too

This was already defined locally by init/main.c, but let's make
it generic, as arch/x86/kernel/cpu/topology.c is going to make
use of it to have more uniform code.

[ Keep it a C variable, not a define, because there's
  some namespace overlap for the 'setup_max_cpus' token
  in existing function argument names. ]

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
--
---
 include/linux/smp.h | 2 ++
 init/main.c         | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
  

Comments

Borislav Petkov Feb. 26, 2024, 3:02 p.m. UTC | #1
On Mon, Feb 26, 2024 at 11:48:06AM -0000, tip-bot2 for Ingo Molnar wrote:
> The following commit has been merged into the x86/apic branch of tip:
> 
> Commit-ID:     429bb0269058e2e1f4ab69a0d33d374933aa15b9
> Gitweb:        https://git.kernel.org/tip/429bb0269058e2e1f4ab69a0d33d374933aa15b9
> Author:        Ingo Molnar <mingo@kernel.org>
> AuthorDate:    Mon, 26 Feb 2024 12:07:31 +01:00
> Committer:     Ingo Molnar <mingo@kernel.org>
> CommitterDate: Mon, 26 Feb 2024 12:13:40 +01:00
> 
> smp: Provide 'setup_max_cpus' definition on UP too
> 
> This was already defined locally by init/main.c, but let's make
> it generic, as arch/x86/kernel/cpu/topology.c is going to make
> use of it to have more uniform code.
> 
> [ Keep it a C variable, not a define, because there's
>   some namespace overlap for the 'setup_max_cpus' token
>   in existing function argument names. ]
> 
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> --
> ---
>  include/linux/smp.h | 2 ++
>  init/main.c         | 1 -
>  2 files changed, 2 insertions(+), 1 deletion(-)

That one needs some work:

$ grep setup_max_cpus 13-37-17-randconfig-x86_64-2517.log
..
/include/linux/smp.h:221:27: warning: ‘setup_max_cpus’ defined but not used [-Wunused-const-variable=]
$ grep setup_max_cpus 13-37-17-randconfig-x86_64-2517.log  | wc -l
122

very noisy.

randconfig attached.
  
Thomas Gleixner Feb. 26, 2024, 6:19 p.m. UTC | #2
On Mon, Feb 26 2024 at 11:48, tip-bot2 for Ingo Molnar wrote:
> --- a/include/linux/smp.h
> +++ b/include/linux/smp.h
> @@ -218,6 +218,8 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
>  static inline void kick_all_cpus_sync(void) {  }
>  static inline void wake_up_all_idle_cpus(void) {  }
>  
> +static const unsigned int setup_max_cpus = 0;

Oops. I missed that when looking at the patch. This is in a header file
and will be instantiated a gazillion times where ever the header is
included. It want's to be a define, no?

Thanks,

        tglx
---
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -218,7 +218,7 @@ smp_call_function_any(const struct cpuma
 static inline void kick_all_cpus_sync(void) {  }
 static inline void wake_up_all_idle_cpus(void) {  }
 
-static const unsigned int setup_max_cpus = 0;
+#define setup_max_cpus	(0)
 
 #ifdef CONFIG_UP_LATE_INIT
 extern void __init up_late_init(void);
  
Ingo Molnar Feb. 27, 2024, 9:19 a.m. UTC | #3
* Borislav Petkov <bp@alien8.de> wrote:

> On Mon, Feb 26, 2024 at 11:48:06AM -0000, tip-bot2 for Ingo Molnar wrote:
> > The following commit has been merged into the x86/apic branch of tip:
> > 
> > Commit-ID:     429bb0269058e2e1f4ab69a0d33d374933aa15b9
> > Gitweb:        https://git.kernel.org/tip/429bb0269058e2e1f4ab69a0d33d374933aa15b9
> > Author:        Ingo Molnar <mingo@kernel.org>
> > AuthorDate:    Mon, 26 Feb 2024 12:07:31 +01:00
> > Committer:     Ingo Molnar <mingo@kernel.org>
> > CommitterDate: Mon, 26 Feb 2024 12:13:40 +01:00
> > 
> > smp: Provide 'setup_max_cpus' definition on UP too
> > 
> > This was already defined locally by init/main.c, but let's make
> > it generic, as arch/x86/kernel/cpu/topology.c is going to make
> > use of it to have more uniform code.
> > 
> > [ Keep it a C variable, not a define, because there's
> >   some namespace overlap for the 'setup_max_cpus' token
> >   in existing function argument names. ]
> > 
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Ingo Molnar <mingo@kernel.org>
> > --
> > ---
> >  include/linux/smp.h | 2 ++
> >  init/main.c         | 1 -
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> That one needs some work:
> 
> $ grep setup_max_cpus 13-37-17-randconfig-x86_64-2517.log
> ...
> ./include/linux/smp.h:221:27: warning: ‘setup_max_cpus’ defined but not used [-Wunused-const-variable=]
> $ grep setup_max_cpus 13-37-17-randconfig-x86_64-2517.log  | wc -l
> 122
> 
> very noisy.

Yeah, a bit sad.

So I resolved this all with using #define and (first) fixing a namespace 
collision that broke with the #define:

  4c8a49854130 smp: Avoid 'setup_max_cpus' namespace collision/shadowing
  3c2f8859ae1c smp: Provide 'setup_max_cpus' definition on UP too
  6be4ec29685c x86/apic: Build the x86 topology enumeration functions on UP APIC builds too

Thanks,

	Ingo
  

Patch

diff --git a/include/linux/smp.h b/include/linux/smp.h
index e87520d..5a5985f 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -218,6 +218,8 @@  smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
 static inline void kick_all_cpus_sync(void) {  }
 static inline void wake_up_all_idle_cpus(void) {  }
 
+static const unsigned int setup_max_cpus = 0;
+
 #ifdef CONFIG_UP_LATE_INIT
 extern void __init up_late_init(void);
 static inline void smp_init(void) { up_late_init(); }
diff --git a/init/main.c b/init/main.c
index e24b078..5644bb1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -603,7 +603,6 @@  static int __init rdinit_setup(char *str)
 __setup("rdinit=", rdinit_setup);
 
 #ifndef CONFIG_SMP
-static const unsigned int setup_max_cpus = NR_CPUS;
 static inline void setup_nr_cpu_ids(void) { }
 static inline void smp_prepare_cpus(unsigned int maxcpus) { }
 #endif