All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] makedumpfile: support --partial-dmesg on 5.10+ kernels
@ 2021-08-16 22:49 Ivan Delalande
  2021-08-18  1:21 ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Delalande @ 2021-08-16 22:49 UTC (permalink / raw)
  To: John Ogness, Kazuhito Hagio; +Cc: kexec

The new printk ringbuffer implementation added in kernel v5.10 with
commit 896fbe20b4e2 ("printk: use the lockless ringbuffer") also
exported a new vmcore symbol "clear_seq" to keep track where dmesg had
been cleared like "clear_idx" on previous versions. Use it in
dump_lockless_dmesg when --partial-dmesg is passed to find and start
dumping messages only from that index.

Signed-off-by: Ivan Delalande <colona@arista.com>
---
 makedumpfile.c |  3 +++
 makedumpfile.h |  1 +
 printk.c       | 10 ++++++++++
 3 files changed, 14 insertions(+)

diff --git a/makedumpfile.c b/makedumpfile.c
index b1b3b42..caf4d12 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1555,6 +1555,7 @@ get_symbol_info(void)
 	SYMBOL_INIT(pgdat_list, "pgdat_list");
 	SYMBOL_INIT(contig_page_data, "contig_page_data");
 	SYMBOL_INIT(prb, "prb");
+	SYMBOL_INIT(clear_seq, "clear_seq");
 	SYMBOL_INIT(log_buf, "log_buf");
 	SYMBOL_INIT(log_buf_len, "log_buf_len");
 	SYMBOL_INIT(log_end, "log_end");
@@ -2231,6 +2232,7 @@ write_vmcoreinfo_data(void)
 	WRITE_SYMBOL("pgdat_list", pgdat_list);
 	WRITE_SYMBOL("contig_page_data", contig_page_data);
 	WRITE_SYMBOL("prb", prb);
+	WRITE_SYMBOL("clear_seq", clear_seq);
 	WRITE_SYMBOL("log_buf", log_buf);
 	WRITE_SYMBOL("log_buf_len", log_buf_len);
 	WRITE_SYMBOL("log_end", log_end);
@@ -2676,6 +2678,7 @@ read_vmcoreinfo(void)
 	READ_SYMBOL("pgdat_list", pgdat_list);
 	READ_SYMBOL("contig_page_data", contig_page_data);
 	READ_SYMBOL("prb", prb);
+	READ_SYMBOL("clear_seq", clear_seq);
 	READ_SYMBOL("log_buf", log_buf);
 	READ_SYMBOL("log_buf_len", log_buf_len);
 	READ_SYMBOL("log_end", log_end);
diff --git a/makedumpfile.h b/makedumpfile.h
index ca50a89..c57ac7a 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1656,6 +1656,7 @@ struct symbol_table {
 	unsigned long long	pgdat_list;
 	unsigned long long	contig_page_data;
 	unsigned long long	prb;
+	unsigned long long	clear_seq;
 	unsigned long long	log_buf;
 	unsigned long long	log_buf_len;
 	unsigned long long	log_end;
diff --git a/printk.c b/printk.c
index e8501c7..a160a5f 100644
--- a/printk.c
+++ b/printk.c
@@ -145,6 +145,7 @@ dump_record(struct prb_map *m, unsigned long id)
 int
 dump_lockless_dmesg(void)
 {
+	unsigned long long clear_seq;
 	unsigned long head_id;
 	unsigned long tail_id;
 	unsigned long kaddr;
@@ -216,6 +217,15 @@ dump_lockless_dmesg(void)
 			OFFSET(atomic_long_t.counter));
 	head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) +
 			OFFSET(atomic_long_t.counter));
+	if (info->flag_partial_dmesg && SYMBOL(clear_seq) != NOT_FOUND_SYMBOL) {
+		if (!readmem(VADDR, SYMBOL(clear_seq), &clear_seq,
+			     sizeof(clear_seq))) {
+			ERRMSG("Can't get clear_seq.\n");
+			goto out_text_data;
+		}
+		tail_id = head_id - head_id % m.desc_ring_count +
+			  clear_seq % m.desc_ring_count;
+	}
 
 	if (!open_dump_file()) {
 		ERRMSG("Can't open output file.\n");
-- 
2.32.0

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] makedumpfile: support --partial-dmesg on 5.10+ kernels
  2021-08-16 22:49 [PATCH] makedumpfile: support --partial-dmesg on 5.10+ kernels Ivan Delalande
