cpu: mark cpu_possible_mask as __ro_after_init

Message ID 41cd78af-92a3-4f23-8c7a-4316a04a66d8@p183
State New
Headers
Series cpu: mark cpu_possible_mask as __ro_after_init |

Commit Message

Alexey Dobriyan Feb. 5, 2024, 10:01 a.m. UTC
  cpu_possible_mask is by definition "cpus which could be hotplugged
without reboot" -- property which is fixed after kernel enumerates
motheboard capabilities and hardware configuration.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 kernel/cpu.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Guenter Roeck Feb. 22, 2024, 6 a.m. UTC | #1
On Mon, Feb 05, 2024 at 01:01:19PM +0300, Alexey Dobriyan wrote:
> cpu_possible_mask is by definition "cpus which could be hotplugged
> without reboot" -- property which is fixed after kernel enumerates
> motheboard capabilities and hardware configuration.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> 
>  kernel/cpu.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -3107,10 +3107,10 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
>  EXPORT_SYMBOL(cpu_all_bits);
>  
>  #ifdef CONFIG_INIT_ALL_POSSIBLE
> -struct cpumask __cpu_possible_mask __read_mostly
> +struct cpumask __cpu_possible_mask __ro_after_init;
>  	= {CPU_BITS_ALL};

I guess you didn't compile test this code.

Guenter

>  #else
> -struct cpumask __cpu_possible_mask __read_mostly;
> +struct cpumask __cpu_possible_mask __ro_after_init;
>  #endif
>  EXPORT_SYMBOL(__cpu_possible_mask);
>
  
Alexey Dobriyan Feb. 22, 2024, 10:26 a.m. UTC | #2
On Wed, Feb 21, 2024 at 10:00:26PM -0800, Guenter Roeck wrote:
> On Mon, Feb 05, 2024 at 01:01:19PM +0300, Alexey Dobriyan wrote:
> > cpu_possible_mask is by definition "cpus which could be hotplugged
> > without reboot" -- property which is fixed after kernel enumerates
> > motheboard capabilities and hardware configuration.
> > 
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > ---
> > 
> >  kernel/cpu.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > --- a/kernel/cpu.c
> > +++ b/kernel/cpu.c
> > @@ -3107,10 +3107,10 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
> >  EXPORT_SYMBOL(cpu_all_bits);
> >  
> >  #ifdef CONFIG_INIT_ALL_POSSIBLE
> > -struct cpumask __cpu_possible_mask __read_mostly
> > +struct cpumask __cpu_possible_mask __ro_after_init;
> >  	= {CPU_BITS_ALL};
> 
> I guess you didn't compile test this code.

On parisc, no. Oh well.

> >  #else
> > -struct cpumask __cpu_possible_mask __read_mostly;
> > +struct cpumask __cpu_possible_mask __ro_after_init;
  

Patch

--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3107,10 +3107,10 @@  const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
 EXPORT_SYMBOL(cpu_all_bits);
 
 #ifdef CONFIG_INIT_ALL_POSSIBLE
-struct cpumask __cpu_possible_mask __read_mostly
+struct cpumask __cpu_possible_mask __ro_after_init;
 	= {CPU_BITS_ALL};
 #else
-struct cpumask __cpu_possible_mask __read_mostly;
+struct cpumask __cpu_possible_mask __ro_after_init;
 #endif
 EXPORT_SYMBOL(__cpu_possible_mask);