diff mbox series

[1/2] mm: Mark nr_node_ids __ro_after_init

Message ID 20230802112525.564928240@infradead.org (mailing list archive)
State New
Headers show
Series nodemask: Use nr_node_ids | expand

Commit Message

Peter Zijlstra Aug. 2, 2023, 11:24 a.m. UTC
Just like nr_cpu_ids, nr_node_ids covers the side of possible_map and
is thus constant after init.

Mark the variable __ro_after_init to both improve performance and
enhance security, since the variable is exported. A module writing to
it would be 'unfortunate'.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 mm/page_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Rapoport Aug. 2, 2023, 2:58 p.m. UTC | #1
On Wed, Aug 02, 2023 at 01:24:59PM +0200, Peter Zijlstra wrote:
> Just like nr_cpu_ids, nr_node_ids covers the side of possible_map and
> is thus constant after init.
> 
> Mark the variable __ro_after_init to both improve performance and
> enhance security, since the variable is exported. A module writing to
> it would be 'unfortunate'.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
>  mm/page_alloc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -305,7 +305,7 @@ int movable_zone;
>  EXPORT_SYMBOL(movable_zone);
>  
>  #if MAX_NUMNODES > 1
> -unsigned int nr_node_ids __read_mostly = MAX_NUMNODES;
> +unsigned int nr_node_ids __ro_after_init = MAX_NUMNODES;
>  unsigned int nr_online_nodes __read_mostly = 1;
>  EXPORT_SYMBOL(nr_node_ids);
>  EXPORT_SYMBOL(nr_online_nodes);
> 
>
diff mbox series

Patch

--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -305,7 +305,7 @@  int movable_zone;
 EXPORT_SYMBOL(movable_zone);
 
 #if MAX_NUMNODES > 1
-unsigned int nr_node_ids __read_mostly = MAX_NUMNODES;
+unsigned int nr_node_ids __ro_after_init = MAX_NUMNODES;
 unsigned int nr_online_nodes __read_mostly = 1;
 EXPORT_SYMBOL(nr_node_ids);
 EXPORT_SYMBOL(nr_online_nodes);