@ 2021-08-18  1:21 ` HAGIO KAZUHITO(萩尾 一仁)
  2021-08-30 23:28   ` [PATCH v2] " Ivan Delalande
  0 siblings, 1 reply; 4+ messages in thread
From: HAGIO KAZUHITO(萩尾 一仁) @ 2021-08-18  1:21 UTC (permalink / raw)
  To: Ivan Delalande; +Cc: kexec, John Ogness

Hi Ivan,

-----Original Message-----
> The new printk ringbuffer implementation added in kernel v5.10 with
> commit 896fbe20b4e2 ("printk: use the lockless ringbuffer") also
> exported a new vmcore symbol "clear_seq" to keep track where dmesg had
> been cleared like "clear_idx" on previous versions. Use it in
> dump_lockless_dmesg when --partial-dmesg is passed to find and start
> dumping messages only from that index.

Thanks for the patch.

Kernel commit 7d7a23a91c91 ("printk: use seqcount_latch for clear_seq")
changed the clear_seq, the patch does not work correctly on 5.13+ kernels.

But the commit exported these values to vmcoreinfo:

SIZE(latched_seq)=24
OFFSET(latched_seq.val)=8

Can it support also 5.13+ with these?

Thanks,
Kazu

> 
> Signed-off-by: Ivan Delalande <colona@arista.com>
> ---
>  makedumpfile.c |  3 +++
>  makedumpfile.h |  1 +
>  printk.c       | 10 ++++++++++
>  3 files changed, 14 insertions(+)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index b1b3b42..caf4d12 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -1555,6 +1555,7 @@ get_symbol_info(void)
>  	SYMBOL_INIT(pgdat_list, "pgdat_list");
>  	SYMBOL_INIT(contig_page_data, "contig_page_data");
>  	SYMBOL_INIT(prb, "prb");
> +	SYMBOL_INIT(clear_seq, "clear_seq");
>  	SYMBOL_INIT(log_buf, "log_buf");
>  	SYMBOL_INIT(log_buf_len, "log_buf_len");
>  	SYMBOL_INIT(log_end, "log_end");
> @@ -2231,6 +2232,7 @@ write_vmcoreinfo_data(void)
>  	WRITE_SYMBOL("pgdat_list", pgdat_list);
>  	WRITE_SYMBOL("contig_page_data", contig_page_data);
>  	WRITE_SYMBOL("prb", prb);
> +	WRITE_SYMBOL("clear_seq", clear_seq);
>  	WRITE_SYMBOL("log_buf", log_buf);
>  	WRITE_SYMBOL("log_buf_len", log_buf_len);
>  	WRITE_SYMBOL("log_end", log_end);
> @@ -2676,6 +2678,7 @@ read_vmcoreinfo(void)
>  	READ_SYMBOL("pgdat_list", pgdat_list);
>  	READ_SYMBOL("contig_page_data", contig_page_data);
>  	READ_SYMBOL("prb", prb);
> +	READ_SYMBOL("clear_seq", clear_seq);
>  	READ_SYMBOL("log_buf", log_buf);
>  	READ_SYMBOL("log_buf_len", log_buf_len);
>  	READ_SYMBOL("log_end", log_end);
> diff --git a/makedumpfile.h b/makedumpfile.h
> index ca50a89..c57ac7a 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -1656,6 +1656,7 @@ struct symbol_table {
>  	unsigned long long	pgdat_list;
>  	unsigned long long	contig_page_data;
>  	unsigned long long	prb;
> +	unsigned long long	clear_seq;
>  	unsigned long long	log_buf;
>  	unsigned long long	log_buf_len;
>  	unsigned long long	log_end;
> diff --git a/printk.c b/printk.c
> index e8501c7..a160a5f 100644
> --- a/printk.c
> +++ b/printk.c
> @@ -145,6 +145,7 @@ dump_record(struct prb_map *m, unsigned long id)
>  int
>  dump_lockless_dmesg(void)
>  {
> +	unsigned long long clear_seq;
>  	unsigned long head_id;
>  	unsigned long tail_id;
>  	unsigned long kaddr;
> @@ -216,6 +217,15 @@ dump_lockless_dmesg(void)
>  			OFFSET(atomic_long_t.counter));
>  	head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) +
>  			OFFSET(atomic_long_t.counter));
> +	if (info->flag_partial_dmesg && SYMBOL(clear_seq) != NOT_FOUND_SYMBOL) {
> +		if (!readmem(VADDR, SYMBOL(clear_seq), &clear_seq,
> +			     sizeof(clear_seq))) {
> +			ERRMSG("Can't get clear_seq.\n");
> +			goto out_text_data;
> +		}
> +		tail_id = head_id - head_id % m.desc_ring_count +
> +			  clear_seq % m.desc_ring_count;
> +	}
> 
>  	if (!open_dump_file()) {
>  		ERRMSG("Can't open output file.\n");
> --
> 2.32.0

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] makedumpfile: support --partial-dmesg on 5.10+ kernels
  2021-08-18  1:21 ` HAGIO KAZUHITO(萩尾 一仁)
@ 2021-08-30 23:28   ` Ivan Delalande
  2021-09-01  5:27     ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Delalande @ 2021-08-30 23:28 UTC (permalink / raw)
  To: HAGIO KAZUHITO(萩尾 一仁)
  Cc: kexec, John Ogness

