linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: try to simplify NR_CPUS config
@ 2018-02-09 22:01 Randy Dunlap
  2018-02-09 22:39 ` Linus Torvalds
  0 siblings, 1 reply; 12+ messages in thread
From: Randy Dunlap @ 2018-02-09 22:01 UTC (permalink / raw)
  To: Linus Torvalds, X86 ML; +Cc: LKML

From: Randy Dunlap <rdunlap@infradead.org>

Clean up and simplify the X86 NR_CPUS Kconfig symbol/option by
introducing MIN_CONFIG_CPUS, MAX_CONFIG_CPUS, and DEF_CONFIG_CPUS.
Then combine some default values when their conditionals can be
reduced.

Also move the X86_BIGSMP kconfig option inside an "if X86_32"/"endif"
config block and drop its explicit "depends on X86_32".

This is a rather literal interpretation of Linus's suggestion.
It mostly moves the complexity to other kconfig symbols, although
a little bit more reduction can be done, especially in
RANGE_BEGIN_CPUS, at the sake of understandability, so I chose
to leave it more understandable (at least to me).

Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Link: lkml.kernel.org/r/CA+55aFzOd3j6ZUSkEwTdk85qtt1JywOtm3ZAb-qAvt8_hJ6D4A@mail.gmail.com
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: x86@kernel.org
---
 arch/x86/Kconfig |   48 ++++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 15 deletions(-)

--- linux-next-20180209.orig/arch/x86/Kconfig
+++ linux-next-20180209/arch/x86/Kconfig
@@ -423,12 +423,6 @@ config X86_MPPARSE
 	  For old smp systems that do not have proper acpi support. Newer systems
 	  (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
 
-config X86_BIGSMP
-	bool "Support for big SMP systems with more than 8 CPUs"
-	depends on X86_32 && SMP
-	---help---
-	  This option is needed for the systems that have more than 8 CPUs
-
 config GOLDFISH
        def_bool y
        depends on X86_GOLDFISH
@@ -460,6 +454,12 @@ config INTEL_RDT
 	  Say N if unsure.
 
 if X86_32
+config X86_BIGSMP
+	bool "Support for big SMP systems with more than 8 CPUs"
+	depends on SMP
+	---help---
+	  This option is needed for the systems that have more than 8 CPUs
+
 config X86_EXTENDED_PLATFORM
 	bool "Support for extended (non-PC) x86 platforms"
 	default y
@@ -949,17 +949,35 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
+config RANGE_BEGIN_CPUS
+	int
+	default 2 if SMP && X86_32
+	default 2 if SMP && !MAXSMP && X86_64
+	default 8192 if SMP && MAXSMP && X86_64
+	default 1 if !SMP
+	default 2
+
+config RANGE_END_CPUS
+	int
+	default 8 if SMP && X86_32 && !X86_BIGSMP
+	default 64 if SMP && X86_32 && X86_BIGSMP
+	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64
+	default 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64
+	default 8192 if SMP && MAXSMP && X86_64
+	default 1 if !SMP
+
+config DEF_CONFIG_CPUS
+	int
+	default 1 if !SMP
+	default 8192 if MAXSMP
+	default 32 if SMP && X86_BIGSMP
+	default 8 if SMP && X86_32
+	default 64 if SMP
+
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range 2 8 if SMP && X86_32 && !X86_BIGSMP
-	range 2 64 if SMP && X86_32 && X86_BIGSMP
-	range 2 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64
-	range 2 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64
-	default "1" if !SMP
-	default "8192" if MAXSMP
-	default "32" if SMP && X86_BIGSMP
-	default "8" if SMP && X86_32
-	default "64" if SMP
+	range RANGE_BEGIN_CPUS RANGE_END_CPUS
+	default DEF_CONFIG_CPUS
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86: try to simplify NR_CPUS config
  2018-02-09 22:01 [PATCH] x86: try to simplify NR_CPUS config Randy Dunlap
@ 2018-02-09 22:39 ` Linus Torvalds
  2018-02-10  0:51   ` [PATCH v2] x86: " Randy Dunlap
  0 siblings, 1 reply; 12+ messages in thread
From: Linus Torvalds @ 2018-02-09 22:39 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: X86 ML, LKML

On Fri, Feb 9, 2018 at 2:01 PM, Randy Dunlap <rdunlap@infradead.org> wrote:
>
> This is a rather literal interpretation of Linus's suggestion.

I think it can be simplified a bit more.

If you move the definition of RANGE_END_CPUS up to before
RANGE_BEGIN_CPUS, you can then make the RANGE_BEGIN_CPUS just be
something like

   default 1 if !SMP
   default RANGE_END_CPUS if MAXSMP
   default 2

which makes a whole lot more sense.

and if you split that RANGE_END_CPUS so that the x86-32 and x86-64
cases are separate, that makes *those* more understandable. It also
makes sense to separate since X86_BIGSMP is 32-bit only.

But yes, this looks like it's in the right direction, where we can
make each step be fairly obvious, instead of the current NR_CPUS mess
that is entirely impossible to parse for mere humans.

               Linus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] x86: simplify NR_CPUS config
  2018-02-09 22:39 ` Linus Torvalds
@ 2018-02-10  0:51   ` Randy Dunlap
  2018-02-10 11:36     ` [PATCH] x86/Kconfig: Further simplify the " Ingo Molnar
  2018-02-11 12:11     ` [tip:x86/urgent] x86/Kconfig: Simplify " tip-bot for Randy Dunlap
  0 siblings, 2 replies; 12+ messages in thread
From: Randy Dunlap @ 2018-02-10  0:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: X86 ML, LKML

From: Randy Dunlap <rdunlap@infradead.org>

Clean up and simplify the X86 NR_CPUS Kconfig symbol/option by
introducing RANGE_BEGIN_CPUS, RANGE_END_CPUS, and DEF_CONFIG_CPUS.
Then combine some default values when their conditionals can be
reduced.

Also move the X86_BIGSMP kconfig option inside an "if X86_32"/"endif"
config block and drop its explicit "depends on X86_32".

Combine the max. 8192 cases of RANGE_END_CPUS (X86_64 only).
Split RANGE_END_CPUS and DEF_CONFIG_CPUS into separate cases for
X86_32 and X86_64.

Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Link: lkml.kernel.org/r/CA+55aFzOd3j6ZUSkEwTdk85qtt1JywOtm3ZAb-qAvt8_hJ6D4A@mail.gmail.com
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: x86@kernel.org
---
 arch/x86/Kconfig |   57 +++++++++++++++++++++++++++++++++------------
 1 file changed, 42 insertions(+), 15 deletions(-)

v2: more simplification as suggested by Linus; also separate the
    X86_32 and X86_64 configs.

--- linux-next-20180209.orig/arch/x86/Kconfig
+++ linux-next-20180209/arch/x86/Kconfig
@@ -423,12 +423,6 @@ config X86_MPPARSE
 	  For old smp systems that do not have proper acpi support. Newer systems
 	  (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
 
-config X86_BIGSMP
-	bool "Support for big SMP systems with more than 8 CPUs"
-	depends on X86_32 && SMP
-	---help---
-	  This option is needed for the systems that have more than 8 CPUs
-
 config GOLDFISH
        def_bool y
        depends on X86_GOLDFISH
@@ -460,6 +454,12 @@ config INTEL_RDT
 	  Say N if unsure.
 
 if X86_32
+config X86_BIGSMP
+	bool "Support for big SMP systems with more than 8 CPUs"
+	depends on SMP
+	---help---
+	  This option is needed for the systems that have more than 8 CPUs
+
 config X86_EXTENDED_PLATFORM
 	bool "Support for extended (non-PC) x86 platforms"
 	default y
@@ -949,17 +949,44 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
+config RANGE_END_CPUS
+	int
+	depends on X86_32
+	default 8 if SMP && !X86_BIGSMP
+	default 64 if SMP && X86_BIGSMP
+	default 1 if !SMP
+
+config RANGE_END_CPUS
+	int
+	depends on X86_64
+	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK
+	default 8192 if SMP && (MAXSMP || CPUMASK_OFFSTACK)
+	default 1 if !SMP
+
+config RANGE_BEGIN_CPUS
+	int
+	default 1 if !SMP
+	default RANGE_END_CPUS if MAXSMP
+	default 2
+
+config DEF_CONFIG_CPUS
+	int
+	depends on X86_32
+	default 1 if !SMP
+	default 32 if X86_BIGSMP
+	default 8 if SMP
+
+config DEF_CONFIG_CPUS
+	int
+	depends on X86_64
+	default 1 if !SMP
+	default 8192 if MAXSMP
+	default 64 if SMP
+
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range 2 8 if SMP && X86_32 && !X86_BIGSMP
-	range 2 64 if SMP && X86_32 && X86_BIGSMP
-	range 2 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64
-	range 2 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64
-	default "1" if !SMP
-	default "8192" if MAXSMP
-	default "32" if SMP && X86_BIGSMP
-	default "8" if SMP && X86_32
-	default "64" if SMP
+	range RANGE_BEGIN_CPUS RANGE_END_CPUS
+	default DEF_CONFIG_CPUS
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10  0:51   ` [PATCH v2] x86: " Randy Dunlap
@ 2018-02-10 11:36     ` Ingo Molnar
  2018-02-10 11:38       ` Ingo Molnar
  2018-02-11 12:12       ` [tip:x86/urgent] " tip-bot for Ingo Molnar
  2018-02-11 12:11     ` [tip:x86/urgent] x86/Kconfig: Simplify " tip-bot for Randy Dunlap
  1 sibling, 2 replies; 12+ messages in thread
From: Ingo Molnar @ 2018-02-10 11:36 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linus Torvalds, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra


* Randy Dunlap <rdunlap@infradead.org> wrote:

> From: Randy Dunlap <rdunlap@infradead.org>
> 
> Clean up and simplify the X86 NR_CPUS Kconfig symbol/option by
> introducing RANGE_BEGIN_CPUS, RANGE_END_CPUS, and DEF_CONFIG_CPUS.
> Then combine some default values when their conditionals can be
> reduced.
> 
> Also move the X86_BIGSMP kconfig option inside an "if X86_32"/"endif"
> config block and drop its explicit "depends on X86_32".
> 
> Combine the max. 8192 cases of RANGE_END_CPUS (X86_64 only).
> Split RANGE_END_CPUS and DEF_CONFIG_CPUS into separate cases for
> X86_32 and X86_64.
> 
> Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
> Link: lkml.kernel.org/r/CA+55aFzOd3j6ZUSkEwTdk85qtt1JywOtm3ZAb-qAvt8_hJ6D4A@mail.gmail.com
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: x86@kernel.org
> ---
>  arch/x86/Kconfig |   57 +++++++++++++++++++++++++++++++++------------
>  1 file changed, 42 insertions(+), 15 deletions(-)

