Linux-mm Archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory()
@ 2023-06-07  3:24 Haifeng Xu
  2023-06-07  6:39 ` Mike Rapoport
  2023-06-07  8:48 ` Michal Hocko
  0 siblings, 2 replies; 3+ messages in thread
From: Haifeng Xu @ 2023-06-07  3:24 UTC (permalink / raw
  To: rppt; +Cc: mhocko, akpm, linux-mm, linux-kernel, Haifeng Xu

The node_id in pgdat has already been set in free_area_init_node(),
so use it internally instead of passing a redundant parameter.

Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
 mm/mm_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index b82718d596c3..78e67041ae9f 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1725,7 +1725,7 @@ static void __init free_area_init_node(int nid)
 }
 
 /* Any regular or high memory on that node ? */
-static void check_for_memory(pg_data_t *pgdat, int nid)
+static void check_for_memory(pg_data_t *pgdat)
 {
 	enum zone_type zone_type;
 
@@ -1733,9 +1733,9 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
 		struct zone *zone = &pgdat->node_zones[zone_type];
 		if (populated_zone(zone)) {
 			if (IS_ENABLED(CONFIG_HIGHMEM))
-				node_set_state(nid, N_HIGH_MEMORY);
+				node_set_state(pgdat->node_id, N_HIGH_MEMORY);
 			if (zone_type <= ZONE_NORMAL)
-				node_set_state(nid, N_NORMAL_MEMORY);
+				node_set_state(pgdat->node_id, N_NORMAL_MEMORY);
 			break;
 		}
 	}
@@ -1887,7 +1887,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)
 		/* Any memory on that node */
 		if (pgdat->node_present_pages)
 			node_set_state(nid, N_MEMORY);
-		check_for_memory(pgdat, nid);
+		check_for_memory(pgdat);
 	}
 
 	memmap_init();
-- 
2.25.1



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

* Re: [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory()
  2023-06-07  3:24 [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory() Haifeng Xu
@ 2023-06-07  6:39 ` Mike Rapoport
  2023-06-07  8:48 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2023-06-07  6:39 UTC (permalink / raw
  To: Haifeng Xu; +Cc: mhocko, akpm, linux-mm, linux-kernel

On Wed, Jun 07, 2023 at 03:24:02AM +0000, Haifeng Xu wrote:
> The node_id in pgdat has already been set in free_area_init_node(),
> so use it internally instead of passing a redundant parameter.
> 
> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>

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

> ---
>  mm/mm_init.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index b82718d596c3..78e67041ae9f 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1725,7 +1725,7 @@ static void __init free_area_init_node(int nid)
>  }
>  
>  /* Any regular or high memory on that node ? */
> -static void check_for_memory(pg_data_t *pgdat, int nid)
> +static void check_for_memory(pg_data_t *pgdat)
>  {
>  	enum zone_type zone_type;
>  
> @@ -1733,9 +1733,9 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
>  		struct zone *zone = &pgdat->node_zones[zone_type];
>  		if (populated_zone(zone)) {
>  			if (IS_ENABLED(CONFIG_HIGHMEM))
> -				node_set_state(nid, N_HIGH_MEMORY);
> +				node_set_state(pgdat->node_id, N_HIGH_MEMORY);
>  			if (zone_type <= ZONE_NORMAL)
> -				node_set_state(nid, N_NORMAL_MEMORY);
> +				node_set_state(pgdat->node_id, N_NORMAL_MEMORY);
>  			break;
>  		}
>  	}
> @@ -1887,7 +1887,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)
>  		/* Any memory on that node */
>  		if (pgdat->node_present_pages)
>  			node_set_state(nid, N_MEMORY);
> -		check_for_memory(pgdat, nid);
> +		check_for_memory(pgdat);
>  	}
>  
>  	memmap_init();
> -- 
> 2.25.1
> 

-- 
Sincerely yours,
Mike.


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

* Re: [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory()
  2023-06-07  3:24 [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory() Haifeng Xu
  2023-06-07  6:39 ` Mike Rapoport
@ 2023-06-07  8:48 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2023-06-07  8:48 UTC (permalink / raw
  To: Haifeng Xu; +Cc: rppt, akpm, linux-mm, linux-kernel

On Wed 07-06-23 03:24:02, Haifeng Xu wrote:
> The node_id in pgdat has already been set in free_area_init_node(),
> so use it internally instead of passing a redundant parameter.

Yes and this even improves the code because having both pgdat and nid
arguments is confusing and can be error prone because those might
mismatch and we would end up allocating from a different node in the
end.

> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/mm_init.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index b82718d596c3..78e67041ae9f 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1725,7 +1725,7 @@ static void __init free_area_init_node(int nid)
>  }
>  
>  /* Any regular or high memory on that node ? */
> -static void check_for_memory(pg_data_t *pgdat, int nid)
> +static void check_for_memory(pg_data_t *pgdat)
>  {
>  	enum zone_type zone_type;
>  
> @@ -1733,9 +1733,9 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
>  		struct zone *zone = &pgdat->node_zones[zone_type];
>  		if (populated_zone(zone)) {
>  			if (IS_ENABLED(CONFIG_HIGHMEM))
> -				node_set_state(nid, N_HIGH_MEMORY);
> +				node_set_state(pgdat->node_id, N_HIGH_MEMORY);
>  			if (zone_type <= ZONE_NORMAL)
> -				node_set_state(nid, N_NORMAL_MEMORY);
> +				node_set_state(pgdat->node_id, N_NORMAL_MEMORY);
>  			break;
>  		}
>  	}
> @@ -1887,7 +1887,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)
>  		/* Any memory on that node */
>  		if (pgdat->node_present_pages)
>  			node_set_state(nid, N_MEMORY);
> -		check_for_memory(pgdat, nid);
> +		check_for_memory(pgdat);
>  	}
>  
>  	memmap_init();
> -- 
> 2.25.1

-- 
Michal Hocko
SUSE Labs


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

end of thread, other threads:[~2023-06-07  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07  3:24 [PATCH] mm/mm_init.c: drop 'nid' parameter from check_for_memory() Haifeng Xu
2023-06-07  6:39 ` Mike Rapoport
2023-06-07  8:48 ` Michal Hocko

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 read-only IMAP folder(s) and NNTP newsgroup(s).