support lockless printk ringbuffer
Subsystems (3)
cover support lockless printk ringbuffer
Hi Kazu,
Here is a patch adding full support for the new lockless printk ringbuffer as it is currently being proposed. Note that the latest version has not yet been submitted to LKML. I was waiting until I finished tests with crash(8) and makedumpfile(8).
The new ringbuffer will export all the necessary symbols, sizes, and offsets in VMCOREINFO.
Note that I created a separate printk.c for the iteration logic.
Also note that I modified dwarf_info.c to support resolving typedefs of typedefs. This was necessary in order to support atomic_long_t and its "counter" member.
I don't expect you to take the patch as-is, but I hope it can provide some positive ground work for moving forward.
John Ogness (1):
printk: add support for lockless ringbuffer
Makefile | 2 +- dwarf_info.c | 36 +++++++++- makedumpfile.c | 101 ++++++++++++++++++++++++++-- makedumpfile.h | 25 +++++++ printk.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 printk.c
Signature · 7 lines
2.20.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
RFC PATCH 1/1 printk: add support for lockless ringbuffer
Linux is moving to a new lockless ringbuffer. The new ringbuffer is structured completely different to the previous iterations. Add support for retrieving the ringbuffer from debug information and/or using vmcoreinfo. The new ringbuffer is detected based on the availability of the "prb" symbol.
--- Makefile | 2 +- dwarf_info.c | 36 +++++++++- makedumpfile.c | 101 ++++++++++++++++++++++++++-- makedumpfile.h | 25 +++++++ printk.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 printk.c
Makefile +1 -1
@@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32 endif SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h -SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c +SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
dwarf_info.c +34 -2
@@ -614,6 +614,7 @@ search_structure(Dwarf_Die *die, int *found) {int tag;const char *name; +Dwarf_Die die_type;/* * If we get to here then we don't have any more
@@ -622,9 +623,31 @@ search_structure(Dwarf_Die *die, int *found) do { tag = dwarf_tag(die); name = dwarf_diename(die); - if ((tag != DW_TAG_structure_type) || (!name) - || strcmp(name, dwarf_info.struct_name)) + if ((!name) || strcmp(name, dwarf_info.struct_name)) + continue; + + if (tag == DW_TAG_typedef) { + if (!get_die_type(die, &die_type)) { + ERRMSG("Can't get CU die of DW_AT_type.\n"); + break; + } + + /* Resolve typedefs of typedefs. */ + while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) { + if (!get_die_type(&die_type, &die_type)) { + ERRMSG("Can't get CU die of DW_AT_type.\n"); + return; + } + } + + if (tag != DW_TAG_structure_type) + continue; + die = &die_type; + + } else if (tag != DW_TAG_structure_type) { continue; + } + /* * Skip if DW_AT_byte_size is not included. */
@@ -740,6 +763,15 @@ search_typedef(Dwarf_Die *die, int *found)ERRMSG ("Can't get CU die of DW_AT_type.\n" );break ; } + +/* Resolve typedefs of typedefs. */ +while ((tag =dwarf_tag (&die_type)) == DW_TAG_typedef) { +if (!get_die_type (&die_type, &die_type)) { +ERRMSG ("Can't get CU die of DW_AT_type.\n" ); +return ; + } + } + dwarf_info.struct_size =dwarf_bytesize (&die_type);if (dwarf_info.struct_size <=0 )continue ;
makedumpfile.c +96 -5
169 lines not on this page · raw message
makedumpfile.h +25 -0
@@ -1317,6 +1317,7 @@ struct DumpInfo {int flag_partial_dmesg;/* dmesg dump only from the last cleared index*/ int flag_mem_usage;/*show the page number of memory in different use*/ int flag_use_printk_log;/* did we read printk_log symbol name? */ +int flag_use_printk_ringbuffer;/* using lockless printk ringbuffer? */ int flag_nospace;/* the flag of "No space on device" error */ int flag_vmemmap;/* kernel supports vmemmap address space */ int flag_excludevm;/* -e - excluding unused vmemmap pages */
@@ -1602,6 +1603,7 @@ struct symbol_table {unsigned long long node_data;unsigned long long pgdat_list;unsigned long long contig_page_data; +unsigned long long prb;unsigned long long log_buf;unsigned long long log_buf_len;unsigned long long log_end;
@@ -1689,6 +1691,12 @@ struct size_table {long nodemask_t;long printk_log; +/* +* for lockless printk +*/ +long printk_ringbuffer; +long prb_desc; +/* * for Xen extraction */
@@ -1862,6 +1870,20 @@ struct offset_table {long ts_nsec;long len;long text_len; +long desc_ring; +long text_data_ring; +long count_bits; +long descs; +long head_id; +long tail_id; +long info; +long state_var; +long text_blk_lpos; +long begin; +long next; +long size_bits; +long data; +long counter; } printk_log;/*
@@ -2390,4 +2412,7 @@ int hexadecimal(char *s, int count);int decimal (char *s,int count);int file_exists (char *file); +int open_dump_file (void ); +int dump_lockless_dmesg (void ); +#endif /* MAKEDUMPFILE_H */
printk.c new file +177 -0
177 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi John,
Quoted 8 lines
-----Original Message-----
Hi Kazu,Here is a patch adding full support for the new lockless printk ringbuffer as it is currently being proposed. Note that the latest version has not yet been submitted to LKML. I was waiting until I finished tests with crash(8) and makedumpfile(8).
Quoted 4 lines
The new ringbuffer will export all the necessary symbols, sizes, and offsets in VMCOREINFO.
Note that I created a separate
printk.cfor the iteration logic.
That's good.
Quoted 4 lines
Also note that I modified
dwarf_info.cto support resolving typedefs of typedefs. This was necessary in order to supportatomic_long_tand its "counter" member.
OK, I see.
Quoted 3 lines
I don't expect you to take the patch as-is, but I hope it can provide some positive ground work for moving forward.
OK. It looks already well-considered.
Thank you very much for the patch!
Kazu
Quoted 12 lines
John Ogness (1):
printk: add support for lockless ringbufferMakefile | 2 +- dwarf_info.c | 36 +++++++++- makedumpfile.c | 101 ++++++++++++++++++++++++++-- makedumpfile.h | 25 +++++++ printk.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 printk.c
Quoted 2 lines
--
2.20.1
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec