From 24239d2b47d2b43c1b96cbfcec040c1ea10b8faa Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 5 Feb 2024 10:29:07 +0800 Subject: [PATCH] Release: crash-8.0.4-3 --- .crash.metadata | 2 + ...-module-if-the-given-address-is-not-.patch | 87 +++++++++++++++++++ crash.spec | 7 +- 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .crash.metadata create mode 100644 0001-symbols-skip-the-module-if-the-given-address-is-not-.patch diff --git a/.crash.metadata b/.crash.metadata new file mode 100644 index 0000000..8979611 --- /dev/null +++ b/.crash.metadata @@ -0,0 +1,2 @@ +335ab5dfe04f5265cf5f7bb5a44d6ee0afad1bdc crash-8.0.4.tar.gz +6bf5ee7877a4740835745ed97ce525a00bb2232c gdb-10.2.tar.gz diff --git a/0001-symbols-skip-the-module-if-the-given-address-is-not-.patch b/0001-symbols-skip-the-module-if-the-given-address-is-not-.patch new file mode 100644 index 0000000..bd6989b --- /dev/null +++ b/0001-symbols-skip-the-module-if-the-given-address-is-not-.patch @@ -0,0 +1,87 @@ +From 28891d1127542dbb2d5ba16c575e14e741ed73ef Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Thu, 4 Jan 2024 09:20:27 +0800 +Subject: [PATCH] symbols: skip the module if the given address is not within + its address range + +Previously, to find a module symbol and its offset by an arbitrary address, +all symbols within the module will be iterated by address ascending order +until the last symbol with a smaller address been noticed. + +However if the address is not within the module address range, e.g. +the address is higher than the module's last symbol's address, then +the module can be surely skipped, because its symbol iteration is +unnecessary. This can speed up the kernel module symbols finding and improve +the overall performance. + +Without the patch: + $ time echo "bt 8993" | ~/crash-dev/crash vmcore vmlinux + crash> bt 8993 + PID: 8993 TASK: ffff927569cc2100 CPU: 2 COMMAND: "WriterPool0" + #0 [ffff927569cd76f0] __schedule at ffffffffb3db78d8 + #1 [ffff927569cd7758] schedule_preempt_disabled at ffffffffb3db8bf9 + #2 [ffff927569cd7768] __mutex_lock_slowpath at ffffffffb3db6ca7 + #3 [ffff927569cd77c0] mutex_lock at ffffffffb3db602f + #4 [ffff927569cd77d8] ucache_retrieve at ffffffffc0cf4409 [secfs2] + ...snip the stacktrace of the same module... + #11 [ffff927569cd7ba0] cskal_path_vfs_getattr_nosec at ffffffffc05cae76 [falcon_kal] + ...snip... + #13 [ffff927569cd7c40] _ZdlPv at ffffffffc086e751 [falcon_lsm_serviceable] + ...snip... + #20 [ffff927569cd7ef8] unload_network_ops_symbols at ffffffffc06f11c0 [falcon_lsm_pinned_14713] + #21 [ffff927569cd7f50] system_call_fastpath at ffffffffb3dc539a + RIP: 00007f2b28ed4023 RSP: 00007f2a45fe7f80 RFLAGS: 00000206 + RAX: 0000000000000012 RBX: 00007f2a68302e00 RCX: 00007f2a682546d8 + RDX: 0000000000000826 RSI: 00007eb57ea6a000 RDI: 00000000000000e3 + RBP: 00007eb57ea6a000 R8: 0000000000000826 R9: 00000002670bdfd2 + R10: 00000002670bdfd2 R11: 0000000000000293 R12: 00000002670bdfd2 + R13: 00007f29d501a480 R14: 0000000000000826 R15: 00000002670bdfd2 + ORIG_RAX: 0000000000000012 CS: 0033 SS: 002b + crash> + real 7m14.826s + user 7m12.502s + sys 0m1.091s + +With the patch: + $ time echo "bt 8993" | ~/crash-dev/crash vmcore vmlinux + crash> bt 8993 + PID: 8993 TASK: ffff927569cc2100 CPU: 2 COMMAND: "WriterPool0" + #0 [ffff927569cd76f0] __schedule at ffffffffb3db78d8 + #1 [ffff927569cd7758] schedule_preempt_disabled at ffffffffb3db8bf9 + ...snip the same output... + crash> + real 0m8.827s + user 0m7.896s + sys 0m0.938s + +Signed-off-by: Tao Liu +--- + symbols.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/symbols.c b/symbols.c +index 5d91991..88a3fd1 100644 +--- a/symbols.c ++++ b/symbols.c +@@ -5561,7 +5561,7 @@ value_search_module_6_4(ulong value, ulong *offset) + sp = lm->symtable[t]; + sp_end = lm->symend[t]; + +- if (value < sp->value) ++ if (value < sp->value || value > sp_end->value) + continue; + + splast = NULL; +@@ -5646,6 +5646,9 @@ retry: + if (sp->value > value) /* invalid -- between modules */ + break; + ++ if (sp_end->value < value) /* not within the module */ ++ continue; ++ + /* + * splast will contain the last module symbol encountered. + * Note: "__insmod_"-type symbols will be set in splast only +-- +2.40.1 + diff --git a/crash.spec b/crash.spec index b3fc25e..a41a4dd 100644 --- a/crash.spec +++ b/crash.spec @@ -4,7 +4,7 @@ Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 8.0.4 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz @@ -33,6 +33,7 @@ Patch12: 0011-RISCV64-Fix-bt-output-when-no-ra-on-the-stack-top.patch Patch13: 0012-arm64-rewrite-the-arm64_get_vmcoreinfo_ul-to-arm64_g.patch Patch14: 0013-help.c-Remove-kmem-l-help-messages.patch Patch15: 0014-x86_64-check-bt-bptr-before-calculate-framesize.patch +Patch16: 0001-symbols-skip-the-module-if-the-given-address-is-not-.patch %description The core analysis suite is a self-contained tool that can be used to @@ -68,6 +69,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %patch -P 13 -p1 %patch -P 14 -p1 %patch -P 15 -p1 +%patch -P 16 -p1 %build @@ -94,6 +96,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Mon Feb 05 2024 Tao Liu - 8.0.4-3 +- Fix bt takes many minutes on some pids in some vmcore + * Tue Jan 02 2024 Lianbo Jiang - 8.0.4-2 - Fix the "dis -lr" not displaying the source file names and line numbers