powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove

"Linux Kernel Mailing List" <[email protected]> Wed, 14 Feb 2018 18:19:52 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/1d9a090783bef19fe8cdec878620d22f05191316
Commit:     1d9a090783bef19fe8cdec878620d22f05191316
Parent:     581e400ff935d34d95811258586128bf11baef15
Refname:    refs/heads/master
Author:     Nathan Fontenot <[email protected]>
AuthorDate: Fri Jan 26 13:41:59 2018 -0600
Committer:  Michael Ellerman <[email protected]>
CommitDate: Thu Feb 8 23:56:10 2018 +1100

    powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove
    
    When DLPAR removing a CPU, the unmapping of the cpu from a node in
    unmap_cpu_from_node() should also invalidate the CPUs entry in the
    numa_cpu_lookup_table. There is not a guarantee that on a subsequent
    DLPAR add of the CPU the associativity will be the same and thus
    could be in a different node. Invalidating the entry in the
    numa_cpu_lookup_table causes the associativity to be read from the
    device tree at the time of the add.
    
    The current behavior of not invalidating the CPUs entry in the
    numa_cpu_lookup_table can result in scenarios where the the topology
    layout of CPUs in the partition does not match the device tree
    or the topology reported by the HMC.
    
    This bug looks like it was introduced in 2004 in the commit titled
    "ppc64: cpu hotplug notifier for numa", which is 6b15e4e87e32 in the
    linux-fullhist tree. Hence tag it for all stable releases.
    
    Cc: [email protected]
    Signed-off-by: Nathan Fontenot <[email protected]>
    Reviewed-by: Tyrel Datwyler <[email protected]>
    Signed-off-by: Michael Ellerman <[email protected]>
---
 arch/powerpc/include/asm/topology.h          | 5 +++++
 arch/powerpc/mm/numa.c                       | 5 -----
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 88187c285c70..1c02e6900f78 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -44,6 +44,11 @@ extern int sysfs_add_device_to_node(struct device *dev, int nid);
 extern void sysfs_remove_device_from_node(struct device *dev, int nid);
 extern int numa_update_cpu_topology(bool cpus_locked);
 
+static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
+{
+	numa_cpu_lookup_table[cpu] = node;
+}
+
 static inline int early_cpu_to_node(int cpu)
 {
 	int nid;
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 314d19ab9385..edd8d0bc9364 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -143,11 +143,6 @@ static void reset_numa_cpu_lookup_table(void)
 		numa_cpu_lookup_table[cpu] = -1;
 }
 
-static void update_numa_cpu_lookup_table(unsigned int cpu, int node)
-{
-	numa_cpu_lookup_table[cpu] = node;
-}