Re: [PATCH x86/mm UPDATED] x86-64, NUMA: Fix distance tablehandling

From: David Rientjes
Date: Wed Mar 02 2011 - 09:31:12 EST


On Wed, 2 Mar 2011, Tejun Heo wrote:

> From d968be2ff381c667bfd09795f82248558902a1ae Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@xxxxxxxxxx>
> Date: Wed, 2 Mar 2011 11:22:14 +0100
>
> NUMA distance table handling has the following problems.
>
> * numa_reset_distance() uses numa_distance * sizeof(numa_distance[0])
> as the table size when it should be using the square of
> numa_distance.
>
> * The same size miscalculation when allocation space for phys_dist in
> numa_emulation().
>
> * In numa_emulation(), phys_dist must be reserved; otherwise, the new
> emulated distance table may overlap it.
>
> Fix them and, while at it, take numa_distance_cnt resetting in
> numa_reset_distance() out of the if block to simplify the code a bit.
>
> David Rientjes reported incorrect handling of distance table during
> emulation and Yinghai identified the above problems and wrote the
> original patch to fix the problems. This patch is based on Yinghai's
> patch.
>
> -v2: Ingo was unhappy with 80-column limit induced linebreaks. Let
> lines run over 80-column.
>
> Reported-by: David Rientjes <rientjes@xxxxxxxxxx>
> Patch-originally-from: Yinghai Lu <yinghai@xxxxxxxxxx>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxx>

Acked-by: David Rientjes <rientjes@xxxxxxxxxx>

There's also this in numa_emulation() that isn't a safe assumption:

/* make sure all emulated nodes are mapped to a physical node */
for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
if (emu_nid_to_phys[i] == NUMA_NO_NODE)
emu_nid_to_phys[i] = 0;

Node id 0 is not always online depending on how you setup your SRAT. I'm
not sure why emu_nid_to_phys[] would ever map a fake node id that doesn't
exist to a physical node id rather than NUMA_NO_NODE, so I think it can
just be removed. Otherwise, it should be mapped to a physical node id
that is known to be online.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/