aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>2020-07-06 18:47:14 +0300
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2021-03-26 13:11:29 -0400
commit42347e10aa05b6b0825adccf33a82f21742484ac (patch)
tree669995a3e844db977f17b643513d5b308169ffa0
parentcd9cf71c1ac1c57037e2749eef210116b9f1ce64 (diff)
downloadlibtraceevent-42347e10aa05b6b0825adccf33a82f21742484ac.tar.gz
tools lib traceveent: Fix kbuffer_start_of_data() to return the first record
The first record in a ring buffer page may not allways be at the beginning of the page. There could be time-extends injected before it. In this case kbuffer_start_of_data() will not return the first record, as expected. Additional field "start" is added in kbuffer struct, to hold the offset of the first record from the page and kbuffer_start_of_data() is modified to use it. Link: https://lore.kernel.org/linux-trace-devel/20200706154714.27566-1-tz.stoyanov@gmail.com Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> [ Finished the patch from Steven ] Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
-rw-r--r--src/kbuffer-parse.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/kbuffer-parse.c b/src/kbuffer-parse.c
index f1640d6..7499950 100644
--- a/src/kbuffer-parse.c
+++ b/src/kbuffer-parse.c
@@ -35,6 +35,7 @@ enum {
* @next - offset from @data to the start of next event
* @size - The size of data on @data
* @start - The offset from @subbuffer where @data lives
+ * @first - The offset from @subbuffer where the first non time stamp event lives
*
* @read_4 - Function to read 4 raw bytes (may swap)
* @read_8 - Function to read 8 raw bytes (may swap)
@@ -51,6 +52,7 @@ struct kbuffer {
unsigned int next;
unsigned int size;
unsigned int start;
+ unsigned int first;
unsigned int (*read_4)(void *ptr);
unsigned long long (*read_8)(void *ptr);
@@ -546,6 +548,9 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)
next_event(kbuf);
+ /* save the first record from the page */
+ kbuf->first = kbuf->curr;
+
return 0;
}
@@ -756,7 +761,7 @@ void kbuffer_set_old_format(struct kbuffer *kbuf)
*/
int kbuffer_start_of_data(struct kbuffer *kbuf)
{
- return kbuf->start;
+ return kbuf->first + kbuf->start;
}
/**