Re: Fwd: [PATCH 0/3] trace.so: Make trace dump -t work again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Let me try that again with discrete attachments.


----- Original Message -----
> 
> ----- Original Message -----
> >
> >>> The problem happens only with module symbols, not with kallsyms.
> >>>
> >>> crash> sym -M
> >>> c008000007810000 MODULE START: crc32c_vpmsum
> >>> c008000007810000 (^R) __crc32c_vpmsum
> >>> c008000007810670 (^B) crc32c_vpmsum_cra_init
> >>> c008000007810690 (^B) crc32c_vpmsum_setkey
> >>
> >> Hi Ravi,
> >>
> >> I have never seen this before, but nonetheless, it does seem that Steve's
> >> patch
> >> to the trace.c module is the better course of action.  Does it work OK for
> >> you?
> >>
> >> Dave
> >
> > Dave, I see only cover letter:
> >   https://www.redhat.com/archives/crash-utility/2019-March/thread.html
> >
> > Can you please forward patches to ml as well.
> >
> 
> Sorry about that...
> 
> Dave
> 
> 
> --
> Crash-utility mailing list
> Crash-utility@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/crash-utility
--- Begin Message ---
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

The -t option is not listed with just crash> trace dump -h
As -t is the most common option for trace dump, it really should be
there on the short help message.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
 extensions/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extensions/trace.c b/extensions/trace.c
index 51a1ab2..c26b6c7 100644
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -1834,7 +1834,7 @@ static void cmd_ftrace(void)
 static char *help_ftrace[] = {
 "trace",
 "show or dump the tracing info",
-"[ <show [-c <cpulist>] [-f [no]<flagname>]> | <dump [-sm] <dest-dir>> ]",
+"[ <show [-c <cpulist>] [-f [no]<flagname>]> | <dump [-sm] <dest-dir>> ] | <dump -t <trace.dat> ]",
 "trace",
 "    shows the current tracer and other informations.",
 "",
-- 
2.20.1


--- End Message ---
--- Begin Message ---
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

It appears that the sp->type is garbage, and writing that to the
kallsyms file for trace-cmd to read, causes it to crash. trace-cmd
doesn't even care about the type field so just write "m".

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
 extensions/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/extensions/trace.c b/extensions/trace.c
index 3827430..51a1ab2 100644
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -2209,7 +2209,8 @@ static int save_proc_kallsyms(int fd)
 			if (!strncmp(sp->name, "_MODULE_", strlen("_MODULE_")))
 				continue;
 
-			tmp_fprintf("%lx %c %s\t[%s]\n", sp->value, sp->type,
+			/* Currently sp->type for modules is not trusted */
+			tmp_fprintf("%lx %c %s\t[%s]\n", sp->value, 'm',
 					sp->name, lm->mod_name);
 		}
 	}
-- 
2.20.1


--- End Message ---
--- Begin Message ---
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

The reader_page can be empty if it was never read, do not record it if
it is empty. Better yet, do not record any page that is empty.

The struct buffer_page "real_end" is not available in older kernels, so
it needs to be tested if it exists before we can use it.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
 extensions/trace.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/extensions/trace.c b/extensions/trace.c
index ad71951..3827430 100644
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -43,6 +43,11 @@ static int max_buffer_available;
  */
 static int multiple_instances_available;
 
+/*
+ * buffer_page has "real_end"
+ */
+static int buffer_page_real_end_available;
+
 #define koffset(struct, member) struct##_##member##_offset
 
 static int koffset(trace_array, current_trace);
@@ -70,6 +75,7 @@ static int koffset(ring_buffer_per_cpu, entries);
 static int koffset(buffer_page, read);
 static int koffset(buffer_page, list);
 static int koffset(buffer_page, page);
+static int koffset(buffer_page, real_end);
 
 static int koffset(list_head, next);
 
@@ -229,6 +235,7 @@ static int init_offsets(void)
 	init_offset(buffer_page, read);
 	init_offset(buffer_page, list);
 	init_offset(buffer_page, page);
+	init_offset(buffer_page, real_end);
 
 	init_offset(list_head, next);
 
@@ -281,6 +288,7 @@ static void print_offsets(void)
 	print_offset(buffer_page, read);
 	print_offset(buffer_page, list);
 	print_offset(buffer_page, page);
+	print_offset(buffer_page, real_end);
 
 	print_offset(list_head, next);
 
@@ -295,6 +303,20 @@ static void print_offsets(void)
 #undef print_offset
 }
 
+static int buffer_page_has_data(ulong page)
+{
+	uint end;
+
+	if (!buffer_page_real_end_available)
+		return 1;
+
+	/* Only write pages with data in it */
+	read_value(end, page, buffer_page, real_end);
+	return end;
+out_fail:
+	return 0;
+}
+
 static int ftrace_init_pages(struct ring_buffer_per_cpu *cpu_buffer,
 		unsigned nr_pages)
 {
@@ -361,7 +383,8 @@ static int ftrace_init_pages(struct ring_buffer_per_cpu *cpu_buffer,
 
 	/* Setup linear pages */
 
-	cpu_buffer->linear_pages[count++] = cpu_buffer->reader_page;
+	if (buffer_page_has_data(cpu_buffer->reader_page))
+		cpu_buffer->linear_pages[count++] = cpu_buffer->reader_page;
 
 	if (cpu_buffer->reader_page == cpu_buffer->commit_page)
 		goto done;
@@ -647,6 +670,8 @@ static int ftrace_init(void)
 		ftrace_trace_arrays = sym_ftrace_trace_arrays->value;
 	}
 
+	if (MEMBER_EXISTS("buffer_page", "real_end"))
+		buffer_page_real_end_available = 1;
 
 	if (MEMBER_EXISTS("trace_array", "current_trace")) {
 		encapsulated_current_trace = 1;
-- 
2.20.1


--- End Message ---
--- Begin Message ---
Hi Dave,

I gave a talk at SCaLE 17x last week and was going to demonstrate using
ftrace on a system that crashes, and then pulling out the vmcore file
with kexec and kdump, and then pulling out the ftrace ring buffers and
creating a trace.dat file with the crash extension trace.so.
Unfortunately, this wasn't working as I planned. I created the
following three patches, where two fix the issue (I was getting a
corrupted trace.dat file), and the third actually documents the '-t'
option of the dump command. Hopefully you can accept these patches.

Thanks!

-- Steve

-----
 extensions/trace.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

Steven Rostedt (VMware) (3):
      trace.so: Do not record empty pages
      trace.so: Do not print garbage for kallsyms "type" for modules
      trace.so: Show -t option in trace dump short help message

--- End Message ---
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux