[PATCH] arm64/mm: return cpu_all_mask when node is NUMA_NO_NODE

Gavin Shan gshan at redhat.com
Fri Sep 18 01:40:45 EDT 2020


Hi Zhengyuan,

On 9/18/20 11:15 AM, Zhengyuan Liu wrote:
> Filter out NUMA_NO_NODE before returning cpumask of a node, otherwise
> it will triger the following WARN_ON(node >= nr_node_ids).
> 
> Signed-off-by: Zhengyuan Liu <liuzhengyuan at tj.kylinos.cn>
> ---
>   arch/arm64/mm/numa.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
> index 73f8b49d485c..78f9b7dab656 100644
> --- a/arch/arm64/mm/numa.c
> +++ b/arch/arm64/mm/numa.c
> @@ -46,6 +46,9 @@ EXPORT_SYMBOL(node_to_cpumask_map);
>    */
>   const struct cpumask *cpumask_of_node(int node)
>   {
> +	if (node == NUMA_NO_NODE)
> +		return cpu_all_mask;
> +
>   	if (WARN_ON(node >= nr_node_ids))
>   		return cpu_none_mask;
>   
> 

I don't understand how NUMA_NO_NODE triggers the warning, as mentioned
in the change log. NUMA_NO_NODE is defined as (-1), but @nr_node_ids
is always larger than 0. @cpu_all_mask returned in this case would be
meaningless. It sounds not reasonable to pass invalid @node to this
function.

I guess the best way is to fix the issue from the caller. In the mean while,
to report the invalid NUMA node would be helpful. So I think you might be need.
Note the change log needs improvement either :)

     if (WARN_ON(node == NUMA_NO_NODE))
        return cpu_all_mask;

     if (WARN_ON(node < 0 || node >= nr_node_ids)
        return cpu_none_mask;

More information about @nr_node_ids: it has fixed value (1U) when
MAX_NUMNODES is smaller than 2. Otherwise, it's initialized to number
of NUMA nodes, probed from ACPI (SRAT) table, FDT, or dummy initialization.
For the later case, @nr_node_ids is always larger than 0.

Cheers,
Gavin

    




More information about the linux-arm-kernel mailing list