osdump: Add one new os minidump module
Subsystems (4)
RFC PATCH 1/7 osdump: Add one new os minidump module
From: qiruipeng <[email protected]>
Osdump is a new crash dumping solution aiming at specific embedded devices within automotive or Industrial.
- limited memory.
- reboot as soon as possible when system fault.
In order to reduce dump file size and speed up dump process, it has the following features:
- no userspace memory, just designed for solving os issues.
- no const data, such as text segment
- dump core os data only.
- bss, data segments which alloc static.
- dynamic data
- slub data for little size data.
- some large size data.
- compress dump data to reduce dump file size.
consist of large massive of uncontinuous data,so use binary data format directly.
reasemble a standard elf format file with dump file and vmlinux, and then parse it with crash tool.
--- arch/arm64/Kconfig | 169 +++++++++++ drivers/of/platform.c | 1 + include/linux/osdump.h | 7 + kernel/Makefile | 1 + kernel/osdump/Makefile | 1 + kernel/osdump/compr.c | 252 ++++++++++++++++ kernel/osdump/core.c | 608 +++++++++++++++++++++++++++++++++++++++ kernel/osdump/extern.h | 13 + kernel/osdump/inode.c | 77 +++++ kernel/osdump/internal.h | 95 ++++++ 10 files changed, 1224 insertions(+) create mode 100644 include/linux/osdump.h create mode 100644 kernel/osdump/Makefile create mode 100644 kernel/osdump/compr.c create mode 100644 kernel/osdump/core.c create mode 100644 kernel/osdump/extern.h create mode 100644 kernel/osdump/inode.c create mode 100644 kernel/osdump/internal.h
arch/arm64/Kconfig +169 -0
@@ -258,6 +258,175 @@ config ARM64 help ARM 64-bit (AArch64) Linux support. +config OS_MINIDUMP + bool "Enable os minidump module" + default n + depends on !CRASH_CORE && !SLUB_DEBUG && !SLUB_TINY + help + Trigger os minidump when panic. It only dump parts of os core + datas/segments in raw binary format to reduce its size and + speed up dump process. Reasemble a standard elf format file + with dump file and vmlinux, and then parse it with crash tool. + + For more details see Documentation/admin-guide/osdump.rst + + If unsure, say N. + +config OS_MINIDUMP_DEFLATE_COMPRESS + tristate "DEFLATE (ZLIB) compression" + depends on OS_MINIDUMP + select CRYPTO_DEFLATE + help + This option enables DEFLATE (also known as ZLIB) compression + algorithm support for os minidump. Enabling this option will allow + mini dumps to be compressed using DEFLATE, which may reduce the size of + the dump files. + + If unsure, say N. + +config OS_MINIDUMP_LZO_COMPRESS + tristate "LZO compression" + default y + depends on OS_MINIDUMP + select CRYPTO_LZO + help + This option enables LZO compression algorithm support for os minidump. + Enabling this option will allow mini dumps to be compressed using LZO, + which may reduce the size of the dump files. + + If unsure, say Y. + +config OS_MINIDUMP_LZ4_COMPRESS + tristate "LZ4 compression" + depends on OS_MINIDUMP + select CRYPTO_LZ4 + help + This option enables LZ4 compression algorithm support for os minidump. + Enabling this option will allow mini dumps to be compressed using LZ4, + which may reduce the size of the dump files. + + If unsure, say N. + +config OS_MINIDUMP_LZ4HC_COMPRESS + tristate "LZ4HC compression" + depends on OS_MINIDUMP + select CRYPTO_LZ4HC + help + This option enables LZ4HC (high compression) mode algorithm. + Enabling this option will allow mini dumps to be compressed using LZ4HC, + which may reduce the size of the dump files. + + If unsure, say N. + +config OS_MINIDUMP_842_COMPRESS + bool "842 compression" + depends on OS_MINIDUMP + select CRYPTO_842 + help + This option enables 842 compression algorithm support for os minidump. + Enabling this option will allow mini dumps to be compressed using 842, + which may reduce the size of the dump files. + + If unsure, say N. + +config OS_MINIDUMP_ZSTD_COMPRESS + bool "zstd compression" + depends on OS_MINIDUMP + select CRYPTO_ZSTD + help + This option enables zstd compression algorithm support for os minidump. + Enabling this option will allow mini dumps to be compressed using ZSTD, + which may reduce the size of the dump files. + + If unsure, say N. + +config OS_MINIDUMP_COMPRESS + def_bool y + depends on OS_MINIDUMP + depends on OS_MINIDUMP_DEFLATE_COMPRESS || OS_MINIDUMP_LZO_COMPRESS || \ + OS_MINIDUMP_LZ4_COMPRESS || OS_MINIDUMP_LZ4HC_COMPRESS || \ + OS_MINIDUMP_842_COMPRESS || OS_MINIDUMP_ZSTD_COMPRESS + +choice + prompt "Default osdump.compression algorithm" + depends on OS_MINIDUMP_COMPRESS + help + This option chooses the default active compression algorithm. + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + Currently, osdump.has support for 6 compression algorithms: + deflate, lzo, lz4, lz4hc, 842 and zstd. + + The default compression algorithm is lzo. + + config OS_MINIDUMP_DEFLATE_COMPRESS_DEFAULT + bool "deflate" if OS_MINIDUMP_DEFLATE_COMPRESS + help + This option chooses deflate as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + config OS_MINIDUMP_LZO_COMPRESS_DEFAULT + bool "lzo" if OS_MINIDUMP_LZO_COMPRESS + help + This option chooses lzo as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + config OS_MINIDUMP_LZ4_COMPRESS_DEFAULT + bool "lz4" if OS_MINIDUMP_LZ4_COMPRESS + help + This option chooses lz4 as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + config OS_MINIDUMP_LZ4HC_COMPRESS_DEFAULT + bool "lz4hc" if OS_MINIDUMP_LZ4HC_COMPRESS + help + This option chooses lz4hc as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + config OS_MINIDUMP_842_COMPRESS_DEFAULT + bool "842" if OS_MINIDUMP_842_COMPRESS + help + This option chooses 842 as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + + config OS_MINIDUMP_ZSTD_COMPRESS_DEFAULT + bool "zstd" if OS_MINIDUMP_ZSTD_COMPRESS + help + This option chooses zstd as default compression algorithm, + which reduce the size of the dump files greately. + + This can be changed at boot with "osdump.compress=..." on + the kernel command line. + +endchoice + +config OS_MINIDUMP_COMPRESS_DEFAULT + string + depends on OS_MINIDUMP_COMPRESS + default "deflate" if OS_MINIDUMP_DEFLATE_COMPRESS_DEFAULT + default "lzo" if OS_MINIDUMP_LZO_COMPRESS_DEFAULT + default "lz4" if OS_MINIDUMP_LZ4_COMPRESS_DEFAULT + default "lz4hc" if OS_MINIDUMP_LZ4HC_COMPRESS_DEFAULT + default "842" if OS_MINIDUMP_842_COMPRESS_DEFAULT + default "zstd" if OS_MINIDUMP_ZSTD_COMPRESS_DEFAULT + + config CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS def_bool CC_IS_CLANG # https://github.com/ClangBuiltLinux/linux/issues/1507
drivers/of/platform.c +1 -0
@@ -538,6 +538,7 @@ static const struct of_device_id reserved_mem_matches[] = { { .compatible = "qcom,cmd-db" }, { .compatible = "qcom,smem" }, { .compatible = "ramoops" }, + { .compatible = "osdump" }, { .compatible = "nvmem-rmem" }, { .compatible = "google,open-dice" }, {}
include/linux/osdump.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_OS_MINIDUMP_H +#define _LINUX_OS_MINIDUMP_H + +extern int osdump (void ); + +#endif
kernel/Makefile +1 -0
@@ -116,6 +116,7 @@ obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call_inline.o obj-$(CONFIG_CFI_CLANG) += cfi.o obj-$(CONFIG_PERF_EVENTS) += events/ +obj-$(CONFIG_OS_MINIDUMP) += osdump/ obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o obj-$(CONFIG_PADATA) += padata.o
kernel/osdump/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += core.o inode.o compr.o
kernel/osdump/compr.c new file +252 -0
252 lines not on this page · raw message
kernel/osdump/core.c new file +608 -0
608 lines not on this page · raw message
kernel/osdump/extern.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_OS_MINIDUMP_EXTERN_H +#define _LINUX_OS_MINIDUMP_EXTERN_H + +extern struct kmem_cache *task_struct_cachep; +extern size_t big_oops_buf_sz; +extern int osdump_compress (const void *in,void *out,int size,int *left); +extern int get_rq (int cpu,void **rq); +extern u32 *vmcoreinfo_note; +extern int get_note_size (void ); + +#endif
kernel/osdump/inode.c new file +77 -0
77 lines not on this page · raw message
kernel/osdump/internal.h new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 6 lines · Ruipeng Qi
From: qiruipeng <[email protected]>
Osdump is a new crash dumping solution aiming at specific embedded devices within automotive or Industrial.
- limited memory.
- reboot as soon as possible when system fault.
NAK, sorry, work with Qualcomm minidump series to incorporate all your needs there.
Best regards,
Krzysztof
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines
Osdump is a new crash dumping solution aiming at specific embedded devices within automotive or Industrial.
- limited memory.
- reboot as soon as possible when system fault.NAK, sorry, work with Qualcomm minidump series to incorporate all your needs there.
Sorry, I didn't explain it properly. Will add more descriptions in the next version. Osdump is a totally different mindump, which aims at helping to solve kernel issues as easy as kdump/kexec/crash, but with little costs.
For something like Pstore, you can get where the issue occurs. You can figure out the problem if it is easy, but sometimes you can't. For example:
<4>[ 5.311431] task_blocks_on_rt_mutex+0x234/0x380 <4>[ 5.316166] rt_spin_lock_slowlock_locked+0xcc/0x2b0 <4>[ 5.321257] rt_spin_lock_slowlock+0x5c/0x90 <4>[ 5.325633] rt_spin_lock+0x60/0x74 <4>[ 5.329207] refill_stock+0x58/0x230
You can find where the issue occurs.
static inline struct rt_mutex_waiter *rt_mutex_top_waiter(struct rt_mutex *lock)
{
struct rb_node *leftmost = rb_first_cached(&lock->waiters); struct rt_mutex_waiter *w = NULL;
if (leftmost) {
w = rb_entry(leftmost, struct rt_mutex_waiter, tree_entry);
BUG_ON(w->lock != lock);But you don't know why w->lock and lock are different, and who is wrong.
Qcom minidump can dump some logs like dmsg, some status like IRQ or Run queue. This can help to learn some information when the issue occurs, which will help to find out the root cause. But what it dumps are limited, it doesn't dump w and lock if they are not local data.
For osdump, it dumps objects stored in slab, datas in bss, data segments, some data alloced with memblock, data stored in local stack, and so on. In a word, it dumps almost all of the key data in the kernel. Besides, you can use the crash tool to analyze the dump file.
In a word, I think this toal different minidump should have its own place in the kernel world. Looking forward to your suggestions!
Best Regards
Ruipeng
Quoted 33 lines · ruipeng qi
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines
Osdump is a new crash dumping solution aiming at specific embedded devices within automotive or Industrial.
- limited memory.
- reboot as soon as possible when system fault.NAK, sorry, work with Qualcomm minidump series to incorporate all your needs there.
Sorry, I didn't explain it properly. Will add more descriptions in the next version. Osdump is a totally different mindump, which aims at helping to solve kernel issues as easy as kdump/kexec/crash, but with little costs.
For something like Pstore, you can get where the issue occurs. You can figure out the problem if it is easy, but sometimes you can't. For example:
<4>[ 5.311431] task_blocks_on_rt_mutex+0x234/0x380 <4>[ 5.316166] rt_spin_lock_slowlock_locked+0xcc/0x2b0 <4>[ 5.321257] rt_spin_lock_slowlock+0x5c/0x90 <4>[ 5.325633] rt_spin_lock+0x60/0x74 <4>[ 5.329207] refill_stock+0x58/0x230You can find where the issue occurs.
static inline structrt_mutex_waiter*rt_mutex_top_waiter(structrt_mutex*lock)
{
structrb_node*leftmost =rb_first_cached(&lock->waiters); structrt_mutex_waiter*w = NULL;if (leftmost) { w = rb_entry(leftmost, struct rt_mutex_waiter, tree_entry); BUG_ON(w->lock != lock);
Quoted 6 lines
But you don't know why
w->lockand lock are different, and who is wrong.Qcom minidump can dump some logs like dmsg, some status like IRQ or Run queue. This can help to learn some information when the issue occurs, which will help to find out the root cause. But what it dumps are limited, it doesn't dump w and lock if they are not local data.
So add missing features to it. I don't think you got my comment and keep arguing on the same thing repeated for upstream submissions many times. We do not want multiple vendor solutions. Every vendor wants his work and does not care about integrating or reusing other pieces.
Quoted 5 lines
For osdump, it dumps objects stored in slab, datas in bss, data segments, some data alloced with memblock, data stored in local stack, and so on. In a word, it dumps almost all of the key data in the kernel. Besides, you can use the crash tool to analyze the dump file.
I don't see a problem why minidump cannot do it.
Quoted 3 lines
In a word, I think this toal different minidump should have its own place in the kernel world. Looking forward to your suggestions!
No, work with minidump.
For any further submissions which do not merge this work into minidump, please carry:
Best regards,
Krzysztof
Quoted 11 lines · Krzysztof Kozlowski
Quoted 4 lines
Qcom minidump can dump some logs like dmsg, some status like IRQ or Run queue. This can help to learn some information when the issue occurs, which will help to find out the root cause. But what it dumps are limited, it doesn't dump w and lock if they are not local data.
So add missing features to it. I don't think you got my comment and keep arguing on the same thing repeated for upstream submissions many times. We do not want multiple vendor solutions. Every vendor wants his work and does not care about integrating or reusing other pieces.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
For osdump, it dumps objects stored in slab, datas in bss, data segments, some data alloced with memblock, data stored in local stack, and so on. In a word, it dumps almost all of the key data in the kernel. Besides, you can use the crash tool to analyze the dump file.
I don't see a problem why minidump cannot do it.
Qcom minidump allows one kernel client to register its region to dump, and then driver will create and maintain one elf head for it.
But osdump will dump thousands of non-continuous regions. If you register one by one, and add an elf head for each, it will cause heavy overhead. So it store data in binary, and reassemble a standard elf format file offline for debug.
Sir, I am not really familiar with Qcom minidump, and some options may be wrong. But do you think it is ok to integrate osdump to Qcom? Looking forward to your suggestions!
Best Regards
Ruipeng
Quoted 7 lines · ruipeng qi
Quoted 1 line
I don't see a problem why minidump cannot do it.
Qcom minidump allows one kernel client to register its region to dump, and then driver will create and maintain one elf head for it.
But osdump will dump thousands of non-continuous regions. If you register one by one, and add an elf head for each, it will cause heavy overhead. So it store data in binary, and reassemble a standard elf format file offline for debug.
Osdump will only dump useful data, which may have been allocated before but freed now. In a word, useful data are changing all the time. I think this is not suitable for Qcom minidump's framework。
Best Regards
Ruipeng
Quoted 9 lines · ruipeng qi
Quoted 7 lines · ruipeng qi
Quoted 1 line
I don't see a problem why minidump cannot do it.
Qcom minidump allows one kernel client to register its region to dump, and then driver will create and maintain one elf head for it.
But osdump will dump thousands of non-continuous regions. If you register one by one, and add an elf head for each, it will cause heavy overhead. So it store data in binary, and reassemble a standard elf format file offline for debug.
Quoted 3 lines
Osdump will only dump useful data, which may have been allocated before but freed now. In a word, useful data are changing all the time. I think this is not suitable for Qcom minidump's framework。
Hey @ruipeng,
I like the idea, However, as i already said here
https://lore.kernel.org/lkml/[email protected]/
This looks more close to pstore ramoops based on Ram backend, as your entire thing is based on RAM content to be preserved across boot and that way it aligns to pstore ramoops concept.
Also most of the stuff like compression is already available in pstore. So, let me know if you think that way, will be happy to collaborate and test this.
-Mukesh
Quoted 4 lines
Best Regards
Ruipeng
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec