mbox series

[0/5] crash: clean up kdump related config items

Message ID 20240105103305.557273-1-bhe@redhat.com (mailing list archive)
Headers show
Series crash: clean up kdump related config items | expand

Message

Baoquan He Jan. 5, 2024, 10:33 a.m. UTC
Motivation:
=============
Previously, LKP reported a building error. When investigating, it can't
be resolved reasonablly with the present messy kdump config items.

https://lore.kernel.org/oe-kbuild-all/202312182200.Ka7MzifQ-lkp@intel.com/


The kdump (crash dumping) related config items could causes confusions:

Firstly,
---
CRASH_CORE enables codes including
 - crashkernel reservation parsing;
 - elfcorehdr updating;
 - vmcoreinfo saving;
 - crash hotplug handling;

Now fadump of powerpc, kcore dynamic debugging and kdump all selects
CRASH_CORE, while fadump 
 - fadump needs crashkernel parsing, vmcoreinfo and accessing
   global variable 'elfcorehdr_addr';
 - kcore needs saved vmcoreinfo;
 - kdump needs all of the current kernel/crash_core.c.

So only enabling PROC_CORE or FA_DUMP will enable CRASH_CORE will
confuse people that we enable the core code of kdump. Actually it's not.

Secondly,
---
It's not reasonable to allow KEXEC_CORE select CRASH_CORE.

Because KEXEC_CORE enables codes which allocate control pages, copy
kexec/kdump segments, and prepare for switching. These codes are
shared by both kexec_load and kexec_file_load, and by both kexec reboot
and kdump. We could want kexec reboot, but disable kdump. In that case,
CRASH_CORE should not be selected.

Thirdly,
---
It's not reasonable to allow CRASH_DUMP select KEXEC_CORE.

That could make KEXEC_CORE, CRASH_DUMP are enabled independently from
KEXEC or KEXEC_FILE. However, w/o KEXEC or KEXEC_FILE, the KEXEC_CORE
code built in doesn't make any sense because no kernel loading or
switching will happen to utilize the KEXEC_CORE code.

Changes:
===========
1, split CRASH_CORE codes into three parts:
    1. move the elfcorehdr upating code and crash hotplug handling code
       into kernel/kexec_core.c. Both KEXEC and KEXEC_FILE will use them.
    2. split crashkernel reservation code out into kernel/crash_reserve.c,
       add CRASH_RESERVE to control its enabling;
    3. rename the left kernel/crash_core.c to kernel/vmcore_info.c since
       only vmcoreinfo is saved in the file, and add VMCORE_INFO to
       control its enabling;
2, rename the current kernel/crash_dump.c to kernel/elfcorehdr.c because
it only defines elfcorehdr_addr and function parse_elfcorehdr() in the
file. And build it in when VMCORE_INFO is enabled.

Achievement:
===========
With above changes, I can rearrange the config items as below (the right
item depends on or is selected by the left item):

    PROC_KCORE -----------> VMCORE_INFO
    
               |----------> VMCORE_INFO
    FA_DUMP----|
               |----------> CRASH_RESERVE
    
                                                    ---->VMCORE_INFO
                                                   /
                                                   |---->CRASH_RESERVE
    KEXEC      --|                                /|
                 |--> KEXEC_CORE--> CRASH_DUMP-->/-|---->PROC_VMCORE
    KEXEC_FILE --|                               \ |
                                                   \---->CRASH_HOTPLUG
    
    KEXEC      --|
                 |--> KEXEC_CORE (for kexec reboot only)
    KEXEC_FILE --|

Baoquan He (5):
  kexec_core: move kdump related codes from crash_core.c to kexec_core.c
  kexec: split crashkernel reservation code out from crash_core.c
  crash: rename crash_core to vmcore_info
  crash: remove dependency of FA_DUMP on CRASH_DUMP
  crash: clean up CRASH_DUMP

 arch/arm64/Kconfig                            |    2 +-
 .../asm/{crash_core.h => crash_reserve.h}     |    4 +-
 arch/arm64/kernel/Makefile                    |    2 +-
 .../kernel/{crash_core.c => vmcore_info.c}    |    2 +-
 arch/powerpc/Kconfig                          |    4 +-
 arch/powerpc/kernel/setup-common.c            |    2 +-
 arch/powerpc/mm/nohash/kaslr_booke.c          |    4 +-
 arch/powerpc/platforms/powernv/opal-core.c    |    2 +-
 arch/riscv/Kconfig                            |    2 +-
 .../asm/{crash_core.h => crash_reserve.h}     |    4 +-
 arch/riscv/kernel/Makefile                    |    2 +-
 .../kernel/{crash_core.c => vmcore_info.c}    |    2 +-
 arch/x86/Kconfig                              |    2 +-
 .../asm/{crash_core.h => crash_reserve.h}     |    6 +-
 arch/x86/kernel/Makefile                      |    2 +-
 .../{crash_core_32.c => vmcore_info_32.c}     |    2 +-
 .../{crash_core_64.c => vmcore_info_64.c}     |    2 +-
 drivers/firmware/qemu_fw_cfg.c                |   14 +-
 fs/proc/Kconfig                               |    2 +-
 fs/proc/kcore.c                               |    2 +-
 include/linux/buildid.h                       |    2 +-
 include/linux/crash_reserve.h                 |   48 +
 include/linux/kexec.h                         |   27 +-
 include/linux/{crash_core.h => vmcore_info.h} |   78 +-
 kernel/Kconfig.kexec                          |   12 +-
 kernel/Makefile                               |    4 +-
 kernel/crash_core.c                           | 1065 -----------------
 kernel/crash_reserve.c                        |  453 +++++++
 kernel/{crash_dump.c => elfcorehdr.c}         |    0
 kernel/kexec_core.c                           |  408 +++++++
 kernel/kexec_internal.h                       |    2 +
 kernel/ksysfs.c                               |    6 +-
 kernel/printk/printk.c                        |    4 +-
 kernel/vmcore_info.c                          |  233 ++++
 lib/buildid.c                                 |    2 +-
 35 files changed, 1222 insertions(+), 1186 deletions(-)
 rename arch/arm64/include/asm/{crash_core.h => crash_reserve.h} (81%)
 rename arch/arm64/kernel/{crash_core.c => vmcore_info.c} (97%)
 rename arch/riscv/include/asm/{crash_core.h => crash_reserve.h} (78%)
 rename arch/riscv/kernel/{crash_core.c => vmcore_info.c} (96%)
 rename arch/x86/include/asm/{crash_core.h => crash_reserve.h} (92%)
 rename arch/x86/kernel/{crash_core_32.c => vmcore_info_32.c} (90%)
 rename arch/x86/kernel/{crash_core_64.c => vmcore_info_64.c} (94%)
 create mode 100644 include/linux/crash_reserve.h
 rename include/linux/{crash_core.h => vmcore_info.h} (59%)
 delete mode 100644 kernel/crash_core.c
 create mode 100644 kernel/crash_reserve.c
 rename kernel/{crash_dump.c => elfcorehdr.c} (100%)
 create mode 100644 kernel/vmcore_info.c