Skip to content

btf/kallsyms based makedumpfile extension for mm page filtering

Tao Liu kexec 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest10 patches 5 repliesIn review
  2. v59 patches 22 repliesSuperseded
  3. v47 patches 21 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v38 patches14 repliesSuperseded
v214 patches15 repliesSuperseded
v1 RFC10 patches15 repliesSuperseded

v6 -> v5 from the cover letter

1) Add erase_sample extension for data erasure sample.
2) Replace fprintf() to MSG()/ERRMSG() in kallsyms.h.
3) Use handle_cbs_len in extension_has_callback() for callback check.
4) Fix bug[5].
5) Add handle_cbs[i]->cb = NULL in init_extensions() to reset the callback if one extension's init() is skipped.
6) The patches are organized as follows:

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10Reserve sections for makedumpfile and extenionsMakefile makedumpfile.ld+17 -10 replies
2/10Implement kernel kallsyms resolvingMakefile kallsyms.c kallsyms.h +2 more+490 -13 replies
3/10Implement kernel btf resolvingMakefile btf_info.c btf_info.h+314 -10 replies
4/10Implement kernel module's kallsyms resolvingkallsyms.c kallsyms.h+161 -00 replies
5/10Implement kernel module's btf resolvingbtf_info.c btf_info.h+135 -00 replies
6/10Add makedumpfile extensions supportMakefile extension.c extension.h +3 more+430 -70 replies
7/10Add sample extension as an example referenceextensions/Makefile extensions/sample.c+70 -10 replies
8/10Add erase_sample extension as an data erase referenceextensions/Makefile extensions/erase_sample.c+79 -10 replies
9/10Doc: Add --extension option to makedumpfile manualREADME makedumpfile.8.in+16 -10 replies
10/10Add amdgpu mm pages filtering extensionextensions/Makefile extensions/amdgpu_filter.c extensions/maple_tree.c +1 more+559 -10 replies

Reviews trailers per patch

9 of 10 patches have a Reviewed-by or Acked-by.

PatchStephen Brennan
1/10R-b
2/10R-b
3/10R-b
4/10R-b
5/10R-b
6/10R-b
7/10R-b
8/10
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6][makedumpfile 00/10] btf/kallsyms based makedumpfile extension for mm page filtering

A) This patchset will introduce the following features to makedumpfile:

1) Add .so extension support to makedumpfile
2) Enable btf and kallsyms for symbol type and address resolving.

B) The purpose of the features are:

1) Currently makedumpfile filters mm pages based on page flags, because flags can help to determine one page's usage. But this page-flag-checking method lacks of flexibility in certain cases, e.g. if we want to filter those mm pages occupied by GPU during vmcore dumping due to:

a) GPU may be taking a large memory and contains sensitive data;
b) GPU mm pages have no relations to kernel crash and useless for vmcore analysis.

But there is no GPU mm page specific flags, and apparently we don't need to create one just for kdump use. A programmable filtering tool is more suitable for such cases. In addition, different GPU vendors may use different ways for mm pages allocating, programmable filtering is better than hard coding these GPU specific logics into makedumpfile in this case.

2) Currently makedumpfile already contains a programmable filtering tool, aka eppic script, which allows user to write customized code for data erasing. However it has the following drawbacks:

a) cannot do mm page filtering.
b) need to access to debuginfo of both kernel and modules, which is not applicable in the 2nd kernel.
c) eppic library has memory leaks which are not all resolved [1]. This is not acceptable in 2nd kernel.

makedumpfile need to resolve the dwarf data from debuginfo, to get symbols types and addresses. In recent kernel there are dwarf alternatives such as btf/kallsyms which can be used for this purpose. And btf/kallsyms info are already packed within vmcore, so we can use it directly.

With these, this patchset introduces makedumpfile extensions, which is based on btf/kallsyms symbol resolving, and is programmable for mm page filtering. The following section shows its usage and performance, please note the tests are performed in 1st kernel.

3) Compile and run makedumpfile extensions:

  $ make LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on EXTENSION=on
  $ make extensions
  $ /usr/bin/time -v ./makedumpfile -d 31 -l /var/crash/127.0.0.1-2025-06-10-18\:03\:12/vmcore
    /tmp/extension.out --extension amdgpu_filter.so
    Loaded extension: ./extensions/amdgpu_filter.so
    makedumpfile Completed.
        User time (seconds): 5.08
        System time (seconds): 0.84
        Percent of CPU this job got: 99%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:05.95
        Maximum resident set size (kbytes): 17360
        ...

To contrast with eppic script of v2 [2]:

  $ /usr/bin/time -v ./makedumpfile -d 31 -l /var/crash/127.0.0.1-2025-06-10-18\:03\:12/vmcore
    /tmp/eppic.out --eppic eppic_scripts/filter_amdgpu_mm_pages.c   
    makedumpfile Completed.
        User time (seconds): 8.23
        System time (seconds): 0.88
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:09.16
        Maximum resident set size (kbytes): 57128
        ...

-rw------- 1 root root 367475074 Jan 19 19:01 /tmp/extension.out
-rw------- 1 root root 367475074 Jan 19 19:48 /tmp/eppic.out
-rw------- 1 root root 387181418 Jun 10 18:03 /var/crash/127.0.0.1-2025-06-10-18:03:12/vmcore

