[PATCH 3/3] mm/numa: remove unnecessary local variable in alloc_node_data()

Ye Liu posted 3 patches 7 months, 3 weeks ago
[PATCH 3/3] mm/numa: remove unnecessary local variable in alloc_node_data()
Posted by Ye Liu 7 months, 3 weeks ago
From: Ye Liu <liuye@kylinos.cn>

The temporary local variable 'nd' is redundant. Directly assign the
virtual address to node_data[nid] to simplify the code.

No functional change.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 mm/numa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/numa.c b/mm/numa.c
index f1787d7713a6..7d5e06fe5bd4 100644
--- a/mm/numa.c
+++ b/mm/numa.c
@@ -13,7 +13,6 @@ void __init alloc_node_data(int nid)
 {
 	const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES);
 	u64 nd_pa;
-	void *nd;
 	int tnid;
 
 	/* Allocate node data.  Try node-local memory and then any node. */
@@ -21,7 +20,6 @@ void __init alloc_node_data(int nid)
 	if (!nd_pa)
 		panic("Cannot allocate %zu bytes for node %d data\n",
 		      nd_size, nid);
-	nd = __va(nd_pa);
 
 	/* report and initialize */
 	pr_info("NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
@@ -30,7 +28,7 @@ void __init alloc_node_data(int nid)
 	if (tnid != nid)
 		pr_info("    NODE_DATA(%d) on node %d\n", nid, tnid);
 
-	node_data[nid] = nd;
+	node_data[nid] = __va(nd_pa);
 	memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
 }
 
-- 
2.25.1
Re: [PATCH 3/3] mm/numa: remove unnecessary local variable in alloc_node_data()
Posted by Mike Rapoport 7 months, 3 weeks ago
On Sun, Apr 27, 2025 at 06:04:42PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
> 
> The temporary local variable 'nd' is redundant. Directly assign the
> virtual address to node_data[nid] to simplify the code.
> 
> No functional change.
> 
> Signed-off-by: Ye Liu <liuye@kylinos.cn>

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

> ---
>  mm/numa.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/numa.c b/mm/numa.c
> index f1787d7713a6..7d5e06fe5bd4 100644
> --- a/mm/numa.c
> +++ b/mm/numa.c
> @@ -13,7 +13,6 @@ void __init alloc_node_data(int nid)
>  {
>  	const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES);
>  	u64 nd_pa;
> -	void *nd;
>  	int tnid;
>  
>  	/* Allocate node data.  Try node-local memory and then any node. */
> @@ -21,7 +20,6 @@ void __init alloc_node_data(int nid)
>  	if (!nd_pa)
>  		panic("Cannot allocate %zu bytes for node %d data\n",
>  		      nd_size, nid);
> -	nd = __va(nd_pa);
>  
>  	/* report and initialize */
>  	pr_info("NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
> @@ -30,7 +28,7 @@ void __init alloc_node_data(int nid)
>  	if (tnid != nid)
>  		pr_info("    NODE_DATA(%d) on node %d\n", nid, tnid);
>  
> -	node_data[nid] = nd;
> +	node_data[nid] = __va(nd_pa);
>  	memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
>  }
>  
> -- 
> 2.25.1
> 

-- 
Sincerely yours,
Mike.
Re: [PATCH 3/3] mm/numa: remove unnecessary local variable in alloc_node_data()
Posted by Anshuman Khandual 7 months, 3 weeks ago
On 4/27/25 15:34, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
> 
> The temporary local variable 'nd' is redundant. Directly assign the
> virtual address to node_data[nid] to simplify the code.
> 
> No functional change.
> 
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
>  mm/numa.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/numa.c b/mm/numa.c
> index f1787d7713a6..7d5e06fe5bd4 100644
> --- a/mm/numa.c
> +++ b/mm/numa.c
> @@ -13,7 +13,6 @@ void __init alloc_node_data(int nid)
>  {
>  	const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES);
>  	u64 nd_pa;
> -	void *nd;
>  	int tnid;
>  
>  	/* Allocate node data.  Try node-local memory and then any node. */
> @@ -21,7 +20,6 @@ void __init alloc_node_data(int nid)
>  	if (!nd_pa)
>  		panic("Cannot allocate %zu bytes for node %d data\n",
>  		      nd_size, nid);
> -	nd = __va(nd_pa);
>  
>  	/* report and initialize */
>  	pr_info("NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
> @@ -30,7 +28,7 @@ void __init alloc_node_data(int nid)
>  	if (tnid != nid)
>  		pr_info("    NODE_DATA(%d) on node %d\n", nid, tnid);
>  
> -	node_data[nid] = nd;
> +	node_data[nid] = __va(nd_pa);
>  	memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
>  }
>  

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Re: [PATCH 3/3] mm/numa: remove unnecessary local variable in alloc_node_data()
Posted by David Hildenbrand 7 months, 3 weeks ago
On 27.04.25 12:04, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
> 
> The temporary local variable 'nd' is redundant. Directly assign the
> virtual address to node_data[nid] to simplify the code.
> 
> No functional change.
> 
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb