diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-02-01 21:47:26 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-01 22:39:29 -0500 |
commit | 687ec6b1c91dbae2d232ef0faf9afceaaf0565db (patch) | |
tree | bf11a9f1b861ab38918456d65706cfa741a3e1af | |
parent | 702c42bd04bf2af5e87d8e3d1c80cac687bc91b8 (diff) |
trace-cmd: Handle junk on last page for tracecmd_read_cpu_last()
If the last page (or last pages) have just junk on it (timestamps
and discarded events), tracecmd_read_cpu_last should not return NULL.
It needs to test previous pages.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-input.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/trace-input.c b/trace-input.c index 31bcc55..40233c9 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -1006,7 +1006,7 @@ struct record * | |||
1006 | tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu) | 1006 | tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu) |
1007 | { | 1007 | { |
1008 | struct record *record = NULL; | 1008 | struct record *record = NULL; |
1009 | off64_t offset; | 1009 | off64_t offset, page_offset; |
1010 | 1010 | ||
1011 | offset = handle->cpu_data[cpu].file_offset + | 1011 | offset = handle->cpu_data[cpu].file_offset + |
1012 | handle->cpu_data[cpu].file_size; | 1012 | handle->cpu_data[cpu].file_size; |
@@ -1016,9 +1016,14 @@ tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu) | |||
1016 | else | 1016 | else |
1017 | offset -= handle->page_size; | 1017 | offset -= handle->page_size; |
1018 | 1018 | ||
1019 | if (get_page(handle, cpu, offset) < 0) | 1019 | page_offset = offset; |
1020 | |||
1021 | again: | ||
1022 | if (get_page(handle, cpu, page_offset) < 0) | ||
1020 | return NULL; | 1023 | return NULL; |
1021 | 1024 | ||
1025 | offset = page_offset; | ||
1026 | |||
1022 | do { | 1027 | do { |
1023 | free_record(record); | 1028 | free_record(record); |
1024 | record = tracecmd_read_data(handle, cpu); | 1029 | record = tracecmd_read_data(handle, cpu); |
@@ -1026,7 +1031,20 @@ tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu) | |||
1026 | offset = record->offset; | 1031 | offset = record->offset; |
1027 | } while (record); | 1032 | } while (record); |
1028 | 1033 | ||
1029 | return tracecmd_read_at(handle, offset, NULL); | 1034 | record = tracecmd_read_at(handle, offset, NULL); |
1035 | |||
1036 | /* | ||
1037 | * It is possible that a page has just a timestamp | ||
1038 | * or just padding on it. | ||
1039 | */ | ||
1040 | if (!record) { | ||
1041 | if (page_offset == handle->cpu_data[cpu].file_offset) | ||
1042 | return NULL; | ||
1043 | page_offset -= handle->page_size; | ||
1044 | goto again; | ||
1045 | } | ||
1046 | |||
1047 | return record; | ||
1030 | } | 1048 | } |
1031 | 1049 | ||
1032 | /** | 1050 | /** |