C) Discussion:

1) GPU types: Currently only tested with amdgpu's mm page filtering, others are not tested.
2) OS: The code can work on rhel-10+/rhel9.5+ on x86_64/arm64/s390/ppc64. rhel8.x is not supported, others are not tested.

D) Testing:

If you don't want to create your vmcore, you can find a vmcore which I created with amdgpu mm pages unfiltered [3], the amdgpu mm pages are allocated by program [4]. You can use the vmcore in 1st kernel to filter the amdgpu mm pages by the previous performance testing cmdline. To verify the pages are filtered in crash:

Unfiltered:
crash> search -c "!QAZXSW@#EDC"
ffff96b7fa800000: !QAZXSW@#EDCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ffff96b87c800000: !QAZXSW@#EDCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX crash> rd ffff96b7fa800000
ffff96b7fa800000: 405753585a415121 !QAZXSW@
crash> rd ffff96b87c800000
ffff96b87c800000: 405753585a415121 !QAZXSW@

Filtered:
crash> search -c "!QAZXSW@#EDC"
crash> rd ffff96b7fa800000
rd: page excluded: kernel virtual address: ffff96b7fa800000 type: "64-bit KVADDR" crash> rd ffff96b87c800000
rd: page excluded: kernel virtual address: ffff96b87c800000 type: "64-bit KVADDR"

[1]: https://github.com/lucchouina/eppic/pull/32
[2]: https://lore.kernel.org/kexec/[email protected]/
[3]: https://people.redhat.com/~ltao/core/vmcore
[4]: https://gist.github.com/liutgnu/a8cbce1c666452f1530e1410d1f352df

v6 -> v5:

1) Add erase_sample extension for data erasure sample.
2) Replace fprintf() to MSG()/ERRMSG() in kallsyms.h.
3) Use handle_cbs_len in extension_has_callback() for callback check.
4) Fix bug[5].
5) Add handle_cbs[i]->cb = NULL in init_extensions() to reset the callback if one extension's init() is skipped.
6) The patches are organized as follows:

---- <customization specific> ---
10. Add amdgpu mm pages filtering extension

--- <code should be merged> ---
9. Doc: Add --extension option to makedumpfile manual
8. Add erase_sample extension as an data erase reference
7. Add sample extension as an example reference
6. Add makedumpfile extensions support
5. Implement kernel module's btf resolving
4. Implement kernel module's kallsyms resolving
3. Implement kernel btf resolving
2. Implement kernel kallsyms resolving
1. Reserve sections for makedumpfile and extenions

Patch 10 is customization specific, merging depends on the strategy of maintenance.
Patch 1 ~ 9 are common code which should be merged with makedumpfile.

[5]: https://lore.kernel.org/kexec/[email protected]/

Link to v5: https://lore.kernel.org/kexec/[email protected]/
Link to v4: https://lore.kernel.org/kexec/[email protected]/
Link to v3: https://lore.kernel.org/kexec/[email protected]/
Link to v2: https://lore.kernel.org/kexec/[email protected]/
Link to v1: https://lore.kernel.org/kexec/[email protected]/

Tao Liu (10):
Reserve sections for makedumpfile and extenions Implement kernel kallsyms resolving Implement kernel btf resolving
Implement kernel module's kallsyms resolving Implement kernel module's btf resolving
Add makedumpfile extensions support
Add sample extension as an example reference Add erase_sample extension as an data erase reference
Doc: Add --extension option to makedumpfile manual Add amdgpu mm pages filtering extension

 Makefile                   |  15 +-
 README                     |   6 +
 btf_info.c                 | 371 +++++++++++++++++++++++++
 btf_info.h                 |  77 ++++++
 extension.c                | 355 ++++++++++++++++++++++++
 extension.h                |  16 ++
 extensions/Makefile        |  13 +
 extensions/amdgpu_filter.c | 221 +++++++++++++++
 extensions/erase_sample.c  |  78 ++++++
 extensions/maple_tree.c    | 328 ++++++++++++++++++++++
 extensions/maple_tree.h    |   7 +
 extensions/sample.c        |  69 +++++
 kallsyms.c                 | 550 +++++++++++++++++++++++++++++++++++++
 kallsyms.h                 |  86 ++++++
 makedumpfile.8.in          |  11 +-
 makedumpfile.c             |  44 ++-
 makedumpfile.h             |  12 +
 makedumpfile.ld            |  16 ++
 18 files changed, 2266 insertions(+), 9 deletions(-)
 create mode 100644 btf_info.c
 create mode 100644 btf_info.h
 create mode 100644 extension.c
 create mode 100644 extension.h
 create mode 100644 extensions/Makefile
 create mode 100644 extensions/amdgpu_filter.c
 create mode 100644 extensions/erase_sample.c
 create mode 100644 extensions/maple_tree.c
 create mode 100644 extensions/maple_tree.h
 create mode 100644 extensions/sample.c
 create mode 100644 kallsyms.c
 create mode 100644 kallsyms.h
 create mode 100644 makedumpfile.ld
Signature · 1 line
2.54.0