diff mbox series

[v2] mm: numa_clear_kernel_node_hotplug: Add NUMA_NO_NODE check for node id

Message ID 1729070461-13576-1-git-send-email-nobuhiro1.iwamatsu@toshiba.co.jp (mailing list archive)
State New
Headers show
Series [v2] mm: numa_clear_kernel_node_hotplug: Add NUMA_NO_NODE check for node id | expand

Commit Message

Nobuhiro Iwamatsu Oct. 16, 2024, 9:21 a.m. UTC
The acquired memory blocks for reserved may include blocks outside of
memory management. In this case, the nid variable is set to NUMA_NO_NODE
(-1), so an error occurs in node_set().
This adds a check using numa_valid_node() to numa_clear_kernel_node_hotplug()
that skips node_set() when nid is set to NUMA_NO_NODE.

Fixes: 87482708210f ("mm: introduce numa_memblks")
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Suggested-by: Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
---
 mm/numa_memblks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

v2:
  - Use numa_valid_node() instead of check.
  - Add Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
  - Update description.
  - Drop RFC from subject.

Comments

Anshuman Khandual Oct. 16, 2024, 12:37 p.m. UTC | #1
On 10/16/24 14:51, Nobuhiro Iwamatsu wrote:
> The acquired memory blocks for reserved may include blocks outside of
> memory management. In this case, the nid variable is set to NUMA_NO_NODE
> (-1), so an error occurs in node_set().
> This adds a check using numa_valid_node() to numa_clear_kernel_node_hotplug()
> that skips node_set() when nid is set to NUMA_NO_NODE.
> 
> Fixes: 87482708210f ("mm: introduce numa_memblks")
> Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Suggested-by: Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
> ---
>  mm/numa_memblks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> v2:
>   - Use numa_valid_node() instead of check.
>   - Add Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
>   - Update description.
>   - Drop RFC from subject.
> 
> diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
> index be52b93a9c58..a3877e9bc878 100644
> --- a/mm/numa_memblks.c
> +++ b/mm/numa_memblks.c
> @@ -349,7 +349,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
>  	for_each_reserved_mem_region(mb_region) {
>  		int nid = memblock_get_region_node(mb_region);
>  
> -		if (nid != MAX_NUMNODES)
> +		if (numa_valid_node(nid))
>  			node_set(nid, reserved_nodemask);
>  	}
>  

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
diff mbox series

Patch

diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index be52b93a9c58..a3877e9bc878 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -349,7 +349,7 @@  static void __init numa_clear_kernel_node_hotplug(void)
 	for_each_reserved_mem_region(mb_region) {
 		int nid = memblock_get_region_node(mb_region);
 
-		if (nid != MAX_NUMNODES)
+		if (numa_valid_node(nid))
 			node_set(nid, reserved_nodemask);
 	}