The new printk ringbuffer implementation added in kernel v5.10 with
commit 896fbe20b4e2 ("printk: use the lockless ringbuffer") also
exported a new vmcore symbol "clear_seq" to keep track where dmesg had
been cleared like "clear_idx" on previous versions. Use it in
dump_lockless_dmesg when --partial-dmesg is passed to find and start
dumping messages only from that index.

On v5.13, commit 7d7a23a91c91 ("printk: use seqcount_latch for
clear_seq") converted it from a simple value, and so an additional step
is required to find and retrieve the sequence at the right offset in the
latched_seq structure it now uses.

Signed-off-by: Ivan Delalande <colona@arista.com>
---
 makedumpfile.c | 12 ++++++++++++
 makedumpfile.h |  6 ++++++
 printk.c       | 19 +++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/makedumpfile.c b/makedumpfile.c
index b1b3b42..ac17f19 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1555,6 +1555,7 @@ get_symbol_info(void)
 	SYMBOL_INIT(pgdat_list, "pgdat_list");
 	SYMBOL_INIT(contig_page_data, "contig_page_data");
 	SYMBOL_INIT(prb, "prb");
+	SYMBOL_INIT(clear_seq, "clear_seq");
 	SYMBOL_INIT(log_buf, "log_buf");
 	SYMBOL_INIT(log_buf_len, "log_buf_len");
 	SYMBOL_INIT(log_end, "log_end");
@@ -2000,6 +2001,9 @@ get_structure_info(void)
 		OFFSET_INIT(printk_info.text_len, "printk_info", "text_len");
 
 		OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter");
+
+		SIZE_INIT(latched_seq, "latched_seq");
+		OFFSET_INIT(latched_seq.val, "latched_seq", "val");
 	} else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
 		/*
 		 * In kernel 3.11-rc4 the log structure name was renamed
@@ -2231,6 +2235,7 @@ write_vmcoreinfo_data(void)
 	WRITE_SYMBOL("pgdat_list", pgdat_list);
 	WRITE_SYMBOL("contig_page_data", contig_page_data);
 	WRITE_SYMBOL("prb", prb);
+	WRITE_SYMBOL("clear_seq", clear_seq);
 	WRITE_SYMBOL("log_buf", log_buf);
 	WRITE_SYMBOL("log_buf_len", log_buf_len);
 	WRITE_SYMBOL("log_end", log_end);
@@ -2266,6 +2271,7 @@ write_vmcoreinfo_data(void)
 		WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer);
 		WRITE_STRUCTURE_SIZE("prb_desc", prb_desc);
 		WRITE_STRUCTURE_SIZE("printk_info", printk_info);
+		WRITE_STRUCTURE_SIZE("latched_seq", latched_seq);
 	} else if (info->flag_use_printk_log)
 		WRITE_STRUCTURE_SIZE("printk_log", printk_log);
 	else
@@ -2335,6 +2341,8 @@ write_vmcoreinfo_data(void)
 		WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
 
 		WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
+
+		WRITE_MEMBER_OFFSET("latched_seq.val", latched_seq.val);
 	} else if (info->flag_use_printk_log) {
 		WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
 		WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len);
@@ -2676,6 +2684,7 @@ read_vmcoreinfo(void)
 	READ_SYMBOL("pgdat_list", pgdat_list);
 	READ_SYMBOL("contig_page_data", contig_page_data);
 	READ_SYMBOL("prb", prb);
+	READ_SYMBOL("clear_seq", clear_seq);
 	READ_SYMBOL("log_buf", log_buf);
 	READ_SYMBOL("log_buf_len", log_buf_len);
 	READ_SYMBOL("log_end", log_end);
@@ -2784,6 +2793,9 @@ read_vmcoreinfo(void)
 		READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
 
 		READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
+
+		READ_STRUCTURE_SIZE("latched_seq", latched_seq);
+		READ_MEMBER_OFFSET("latched_seq.val", latched_seq.val);
 	} else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
 		info->flag_use_printk_ringbuffer = FALSE;
 		info->flag_use_printk_log = TRUE;
diff --git a/makedumpfile.h b/makedumpfile.h
index ca50a89..bd9e2f6 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1656,6 +1656,7 @@ struct symbol_table {
 	unsigned long long	pgdat_list;
 	unsigned long long	contig_page_data;
 	unsigned long long	prb;
+	unsigned long long	clear_seq;
 	unsigned long long	log_buf;
 	unsigned long long	log_buf_len;
 	unsigned long long	log_end;
@@ -1749,6 +1750,7 @@ struct size_table {
 	long	printk_ringbuffer;
 	long	prb_desc;
 	long	printk_info;
+	long	latched_seq;
 
 	/*
 	 * for Xen extraction
@@ -1973,6 +1975,10 @@ struct offset_table {
 		long counter;
 	} atomic_long_t;
 
+	struct latched_seq_s {
+		long val;
+	} latched_seq;
+
 	/*
 	 * symbols on ppc64 arch
 	 */
diff --git a/printk.c b/printk.c
index e8501c7..61e0b26 100644
--- a/printk.c
+++ b/printk.c
@@ -145,6 +145,7 @@ dump_record(struct prb_map *m, unsigned long id)
 int
 dump_lockless_dmesg(void)
 {
+	unsigned long long clear_seq;
 	unsigned long head_id;
 	unsigned long tail_id;
 	unsigned long kaddr;
@@ -216,6 +217,24 @@ dump_lockless_dmesg(void)
 			OFFSET(atomic_long_t.counter));
 	head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) +
 			OFFSET(atomic_long_t.counter));
+	if (info->flag_partial_dmesg && SYMBOL(clear_seq) != NOT_FOUND_SYMBOL) {
+		if (!readmem(VADDR, SYMBOL(clear_seq), &clear_seq,
+			     sizeof(clear_seq))) {
+			ERRMSG("Can't get clear_seq.\n");
+			goto out_text_data;
+		}
+		if (SIZE(latched_seq) != NOT_FOUND_STRUCTURE) {
+			kaddr = SYMBOL(clear_seq) + OFFSET(latched_seq.val) +
+				(clear_seq & 0x1) * sizeof(clear_seq);
+			if (!readmem(VADDR, kaddr, &clear_seq,
+				     sizeof(clear_seq))) {
+				ERRMSG("Can't get latched clear_seq.\n");
+				goto out_text_data;
+			}
+		}
+		tail_id = head_id - head_id % m.desc_ring_count +
+			  clear_seq % m.desc_ring_count;
+	}
 
 	if (!open_dump_file()) {
 		ERRMSG("Can't open output file.\n");
-- 
2.33.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] makedumpfile: support --partial-dmesg on 5.10+ kernels
  2021-08-30 23:28   ` [PATCH v2] " Ivan Delalande
@ 2021-09-01  5:27     ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 0 replies; 4+ messages in thread
From: HAGIO KAZUHITO(萩尾 一仁) @ 2021-09-01  5:27 UTC (permalink / raw)
  To: Ivan Delalande; +Cc: kexec, John Ogness

-----Original Message-----
> The new printk ringbuffer implementation added in kernel v5.10 with
> commit 896fbe20b4e2 ("printk: use the lockless ringbuffer") also
> exported a new vmcore symbol "clear_seq" to keep track where dmesg had
> been cleared like "clear_idx" on previous versions. Use it in
> dump_lockless_dmesg when --partial-dmesg is passed to find and start
> dumping messages only from that index.
> 
> On v5.13, commit 7d7a23a91c91 ("printk: use seqcount_latch for
> clear_seq") converted it from a simple value, and so an additional step
> is required to find and retrieve the sequence at the right offset in the
> latched_seq structure it now uses.
> 
> Signed-off-by: Ivan Delalande <colona@arista.com>

The v2 patch tested OK on 5.12 and 5.14.  Applied.
https://github.com/makedumpfile/makedumpfile/commit/bccc39c147fea2b29f98f9973614c7a6697a065d

Thanks,
Kazu

> ---
>  makedumpfile.c | 12 ++++++++++++
>  makedumpfile.h |  6 ++++++
>  printk.c       | 19 +++++++++++++++++++
>  3 files changed, 37 insertions(+)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index b1b3b42..ac17f19 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -1555,6 +1555,7 @@ get_symbol_info(void)
>  	SYMBOL_INIT(pgdat_list, "pgdat_list");
>  	SYMBOL_INIT(contig_page_data, "contig_page_data");
>  	SYMBOL_INIT(prb, "prb");
> +	SYMBOL_INIT(clear_seq, "clear_seq");
>  	SYMBOL_INIT(log_buf, "log_buf");
>  	SYMBOL_INIT(log_buf_len, "log_buf_len");
>  	SYMBOL_INIT(log_end, "log_end");
> @@ -2000,6 +2001,9 @@ get_structure_info(void)
>  		OFFSET_INIT(printk_info.text_len, "printk_info", "text_len");
> 
>  		OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter");
> +
> +		SIZE_INIT(latched_seq, "latched_seq");
> +		OFFSET_INIT(latched_seq.val, "latched_seq", "val");
>  	} else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
>  		/*
>  		 * In kernel 3.11-rc4 the log structure name was renamed
> @@ -2231,6 +2235,7 @@ write_vmcoreinfo_data(void)
>  	WRITE_SYMBOL("pgdat_list", pgdat_list);
>  	WRITE_SYMBOL("contig_page_data", contig_page_data);
>  	WRITE_SYMBOL("prb", prb);
> +	WRITE_SYMBOL("clear_seq", clear_seq);
>  	WRITE_SYMBOL("log_buf", log_buf);
>  	WRITE_SYMBOL("log_buf_len", log_buf_len);
>  	WRITE_SYMBOL("log_end", log_end);
> @@ -2266,6 +2271,7 @@ write_vmcoreinfo_data(void)
>  		WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer);
>  		WRITE_STRUCTURE_SIZE("prb_desc", prb_desc);
>  		WRITE_STRUCTURE_SIZE("printk_info", printk_info);
> +		WRITE_STRUCTURE_SIZE("latched_seq", latched_seq);
>  	} else if (info->flag_use_printk_log)
>  		WRITE_STRUCTURE_SIZE("printk_log", printk_log);
>  	else
> @@ -2335,6 +2341,8 @@ write_vmcoreinfo_data(void)
>  		WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
> 
>  		WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
> +
> +		WRITE_MEMBER_OFFSET("latched_seq.val", latched_seq.val);
>  	} else if (info->flag_use_printk_log) {
>  		WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
>  		WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len);
> @@ -2676,6 +2684,7 @@ read_vmcoreinfo(void)
>  	READ_SYMBOL("pgdat_list", pgdat_list);
>  	READ_SYMBOL("contig_page_data", contig_page_data);
>  	READ_SYMBOL("prb", prb);
> +	READ_SYMBOL("clear_seq", clear_seq);
>  	READ_SYMBOL("log_buf", log_buf);
>  	READ_SYMBOL("log_buf_len", log_buf_len);
>  	READ_SYMBOL("log_end", log_end);
> @@ -2784,6 +2793,9 @@ read_vmcoreinfo(void)
>  		READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
> 
>  		READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
> +
> +		READ_STRUCTURE_SIZE("latched_seq", latched_seq);
> +		READ_MEMBER_OFFSET("latched_seq.val", latched_seq.val);
>  	} else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
>  		info->flag_use_printk_ringbuffer = FALSE;
>  		info->flag_use_printk_log = TRUE;
> diff --git a/makedumpfile.h b/makedumpfile.h
> index ca50a89..bd9e2f6 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -1656,6 +1656,7 @@ struct symbol_table {
>  	unsigned long long	pgdat_list;
>  	unsigned long long	contig_page_data;
>  	unsigned long long	prb;
> +	unsigned long long	clear_seq;
>  	unsigned long long	log_buf;
>  	unsigned long long	log_buf_len;
>  	unsigned long long	log_end;
> @@ -1749,6 +1750,7 @@ struct size_table {
>  	long	printk_ringbuffer;
>  	long	prb_desc;
>  	long	printk_info;
> +	long	latched_seq;
> 
>  	/*
>  	 * for Xen extraction
> @@ -1973,6 +1975,10 @@ struct offset_table {
>  		long counter;
>  	} atomic_long_t;
> 
> +	struct latched_seq_s {
> +		long val;
> +	} latched_seq;
> +
>  	/*
>  	 * symbols on ppc64 arch
>  	 */
> diff --git a/printk.c b/printk.c
> index e8501c7..61e0b26 100644
> --- a/printk.c
> +++ b/printk.c
> @@ -145,6 +145,7 @@ dump_record(struct prb_map *m, unsigned long id)
>  int
>  dump_lockless_dmesg(void)
>  {
> +	unsigned long long clear_seq;
>  	unsigned long head_id;
>  	unsigned long tail_id;
>  	unsigned long kaddr;
> @@ -216,6 +217,24 @@ dump_lockless_dmesg(void)
>  			OFFSET(atomic_long_t.counter));
>  	head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) +
>  			OFFSET(atomic_long_t.counter));
> +	if (info->flag_partial_dmesg && SYMBOL(clear_seq) != NOT_FOUND_SYMBOL) {
> +		if (!readmem(VADDR, SYMBOL(clear_seq), &clear_seq,
> +			     sizeof(clear_seq))) {
> +			ERRMSG("Can't get clear_seq.\n");
> +			goto out_text_data;
> +		}
> +		if (SIZE(latched_seq) != NOT_FOUND_STRUCTURE) {
> +			kaddr = SYMBOL(clear_seq) + OFFSET(latched_seq.val) +
> +				(clear_seq & 0x1) * sizeof(clear_seq);
> +			if (!readmem(VADDR, kaddr, &clear_seq,
> +				     sizeof(clear_seq))) {
> +				ERRMSG("Can't get latched clear_seq.\n");
> +				goto out_text_data;
> +			}
> +		}
> +		tail_id = head_id - head_id % m.desc_ring_count +
> +			  clear_seq % m.desc_ring_count;
> +	}
> 
>  	if (!open_dump_file()) {
>  		ERRMSG("Can't open output file.\n");
> --
> 2.33.0

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-01  5:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 22:49 [PATCH] makedumpfile: support --partial-dmesg on 5.10+ kernels Ivan Delalande
2021-08-18  1:21 ` HAGIO KAZUHITO(萩尾 一仁)
2021-08-30 23:28   ` [PATCH v2] " Ivan Delalande
2021-09-01  5:27     ` HAGIO KAZUHITO(萩尾 一仁)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.