Message ID | 20230115150206.431528-5-sourabhjain@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | In kernel handling of CPU hotplug events for crash kernel | expand |
On 15/01/2023 16:02:02, Sourabh Jain wrote: > On architectures like PowerPC the crash notes are available for all > possible CPUs. So let's populate the elfcorehdr for all possible > CPUs having crash notes to avoid updating elfcorehdr during in-kernel > crash update on CPU hotplug events. > > The similar technique is used in kexec-tool for kexec_load case. > > Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> > --- > kernel/crash_core.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) This patch is not applying on ppc/next (53ab112a9508). As far as I could see, crash_prepare_elf64_headers() is defined in the file kernel/kexec_file.c and that's not recent, see babac4a84a88 (kexec_file, x86: move re-factored code to generic side, 2018-04-13) Am I missing something? > > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > index 910d377ea317e..19f987b3851e8 100644 > --- a/kernel/crash_core.c > +++ b/kernel/crash_core.c > @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, > ehdr->e_ehsize = sizeof(Elf64_Ehdr); > ehdr->e_phentsize = sizeof(Elf64_Phdr); > > - /* Prepare one phdr of type PT_NOTE for each present CPU */ > - for_each_present_cpu(cpu) { > + /* Prepare one phdr of type PT_NOTE for possible CPU with crash note. */ > + for_each_possible_cpu(cpu) { > #ifdef CONFIG_CRASH_HOTPLUG > if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { > /* Skip the soon-to-be offlined cpu */ > @@ -373,8 +373,11 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, > continue; > } > #endif > - phdr->p_type = PT_NOTE; > notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); > + if (!notes_addr) > + continue; > + > + phdr->p_type = PT_NOTE; > phdr->p_offset = phdr->p_paddr = notes_addr; > phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); > (ehdr->e_phnum)++;
On 19/01/2023 19:29:52, Laurent Dufour wrote: > On 15/01/2023 16:02:02, Sourabh Jain wrote: >> On architectures like PowerPC the crash notes are available for all >> possible CPUs. So let's populate the elfcorehdr for all possible >> CPUs having crash notes to avoid updating elfcorehdr during in-kernel >> crash update on CPU hotplug events. >> >> The similar technique is used in kexec-tool for kexec_load case. >> >> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> >> --- >> kernel/crash_core.c | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) > > This patch is not applying on ppc/next (53ab112a9508). > > As far as I could see, crash_prepare_elf64_headers() is defined in the file > kernel/kexec_file.c and that's not recent, see babac4a84a88 (kexec_file, > x86: move re-factored code to generic side, 2018-04-13) > > Am I missing something? My mistake, sounds that your series is based on top of the Eric's one (not yet upstream): https://lore.kernel.org/lkml/20230118213544.2128-1-eric.devolder@oracle.com/ > >> >> diff --git a/kernel/crash_core.c b/kernel/crash_core.c >> index 910d377ea317e..19f987b3851e8 100644 >> --- a/kernel/crash_core.c >> +++ b/kernel/crash_core.c >> @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, >> ehdr->e_ehsize = sizeof(Elf64_Ehdr); >> ehdr->e_phentsize = sizeof(Elf64_Phdr); >> >> - /* Prepare one phdr of type PT_NOTE for each present CPU */ >> - for_each_present_cpu(cpu) { >> + /* Prepare one phdr of type PT_NOTE for possible CPU with crash note. */ >> + for_each_possible_cpu(cpu) { >> #ifdef CONFIG_CRASH_HOTPLUG >> if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { >> /* Skip the soon-to-be offlined cpu */ >> @@ -373,8 +373,11 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, >> continue; >> } >> #endif >> - phdr->p_type = PT_NOTE; >> notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); >> + if (!notes_addr) >> + continue; >> + >> + phdr->p_type = PT_NOTE; >> phdr->p_offset = phdr->p_paddr = notes_addr; >> phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); >> (ehdr->e_phnum)++; >
On 20/01/23 17:09, Laurent Dufour wrote: > On 19/01/2023 19:29:52, Laurent Dufour wrote: >> On 15/01/2023 16:02:02, Sourabh Jain wrote: >>> On architectures like PowerPC the crash notes are available for all >>> possible CPUs. So let's populate the elfcorehdr for all possible >>> CPUs having crash notes to avoid updating elfcorehdr during in-kernel >>> crash update on CPU hotplug events. >>> >>> The similar technique is used in kexec-tool for kexec_load case. >>> >>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> >>> --- >>> kernel/crash_core.c | 9 ++++++--- >>> 1 file changed, 6 insertions(+), 3 deletions(-) >> This patch is not applying on ppc/next (53ab112a9508). >> >> As far as I could see, crash_prepare_elf64_headers() is defined in the file >> kernel/kexec_file.c and that's not recent, see babac4a84a88 (kexec_file, >> x86: move re-factored code to generic side, 2018-04-13) >> >> Am I missing something? > My mistake, sounds that your series is based on top of the Eric's one (not yet upstream): > > https://lore.kernel.org/lkml/20230118213544.2128-1-eric.devolder@oracle.com/ Yes this patch series is dependent on the above patch series. In the next version I will share a git repo link that will have this patch series applied along with dependent patch series for easy try. - Sourabh
diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 910d377ea317e..19f987b3851e8 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, ehdr->e_ehsize = sizeof(Elf64_Ehdr); ehdr->e_phentsize = sizeof(Elf64_Phdr); - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { + /* Prepare one phdr of type PT_NOTE for possible CPU with crash note. */ + for_each_possible_cpu(cpu) { #ifdef CONFIG_CRASH_HOTPLUG if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { /* Skip the soon-to-be offlined cpu */ @@ -373,8 +373,11 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, continue; } #endif - phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + if (!notes_addr) + continue; + + phdr->p_type = PT_NOTE; phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); (ehdr->e_phnum)++;
On architectures like PowerPC the crash notes are available for all possible CPUs. So let's populate the elfcorehdr for all possible CPUs having crash notes to avoid updating elfcorehdr during in-kernel crash update on CPU hotplug events. The similar technique is used in kexec-tool for kexec_load case. Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> --- kernel/crash_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)