Looks mostly good to me in principle - there's a few style nits:

> 
> v2: more simplification as suggested by Linus; also separate the
>     X86_32 and X86_64 configs.
> 
> --- linux-next-20180209.orig/arch/x86/Kconfig
> +++ linux-next-20180209/arch/x86/Kconfig
> @@ -423,12 +423,6 @@ config X86_MPPARSE
>  	  For old smp systems that do not have proper acpi support. Newer systems
>  	  (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
>  
> -config X86_BIGSMP
> -	bool "Support for big SMP systems with more than 8 CPUs"
> -	depends on X86_32 && SMP
> -	---help---
> -	  This option is needed for the systems that have more than 8 CPUs
> -
>  config GOLDFISH
>         def_bool y
>         depends on X86_GOLDFISH
> @@ -460,6 +454,12 @@ config INTEL_RDT
>  	  Say N if unsure.
>  
>  if X86_32
> +config X86_BIGSMP
> +	bool "Support for big SMP systems with more than 8 CPUs"
> +	depends on SMP
> +	---help---
> +	  This option is needed for the systems that have more than 8 CPUs
> +
>  config X86_EXTENDED_PLATFORM
>  	bool "Support for extended (non-PC) x86 platforms"
>  	default y
> @@ -949,17 +949,44 @@ config MAXSMP
>  	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
>  	  If unsure, say N.
>  
> +config RANGE_END_CPUS
> +	int
> +	depends on X86_32
> +	default 8 if SMP && !X86_BIGSMP
> +	default 64 if SMP && X86_BIGSMP
> +	default 1 if !SMP
> +
> +config RANGE_END_CPUS
> +	int
> +	depends on X86_64
> +	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK
> +	default 8192 if SMP && (MAXSMP || CPUMASK_OFFSTACK)
> +	default 1 if !SMP
> +
> +config RANGE_BEGIN_CPUS
> +	int
> +	default 1 if !SMP
> +	default RANGE_END_CPUS if MAXSMP
> +	default 2

I'd suggest a more natural naming order, which also lines up with how we name the 
main parameter in the end (CONFIG_NR_CPUS):

	NR_CPUS_RANGE_BEGIN
	NR_CPUS_RANGE_END

> +config DEF_CONFIG_CPUS
> +	int
> +	depends on X86_32
> +	default 1 if !SMP
> +	default 32 if X86_BIGSMP
> +	default 8 if SMP
> +
> +config DEF_CONFIG_CPUS
> +	int
> +	depends on X86_64
> +	default 1 if !SMP
> +	default 8192 if MAXSMP
> +	default 64 if SMP

This too needs to match the target namespace, i.e.:

       NR_CPUS_DEFAULT

I.e. instead of the random, idiosynchratic naming this patch introduces:

	CONFIG_RANGE_BEGIN_CPUS
	CONFIG_RANGE_END_CPUS
	CONFIG_DEF_CONFIG_CPUS
	CONFIG_NR_CPUS

We'll get:

	CONFIG_NR_CPUS_RANGE_BEGIN
	CONFIG_NR_CPUS_RANGE_END
	CONFIG_NR_CPUS_DEFAULT
	CONFIG_NR_CPUS

See how much more structured and organized it all is, both in the source and in 
the resulting .config file? Also, a side effect is that a simple NR_CPUS grep:

  triton:~/tip> grep NR_CPUS .config
  CONFIG_NR_CPUS_RANGE_BEGIN=2
  CONFIG_NR_CPUS_RANGE_END=512
  CONFIG_NR_CPUS_DEFAULT=64
  CONFIG_NR_CPUS=64

  grep NR_CPUS .config

... will tell the full story about how the NR_CPUS Kconfig setup on a particular 
system looks like.

There's no such grep command for the patch you sent, because for example the 
pattern 'CPUS' is too generic as it matches 'CPUSET' and 'PTLOCK_CPUS' as well.

Furthermore, these blocks should be vertically aligned:

> +	default 1 if !SMP
> +	default 8192 if MAXSMP
> +	default 64 if SMP

To:

	default    1 if !SMP
	default 8192 if MAXSMP
	default   64 if SMP

Also note that the moment we have aligned this block vertically, it becomes clear 
at a glance that the internal ordering of the lines should be numeric (in 
decreasing order, to arrive at the highest possible value):

	default 8192 if MAXSMP
	default   64 if SMP
	default    1 if !SMP

We should do the same for all the other entries as well.

A third general problem is the somewhat random ordering of the Kconfig blocks 
themselves:

 +config NR_CPUS_RANGE_END
 +config NR_CPUS_RANGE_BEGIN
 +config NR_CPUS_DEFAULT

The more natural ordering is _RANGE_BEGIN, _RANGE_END, _DEFAULT. (The Kconfig 
language allows forward references, so the fact that _BEGIN in a narrow case 
depends on _END isn't a problem.)

... below is the a patch on top of yours that fixes all this and a few other 
details - see the changelog.

Thanks,

	Ingo

=========================>
Subject: x86/Kconfig: Further simplify the NR_CPUS config
From: Ingo Molnar <mingo@kernel.org>
Date: Sat Feb 10 11:51:57 CET 2018

Clean up various aspects of the x86 CONFIG_NR_CPUS configuration switches:

- Rename the three CONFIG_NR_CPUS related variables to create a common
  namespace for them:

    RANGE_BEGIN_CPUS => NR_CPUS_RANGE_BEGIN
    RANGE_END_CPUS   => NR_CPUS_RANGE_END
    DEF_CONFIG_CPUS  => NR_CPUS_DEFAULT

- Align them vertically, such as:

    config NR_CPUS_RANGE_END
            int
            depends on X86_64
            default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
            default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
            default    1 if !SMP

- Update help text, add more comments.

Test results:

 # i386 allnoconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=1
 CONFIG_NR_CPUS_RANGE_END=1
 CONFIG_NR_CPUS_DEFAULT=1
 CONFIG_NR_CPUS=1

 # i386 defconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=8
 CONFIG_NR_CPUS_DEFAULT=8
 CONFIG_NR_CPUS=8

 # i386 allyesconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=64
 CONFIG_NR_CPUS_DEFAULT=32
 CONFIG_NR_CPUS=32

 # x86_64 allnoconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=1
 CONFIG_NR_CPUS_RANGE_END=1
 CONFIG_NR_CPUS_DEFAULT=1
 CONFIG_NR_CPUS=1

 # x86_64 defconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=512
 CONFIG_NR_CPUS_DEFAULT=64
 CONFIG_NR_CPUS=64

 # x86_64 allyesconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=8192
 CONFIG_NR_CPUS_RANGE_END=8192
 CONFIG_NR_CPUS_DEFAULT=8192
 CONFIG_NR_CPUS=8192

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig |   66 +++++++++++++++++++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 26 deletions(-)

Index: tip/arch/x86/Kconfig
===================================================================
--- tip.orig/arch/x86/Kconfig
+++ tip/arch/x86/Kconfig
@@ -949,52 +949,66 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
-config RANGE_END_CPUS
+#
+# The maximum number of CPUs supported:
+#
+# The main config value is NR_CPUS, which defaults to NR_CPUS_DEFAULT,
+# and which can be configured interactively in the
+# [NR_CPUS_RANGE_BEGIN ... NR_CPUS_RANGE_END] range.
+#
+# The ranges are different on 32-bit and 64-bit kernels, depending on
+# hardware capabilities and scalability features of the kernel.
+#
+# ( If MAXSMP is enabled we just use the highest possible value and disable
+#   interactive configuration. )
+#
+
+config NR_CPUS_RANGE_BEGIN
 	int
-	depends on X86_32
-	default 8 if SMP && !X86_BIGSMP
-	default 64 if SMP && X86_BIGSMP
-	default 1 if !SMP
+	default NR_CPUS_RANGE_END if MAXSMP
+	default    1 if !SMP
+	default    2
 
-config RANGE_END_CPUS
+config NR_CPUS_RANGE_END
 	int
-	depends on X86_64
-	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK
-	default 8192 if SMP && (MAXSMP || CPUMASK_OFFSTACK)
-	default 1 if !SMP
+	depends on X86_32
+	default   64 if  SMP &&  X86_BIGSMP
+	default    8 if  SMP && !X86_BIGSMP
+	default    1 if !SMP
 
-config RANGE_BEGIN_CPUS
+config NR_CPUS_RANGE_END
 	int
-	default 1 if !SMP
-	default RANGE_END_CPUS if MAXSMP
-	default 2
+	depends on X86_64
+	default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
+	default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
+	default    1 if !SMP
 
-config DEF_CONFIG_CPUS
+config NR_CPUS_DEFAULT
 	int
 	depends on X86_32
-	default 1 if !SMP
-	default 32 if X86_BIGSMP
-	default 8 if SMP
+	default   32 if  X86_BIGSMP
+	default    8 if  SMP
+	default    1 if !SMP
 
-config DEF_CONFIG_CPUS
+config NR_CPUS_DEFAULT
 	int
 	depends on X86_64
-	default 1 if !SMP
-	default 8192 if MAXSMP
-	default 64 if SMP
+	default 8192 if  MAXSMP
+	default   64 if  SMP
+	default    1 if !SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range RANGE_BEGIN_CPUS RANGE_END_CPUS
-	default DEF_CONFIG_CPUS
+	range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
+	default NR_CPUS_DEFAULT
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum
 	  supported value is 8192, otherwise the maximum value is 512.  The
 	  minimum value which makes sense is 2.
 
-	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
+	  This is purely to save memory: each supported CPU adds about 8KB
+	  to the kernel image.
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 11:36     ` [PATCH] x86/Kconfig: Further simplify the " Ingo Molnar
@ 2018-02-10 11:38       ` Ingo Molnar
  2018-02-10 17:37         ` Randy Dunlap
  2018-02-10 22:19         ` Linus Torvalds
  2018-02-11 12:12       ` [tip:x86/urgent] " tip-bot for Ingo Molnar
  1 sibling, 2 replies; 12+ messages in thread
From: Ingo Molnar @ 2018-02-10 11:38 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linus Torvalds, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra


* Ingo Molnar <mingo@kernel.org> wrote:

> =========================>
> Subject: x86/Kconfig: Further simplify the NR_CPUS config
> From: Ingo Molnar <mingo@kernel.org>
> Date: Sat Feb 10 11:51:57 CET 2018
> 
> Clean up various aspects of the x86 CONFIG_NR_CPUS configuration switches:
> 
> - Rename the three CONFIG_NR_CPUS related variables to create a common
>   namespace for them:
> 
>     RANGE_BEGIN_CPUS => NR_CPUS_RANGE_BEGIN
>     RANGE_END_CPUS   => NR_CPUS_RANGE_END
>     DEF_CONFIG_CPUS  => NR_CPUS_DEFAULT
> 
> - Align them vertically, such as:
> 
>     config NR_CPUS_RANGE_END
>             int
>             depends on X86_64
>             default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
>             default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
>             default    1 if !SMP
> 
> - Update help text, add more comments.
> 
> Test results:
> 
>  # i386 allnoconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=1
>  CONFIG_NR_CPUS_RANGE_END=1
>  CONFIG_NR_CPUS_DEFAULT=1
>  CONFIG_NR_CPUS=1
> 
>  # i386 defconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=2
>  CONFIG_NR_CPUS_RANGE_END=8
>  CONFIG_NR_CPUS_DEFAULT=8
>  CONFIG_NR_CPUS=8
> 
>  # i386 allyesconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=2
>  CONFIG_NR_CPUS_RANGE_END=64
>  CONFIG_NR_CPUS_DEFAULT=32
>  CONFIG_NR_CPUS=32
> 
>  # x86_64 allnoconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=1
>  CONFIG_NR_CPUS_RANGE_END=1
>  CONFIG_NR_CPUS_DEFAULT=1
>  CONFIG_NR_CPUS=1
> 
>  # x86_64 defconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=2
>  CONFIG_NR_CPUS_RANGE_END=512
>  CONFIG_NR_CPUS_DEFAULT=64
>  CONFIG_NR_CPUS=64
> 
>  # x86_64 allyesconfig:
>  CONFIG_NR_CPUS_RANGE_BEGIN=8192
>  CONFIG_NR_CPUS_RANGE_END=8192
>  CONFIG_NR_CPUS_DEFAULT=8192
>  CONFIG_NR_CPUS=8192
> 
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/Kconfig |   66 +++++++++++++++++++++++++++++++++----------------------
>  1 file changed, 40 insertions(+), 26 deletions(-)

Here is a full combo patch of your patch and mine, for easier review:

---
 arch/x86/Kconfig |   75 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 58 insertions(+), 17 deletions(-)

Index: tip/arch/x86/Kconfig
===================================================================
--- tip.orig/arch/x86/Kconfig
+++ tip/arch/x86/Kconfig
@@ -423,12 +423,6 @@ config X86_MPPARSE
 	  For old smp systems that do not have proper acpi support. Newer systems
 	  (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
 
-config X86_BIGSMP
-	bool "Support for big SMP systems with more than 8 CPUs"
-	depends on X86_32 && SMP
-	---help---
-	  This option is needed for the systems that have more than 8 CPUs
-
 config GOLDFISH
        def_bool y
        depends on X86_GOLDFISH
@@ -460,6 +454,12 @@ config INTEL_RDT
 	  Say N if unsure.
 
 if X86_32
+config X86_BIGSMP
+	bool "Support for big SMP systems with more than 8 CPUs"
+	depends on SMP
+	---help---
+	  This option is needed for the systems that have more than 8 CPUs
+
 config X86_EXTENDED_PLATFORM
 	bool "Support for extended (non-PC) x86 platforms"
 	default y
@@ -949,25 +949,66 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
+#
+# The maximum number of CPUs supported:
+#
+# The main config value is NR_CPUS, which defaults to NR_CPUS_DEFAULT,
+# and which can be configured interactively in the
+# [NR_CPUS_RANGE_BEGIN ... NR_CPUS_RANGE_END] range.
+#
+# The ranges are different on 32-bit and 64-bit kernels, depending on
+# hardware capabilities and scalability features of the kernel.
+#
+# ( If MAXSMP is enabled we just use the highest possible value and disable
+#   interactive configuration. )
+#
+
+config NR_CPUS_RANGE_BEGIN
+	int
+	default NR_CPUS_RANGE_END if MAXSMP
+	default    1 if !SMP
+	default    2
+
+config NR_CPUS_RANGE_END
+	int
+	depends on X86_32
+	default   64 if  SMP &&  X86_BIGSMP
+	default    8 if  SMP && !X86_BIGSMP
+	default    1 if !SMP
+
+config NR_CPUS_RANGE_END
+	int
+	depends on X86_64
+	default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
+	default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
+	default    1 if !SMP
+
+config NR_CPUS_DEFAULT
+	int
+	depends on X86_32
+	default   32 if  X86_BIGSMP
+	default    8 if  SMP
+	default    1 if !SMP
+
+config NR_CPUS_DEFAULT
+	int
+	depends on X86_64
+	default 8192 if  MAXSMP
+	default   64 if  SMP
+	default    1 if !SMP
+
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range 2 8 if SMP && X86_32 && !X86_BIGSMP
-	range 2 64 if SMP && X86_32 && X86_BIGSMP
-	range 2 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64
-	range 2 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64
-	default "1" if !SMP
-	default "8192" if MAXSMP
-	default "32" if SMP && X86_BIGSMP
-	default "8" if SMP && X86_32
-	default "64" if SMP
+	range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
+	default NR_CPUS_DEFAULT
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum
 	  supported value is 8192, otherwise the maximum value is 512.  The
 	  minimum value which makes sense is 2.
 
-	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
+	  This is purely to save memory: each supported CPU adds about 8KB
+	  to the kernel image.
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 11:38       ` Ingo Molnar
@ 2018-02-10 17:37         ` Randy Dunlap
  2018-02-10 22:19         ` Linus Torvalds
  1 sibling, 0 replies; 12+ messages in thread
From: Randy Dunlap @ 2018-02-10 17:37 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Linus Torvalds, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra

On 02/10/2018 03:38 AM, Ingo Molnar wrote:
> 
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>> ---
>>  arch/x86/Kconfig |   66 +++++++++++++++++++++++++++++++++----------------------
>>  1 file changed, 40 insertions(+), 26 deletions(-)
> 
> Here is a full combo patch of your patch and mine, for easier review:
> 

Looks very nice.  Thanks.

Acked-by: Randy Dunlap <rdunlap@infradead.org>
if you want it.


-- 
~Randy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 11:38       ` Ingo Molnar
  2018-02-10 17:37         ` Randy Dunlap
@ 2018-02-10 22:19         ` Linus Torvalds
  2018-02-11  1:11           ` Randy Dunlap
  2018-02-11 10:50           ` Ingo Molnar
  1 sibling, 2 replies; 12+ messages in thread
From: Linus Torvalds @ 2018-02-10 22:19 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Randy Dunlap, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra

Looks good to me.

At the risk of bike-shedding, we could remove all the

        default    1 if !SMP

from the BEGIN/END/DEFAULT things, and perhaps just keep that part in NR_CPUS.

I didn't check, but I *think* it would work to just do

 config NR_CPUS
        int "Maximum number of CPUs" if SMP && !MAXSMP
        range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
        default "1" if !SMP
        default NR_CPUS_DEFAULT

but maybe the "range" line would need an "if !SMP" on it too to avoid
the issue with "1" being out of range.,

That would still leave the NR_CPUS thing *much* easier to understand,
and it would mean that the other helper things wouldn't need to care
about the UP case.

But regardless, that least version looks perfectly fine to me even
without that random tweak.

              Linus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 22:19         ` Linus Torvalds
@ 2018-02-11  1:11           ` Randy Dunlap
  2018-02-11 10:47             ` Ingo Molnar
  2018-02-11 10:50           ` Ingo Molnar
  1 sibling, 1 reply; 12+ messages in thread
From: Randy Dunlap @ 2018-02-11  1:11 UTC (permalink / raw)
  To: Linus Torvalds, Ingo Molnar; +Cc: X86 ML, LKML, Thomas Gleixner, Peter Zijlstra

On 02/10/2018 02:19 PM, Linus Torvalds wrote:
> Looks good to me.
> 
> At the risk of bike-shedding, we could remove all the
> 
>         default    1 if !SMP
> 
> from the BEGIN/END/DEFAULT things, and perhaps just keep that part in NR_CPUS.
> 
> I didn't check, but I *think* it would work to just do
> 
>  config NR_CPUS
>         int "Maximum number of CPUs" if SMP && !MAXSMP
>         range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
>         default "1" if !SMP
>         default NR_CPUS_DEFAULT
> 
> but maybe the "range" line would need an "if !SMP" on it too to avoid
> the issue with "1" being out of range.,

Yeah, I had an early test that failed due to something like that.


-- 
~Randy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-11  1:11           ` Randy Dunlap
@ 2018-02-11 10:47             ` Ingo Molnar
  0 siblings, 0 replies; 12+ messages in thread
From: Ingo Molnar @ 2018-02-11 10:47 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linus Torvalds, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra


* Randy Dunlap <rdunlap@infradead.org> wrote:

> On 02/10/2018 02:19 PM, Linus Torvalds wrote:
> > Looks good to me.
> > 
> > At the risk of bike-shedding, we could remove all the
> > 
> >         default    1 if !SMP
> > 
> > from the BEGIN/END/DEFAULT things, and perhaps just keep that part in NR_CPUS.
> > 
> > I didn't check, but I *think* it would work to just do
> > 
> >  config NR_CPUS
> >         int "Maximum number of CPUs" if SMP && !MAXSMP
> >         range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
> >         default "1" if !SMP
> >         default NR_CPUS_DEFAULT
> > 
> > but maybe the "range" line would need an "if !SMP" on it too to avoid
> > the issue with "1" being out of range.,
> 
> Yeah, I had an early test that failed due to something like that.

I *think* I slightly prefer the current approach, because while it's somewhat 
verbose, the advantage is that this way we have *all* range considerations for a 
given main hardware variant in a single place, and the main NR_CPUS config entry 
is 'passive' in terms of determining the range used.

Plus the verbosity isn't really a problem either, as the whole approach is a 
'verbose' expansion of an overly complex config expression, for better 
readability/maintainability.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 22:19         ` Linus Torvalds
  2018-02-11  1:11           ` Randy Dunlap
@ 2018-02-11 10:50           ` Ingo Molnar
  1 sibling, 0 replies; 12+ messages in thread
From: Ingo Molnar @ 2018-02-11 10:50 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Randy Dunlap, X86 ML, LKML, Thomas Gleixner, Peter Zijlstra


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> But regardless, that least version looks perfectly fine to me even
> without that random tweak.

Thanks, I turned this into:

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

	Ingo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [tip:x86/urgent] x86/Kconfig: Simplify NR_CPUS config
  2018-02-10  0:51   ` [PATCH v2] x86: " Randy Dunlap
  2018-02-10 11:36     ` [PATCH] x86/Kconfig: Further simplify the " Ingo Molnar
@ 2018-02-11 12:11     ` tip-bot for Randy Dunlap
  1 sibling, 0 replies; 12+ messages in thread
From: tip-bot for Randy Dunlap @ 2018-02-11 12:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, torvalds, peterz, rdunlap, torvalds, mingo, linux-kernel, tglx

Commit-ID:  a0d0bb4deba831085d3eeb32d39fe73713ce6eb2
Gitweb:     https://git.kernel.org/tip/a0d0bb4deba831085d3eeb32d39fe73713ce6eb2
Author:     Randy Dunlap <rdunlap@infradead.org>
AuthorDate: Fri, 9 Feb 2018 16:51:03 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 11 Feb 2018 11:51:33 +0100

x86/Kconfig: Simplify NR_CPUS config

Clean up and simplify the X86 NR_CPUS Kconfig symbol/option by
introducing RANGE_BEGIN_CPUS, RANGE_END_CPUS, and DEF_CONFIG_CPUS.
Then combine some default values when their conditionals can be
reduced.

Also move the X86_BIGSMP kconfig option inside an "if X86_32"/"endif"
config block and drop its explicit "depends on X86_32".

Combine the max. 8192 cases of RANGE_END_CPUS (X86_64 only).
Split RANGE_END_CPUS and DEF_CONFIG_CPUS into separate cases for
X86_32 and X86_64.

Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/0b833246-ed4b-e451-c426-c4464725be92@infradead.org
Link: lkml.kernel.org/r/CA+55aFzOd3j6ZUSkEwTdk85qtt1JywOtm3ZAb-qAvt8_hJ6D4A@mail.gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig | 57 +++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 15 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 63bf349..9d921b7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -423,12 +423,6 @@ config X86_MPPARSE
 	  For old smp systems that do not have proper acpi support. Newer systems
 	  (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
 
-config X86_BIGSMP
-	bool "Support for big SMP systems with more than 8 CPUs"
-	depends on X86_32 && SMP
-	---help---
-	  This option is needed for the systems that have more than 8 CPUs
-
 config GOLDFISH
        def_bool y
        depends on X86_GOLDFISH
@@ -460,6 +454,12 @@ config INTEL_RDT
 	  Say N if unsure.
 
 if X86_32
+config X86_BIGSMP
+	bool "Support for big SMP systems with more than 8 CPUs"
+	depends on SMP
+	---help---
+	  This option is needed for the systems that have more than 8 CPUs
+
 config X86_EXTENDED_PLATFORM
 	bool "Support for extended (non-PC) x86 platforms"
 	default y
@@ -949,17 +949,44 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
+config RANGE_END_CPUS
+	int
+	depends on X86_32
+	default 8 if SMP && !X86_BIGSMP
+	default 64 if SMP && X86_BIGSMP
+	default 1 if !SMP
+
+config RANGE_END_CPUS
+	int
+	depends on X86_64
+	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK
+	default 8192 if SMP && (MAXSMP || CPUMASK_OFFSTACK)
+	default 1 if !SMP
+
+config RANGE_BEGIN_CPUS
+	int
+	default 1 if !SMP
+	default RANGE_END_CPUS if MAXSMP
+	default 2
+
+config DEF_CONFIG_CPUS
+	int
+	depends on X86_32
+	default 1 if !SMP
+	default 32 if X86_BIGSMP
+	default 8 if SMP
+
+config DEF_CONFIG_CPUS
+	int
+	depends on X86_64
+	default 1 if !SMP
+	default 8192 if MAXSMP
+	default 64 if SMP
+
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range 2 8 if SMP && X86_32 && !X86_BIGSMP
-	range 2 64 if SMP && X86_32 && X86_BIGSMP
-	range 2 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK && X86_64
-	range 2 8192 if SMP && !MAXSMP && CPUMASK_OFFSTACK && X86_64
-	default "1" if !SMP
-	default "8192" if MAXSMP
-	default "32" if SMP && X86_BIGSMP
-	default "8" if SMP && X86_32
-	default "64" if SMP
+	range RANGE_BEGIN_CPUS RANGE_END_CPUS
+	default DEF_CONFIG_CPUS
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:x86/urgent] x86/Kconfig: Further simplify the NR_CPUS config
  2018-02-10 11:36     ` [PATCH] x86/Kconfig: Further simplify the " Ingo Molnar
  2018-02-10 11:38       ` Ingo Molnar
@ 2018-02-11 12:12       ` tip-bot for Ingo Molnar
  1 sibling, 0 replies; 12+ messages in thread
From: tip-bot for Ingo Molnar @ 2018-02-11 12:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: rdunlap, mingo, torvalds, a.p.zijlstra, tglx, hpa, linux-kernel, peterz

Commit-ID:  aec6487e994d2f625197970a56a4aac40c2c7547
Gitweb:     https://git.kernel.org/tip/aec6487e994d2f625197970a56a4aac40c2c7547
Author:     Ingo Molnar <mingo@kernel.org>
AuthorDate: Sat, 10 Feb 2018 12:36:29 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 11 Feb 2018 11:51:34 +0100

x86/Kconfig: Further simplify the NR_CPUS config

Clean up various aspects of the x86 CONFIG_NR_CPUS configuration switches:

- Rename the three CONFIG_NR_CPUS related variables to create a common
  namespace for them:

    RANGE_BEGIN_CPUS => NR_CPUS_RANGE_BEGIN
    RANGE_END_CPUS   => NR_CPUS_RANGE_END
    DEF_CONFIG_CPUS  => NR_CPUS_DEFAULT

- Align them vertically, such as:

    config NR_CPUS_RANGE_END
            int
            depends on X86_64
            default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
            default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
            default    1 if !SMP

- Update help text, add more comments.

Test results:

 # i386 allnoconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=1
 CONFIG_NR_CPUS_RANGE_END=1
 CONFIG_NR_CPUS_DEFAULT=1
 CONFIG_NR_CPUS=1

 # i386 defconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=8
 CONFIG_NR_CPUS_DEFAULT=8
 CONFIG_NR_CPUS=8

 # i386 allyesconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=64
 CONFIG_NR_CPUS_DEFAULT=32
 CONFIG_NR_CPUS=32

 # x86_64 allnoconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=1
 CONFIG_NR_CPUS_RANGE_END=1
 CONFIG_NR_CPUS_DEFAULT=1
 CONFIG_NR_CPUS=1

 # x86_64 defconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=2
 CONFIG_NR_CPUS_RANGE_END=512
 CONFIG_NR_CPUS_DEFAULT=64
 CONFIG_NR_CPUS=64

 # x86_64 allyesconfig:
 CONFIG_NR_CPUS_RANGE_BEGIN=8192
 CONFIG_NR_CPUS_RANGE_END=8192
 CONFIG_NR_CPUS_DEFAULT=8192
 CONFIG_NR_CPUS=8192

Acked-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180210113629.jcv6su3r4suuno63@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig | 66 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 9d921b7..a528c14 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -949,52 +949,66 @@ config MAXSMP
 	  Enable maximum number of CPUS and NUMA Nodes for this architecture.
 	  If unsure, say N.
 
-config RANGE_END_CPUS
+#
+# The maximum number of CPUs supported:
+#
+# The main config value is NR_CPUS, which defaults to NR_CPUS_DEFAULT,
+# and which can be configured interactively in the
+# [NR_CPUS_RANGE_BEGIN ... NR_CPUS_RANGE_END] range.
+#
+# The ranges are different on 32-bit and 64-bit kernels, depending on
+# hardware capabilities and scalability features of the kernel.
+#
+# ( If MAXSMP is enabled we just use the highest possible value and disable
+#   interactive configuration. )
+#
+
+config NR_CPUS_RANGE_BEGIN
 	int
-	depends on X86_32
-	default 8 if SMP && !X86_BIGSMP
-	default 64 if SMP && X86_BIGSMP
-	default 1 if !SMP
+	default NR_CPUS_RANGE_END if MAXSMP
+	default    1 if !SMP
+	default    2
 
-config RANGE_END_CPUS
+config NR_CPUS_RANGE_END
 	int
-	depends on X86_64
-	default 512 if SMP && !MAXSMP && !CPUMASK_OFFSTACK
-	default 8192 if SMP && (MAXSMP || CPUMASK_OFFSTACK)
-	default 1 if !SMP
+	depends on X86_32
+	default   64 if  SMP &&  X86_BIGSMP
+	default    8 if  SMP && !X86_BIGSMP
+	default    1 if !SMP
 
-config RANGE_BEGIN_CPUS
+config NR_CPUS_RANGE_END
 	int
-	default 1 if !SMP
-	default RANGE_END_CPUS if MAXSMP
-	default 2
+	depends on X86_64
+	default 8192 if  SMP && ( MAXSMP ||  CPUMASK_OFFSTACK)
+	default  512 if  SMP && (!MAXSMP && !CPUMASK_OFFSTACK)
+	default    1 if !SMP
 
-config DEF_CONFIG_CPUS
+config NR_CPUS_DEFAULT
 	int
 	depends on X86_32
-	default 1 if !SMP
-	default 32 if X86_BIGSMP
-	default 8 if SMP
+	default   32 if  X86_BIGSMP
+	default    8 if  SMP
+	default    1 if !SMP
 
-config DEF_CONFIG_CPUS
+config NR_CPUS_DEFAULT
 	int
 	depends on X86_64
-	default 1 if !SMP
-	default 8192 if MAXSMP
-	default 64 if SMP
+	default 8192 if  MAXSMP
+	default   64 if  SMP
+	default    1 if !SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range RANGE_BEGIN_CPUS RANGE_END_CPUS
-	default DEF_CONFIG_CPUS
+	range NR_CPUS_RANGE_BEGIN NR_CPUS_RANGE_END
+	default NR_CPUS_DEFAULT
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  If CPUMASK_OFFSTACK is enabled, the maximum
 	  supported value is 8192, otherwise the maximum value is 512.  The
 	  minimum value which makes sense is 2.
 
-	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
+	  This is purely to save memory: each supported CPU adds about 8KB
+	  to the kernel image.
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-02-12  1:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 22:01 [PATCH] x86: try to simplify NR_CPUS config Randy Dunlap
2018-02-09 22:39 ` Linus Torvalds
2018-02-10  0:51   ` [PATCH v2] x86: " Randy Dunlap
2018-02-10 11:36     ` [PATCH] x86/Kconfig: Further simplify the " Ingo Molnar
2018-02-10 11:38       ` Ingo Molnar
2018-02-10 17:37         ` Randy Dunlap
2018-02-10 22:19         ` Linus Torvalds
2018-02-11  1:11           ` Randy Dunlap
2018-02-11 10:47             ` Ingo Molnar
2018-02-11 10:50           ` Ingo Molnar
2018-02-11 12:12       ` [tip:x86/urgent] " tip-bot for Ingo Molnar
2018-02-11 12:11     ` [tip:x86/urgent] x86/Kconfig: Simplify " tip-bot for Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).