powerpc/smp: Cache CPU to chip lookup
authorSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Thu, 15 Apr 2021 12:09:34 +0000 (17:39 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 17 Apr 2021 00:40:51 +0000 (10:40 +1000)
commitc1e53367dab15e41814cff4e37df8ec4ac8fb9d7
tree490cad3a7a3e381380a82bed254bb9180bc92785
parent131c82b6a1d261705a6f98368e501d43d994018d
powerpc/smp: Cache CPU to chip lookup

On systems with large CPUs per node, even with the filtered matching of
related CPUs, there can be large number of calls to cpu_to_chip_id for
the same CPU. For example with 4096 vCPU, 1 node QEMU configuration,
with 4 threads per core, system could be see upto 1024 calls to
cpu_to_chip_id() for the same CPU. On a given system, cpu_to_chip_id()
for a given CPU would always return the same. Hence cache the result in
a lookup table for use in subsequent calls.

Since all CPUs sharing the same core will belong to the same chip, the
lookup_table has an entry for one CPU per core.  chip_id_lookup_table is
not being freed and would be used on subsequent CPU online post CPU
offline.

Reported-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210415120934.232271-4-srikar@linux.vnet.ibm.com
arch/powerpc/include/asm/smp.h
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/smp.c