When adding CPUs to an already big system (test show it seems to start with
more than 256 CPUs), the kernel is showing error messages when building the
FDT for the kexec kernel (kdump or kexec).
It's worth to mention that the kdump kernel is reloaded after a CPU add
operation.
The messages look like (property's name may vary):
10175.025675] Unable to add 32-64-bridge property: FDT_ERR_NOSPACE
This happens because the size of the FDT is computed based on the size of
the FDT the kernel received at boot time. There is additional space added
in kexec_extra_fdt_size_ppc64() for the added memory but nothing is done
for the added CPUs.
This patch adds this feature so adding new CPUs will increase the size of
the FDT for the kexec kernel.
To compute the additional size required, the number of CPU nodes of the
initial FDT (the one the kernel receive at boot time) are recorded. When a
kexec FDT is created, the number of CPU nodes in the current FDT is used to
compute the additional size.
The first patch of this series is creating a variable provided by the boot
code when parsing the initial FDT at boot time.
The second patch is computing the required additional space.
This has been tested on a PowerVM LPAR running with than 256 CPUs in shared
mode, adding 320 CPUs to this LPAR.
Changes in v2:
- Fix build issue, moving definition in prom.h
Laurent Dufour (2):
powerpc: export the CPU node count
powerpc: Take in account addition CPU node when building kexec FDT
arch/powerpc/include/asm/prom.h | 1 +
arch/powerpc/kernel/prom.c | 3 ++
arch/powerpc/kexec/file_load_64.c | 60 ++++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 1 deletion(-)
--
2.38.1
At boot time, the FDT is parsed to compute the number of CPUs.
In addition count the number of CPU nodes and export it.
This is useful when building the FDT for a kexeced kernel since we need to
take in account the CPU node added since the boot time during CPU hotplug
operations.
Signed-off-by: Laurent Dufour <redacted>
---
arch/powerpc/include/asm/prom.h | 1 +
arch/powerpc/kernel/prom.c | 3 +++
2 files changed, 4 insertions(+)
@@ -72,6 +72,7 @@ int __initdata iommu_is_off;int__initdataiommu_force_on;unsignedlongtce_alloc_start,tce_alloc_end;u64ppc64_rma_size;+unsignedintboot_cpu_node_count__ro_after_init;#endifstaticphys_addr_tfirst_memblock_size;staticint__initdataboot_cpu_count;
@@ -335,6 +336,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node,if(type==NULL||strcmp(type,"cpu")!=0)return0;+boot_cpu_node_count++;+/* Get physical cpuid */intserv=of_get_flat_dt_prop(node,"ibm,ppc-interrupt-server#s",&len);if(!intserv)
On a system with a large number of CPUs, the creation of the FDT for a
kexec kernel may fail because the allocated FDT is not large enough.
When this happens, such a message is displayed on the console:
Unable to add ibm,processor-vadd-size property: FDT_ERR_NOSPACE
The property's name may change depending when the buffer overwrite is
detected.
Obviously the created FDT is missing information, and it is expected that
system dump or kexec kernel failed to run properly.
When the FDT is allocated, the size of the FDT the kernel received at boot
time is used and an extra size can be applied. Currently, only memory added
after boot time is taken in account, not the CPU nodes.
The extra size should take in account these additional CPU nodes and
compute the required extra space. To achieve that, the size of a CPU node,
including its subnode is computed once and multiplied by the number of
additional CPU nodes.
The assumption is that the size of the CPU node is _same_ for all the node,
the only variable part should be the name "PowerPC,POWERxx@##" where "##"
may vary a bit.
Signed-off-by: Laurent Dufour <redacted>
---
arch/powerpc/kexec/file_load_64.c | 60 ++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
@@ -26,6 +26,7 @@#include<asm/firmware.h>#include<asm/kexec_ranges.h>#include<asm/crashdump-ppc64.h>+#include<asm/prom.h>structumem_info{u64*buf;/* data buffer for usable-memory property */
@@ -928,6 +929,46 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,returnret;}+/**+*get_cpu_node_size-ComputethesizeofaCPUnodeintheFDT.+*Thisshouldbedoneonlyonceandthevalueisstoredin+*astaticvariable.+*ReturnsthemaxsizeofaCPUnodeintheFDT.+*/+staticunsignedintcpu_node_size(void)+{+staticunsignedintcpu_node_size;+structdevice_node*dn;+structproperty*pp;++/*+*Don'tcomputeittwice,weareassumingthattheperCPUnodesize+*doesn'tchangeduringthesystem'slife.+*/+if(cpu_node_size)+returncpu_node_size;++dn=of_find_node_by_type(NULL,"cpu");+if(!dn){+/* Unlikely to happen */+WARN_ON_ONCE(1);+return0;+}++/*+*WecomputethesubnodesizeforaCPUnode,assumingit+*willbethesameforall.+*/+cpu_node_size+=strlen(dn->name)+5;+for_each_property_of_node(dn,pp){+cpu_node_size+=strlen(pp->name);+cpu_node_size+=pp->length;+}++of_node_put(dn);+returncpu_node_size;+}+/***kexec_extra_fdt_size_ppc64-Returntheestimatedadditionalsizeneededto*setupFDTforkexec/kdumpkernel.
From: Michael Ellerman <hidden> Date: 2022-12-08 12:50:42
On Thu, 10 Nov 2022 19:06:17 +0100, Laurent Dufour wrote:
When adding CPUs to an already big system (test show it seems to start with
more than 256 CPUs), the kernel is showing error messages when building the
FDT for the kexec kernel (kdump or kexec).
It's worth to mention that the kdump kernel is reloaded after a CPU add
operation.
[...]