Re: [PATCH v2] arch_numa: Restore nid checks before registering a memblock with a node

From: Mike Rapoport
Date: Sun Dec 01 2024 - 14:32:45 EST


Hi Marc,

On Sun, Dec 01, 2024 at 09:27:02AM +0000, Marc Zyngier wrote:
> Commit 767507654c22 ("arch_numa: switch over to numa_memblks")
> significantly cleaned up the NUMA registration code, but also
> dropped a significant check that was refusing to accept to
> configure a memblock with an invalid nid.

...

> while previous kernel versions were able to recognise how brain-damaged
> the machine is, and only build a fake node.
>
> Use the memblock_validate_numa_coverage() helper to restore some sanity
> and a "working" system.
>
> Fixes: 767507654c22 ("arch_numa: switch over to numa_memblks")
> Suggested-by: Mike Rapoport <rppt@xxxxxxxxxx>
> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
> Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Zi Yan <ziy@xxxxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: David Hildenbrand <david@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> drivers/base/arch_numa.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
> index e187016764265..c63a72a1fed64 100644
> --- a/drivers/base/arch_numa.c
> +++ b/drivers/base/arch_numa.c
> @@ -208,6 +208,10 @@ static int __init numa_register_nodes(void)
> {
> int nid;
>
> + /* Check the validity of the memblock/node mapping */
> + if (!memblock_validate_numa_coverage(1))

I've changed this to memblock_validate_numa_coverage(0) and applied along
with my patch that changed memblock_validate_numa_coverage() to work with
0:

https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git/log/?h=thunderx-fix

Can you please verify that it works on your "quality hardware"?

> + return -EINVAL;
> +
> /* Finally register nodes. */
> for_each_node_mask(nid, numa_nodes_parsed) {
> unsigned long start_pfn, end_pfn;
> --
> 2.39.2

--
Sincerely yours,
Mike.