diff mbox series

[v2,01/15] tools lib traceevent: Add API to read time information from kbuffer

Message ID 20200702185703.619656282@goodmis.org (mailing list archive)
State Superseded
Headers show
Series tools lib traceevent: Patches from the trace-cmd repo | expand

Commit Message

Steven Rostedt July 2, 2020, 6:53 p.m. UTC
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Add the functions kbuffer_subbuf_timestamp() and kbuffer_ptr_delta() to get
the timing data stored in the ring buffer that is used to produced the time
stamps of the records.

This is useful for tools like trace-cmd to be able to display the content of
the read data to understand why the records show the time stamps that they
do.

Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-2-tz.stoyanov@gmail.com

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
[ Ported from trace-cmd.git ]
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/lib/traceevent/kbuffer-parse.c | 28 ++++++++++++++++++++++++++++
 tools/lib/traceevent/kbuffer.h       |  2 ++
 2 files changed, 30 insertions(+)

Comments

Arnaldo Carvalho de Melo July 3, 2020, 11:31 a.m. UTC | #1
Em Thu, Jul 02, 2020 at 02:53:45PM -0400, Steven Rostedt escreveu:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> 
> Add the functions kbuffer_subbuf_timestamp() and kbuffer_ptr_delta() to get
> the timing data stored in the ring buffer that is used to produced the time
> stamps of the records.
> 
> This is useful for tools like trace-cmd to be able to display the content of
> the read data to understand why the records show the time stamps that they
> do.
> 
> Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-2-tz.stoyanov@gmail.com
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> [ Ported from trace-cmd.git ]
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Humm, is that intentional, i.e. two signed-off-by you?

- Arnaldo

> ---
>  tools/lib/traceevent/kbuffer-parse.c | 28 ++++++++++++++++++++++++++++
>  tools/lib/traceevent/kbuffer.h       |  2 ++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
> index 27f3b07fdae8..583db99aee94 100644
> --- a/tools/lib/traceevent/kbuffer-parse.c
> +++ b/tools/lib/traceevent/kbuffer-parse.c
> @@ -546,6 +546,34 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)
>  	return 0;
>  }
>  
> +/**
> + * kbuffer_subbuf_timestamp - read the timestamp from a sub buffer
> + * @kbuf:      The kbuffer to load
> + * @subbuf:    The subbuffer to read from.
> + *
> + * Return the timestamp from a subbuffer.
> + */
> +unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf)
> +{
> +	return kbuf->read_8(subbuf);
> +}
> +
> +/**
> + * kbuffer_ptr_delta - read the delta field from a record
> + * @kbuf:      The kbuffer to load
> + * @ptr:       The record in the buffe.
> + *
> + * Return the timestamp delta from a record
> + */
> +unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr)
> +{
> +	unsigned int type_len_ts;
> +
> +	type_len_ts = read_4(kbuf, ptr);
> +	return ts4host(kbuf, type_len_ts);
> +}
> +
> +
>  /**
>   * kbuffer_read_event - read the next event in the kbuffer subbuffer
>   * @kbuf:	The kbuffer to read from
> diff --git a/tools/lib/traceevent/kbuffer.h b/tools/lib/traceevent/kbuffer.h
> index ed4d697fc137..5fa8292e341b 100644
> --- a/tools/lib/traceevent/kbuffer.h
> +++ b/tools/lib/traceevent/kbuffer.h
> @@ -49,6 +49,8 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);
>  void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts);
>  void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts);
>  unsigned long long kbuffer_timestamp(struct kbuffer *kbuf);
> +unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf);
> +unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr);
>  
>  void *kbuffer_translate_data(int swap, void *data, unsigned int *size);
>  
> -- 
> 2.26.2
> 
>
Steven Rostedt July 3, 2020, 4:18 p.m. UTC | #2
On Fri, 3 Jul 2020 08:31:07 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Em Thu, Jul 02, 2020 at 02:53:45PM -0400, Steven Rostedt escreveu:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > 
> > Add the functions kbuffer_subbuf_timestamp() and kbuffer_ptr_delta() to get
> > the timing data stored in the ring buffer that is used to produced the time
> > stamps of the records.
> > 
> > This is useful for tools like trace-cmd to be able to display the content of
> > the read data to understand why the records show the time stamps that they
> > do.
> > 
> > Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-2-tz.stoyanov@gmail.com
> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > [ Ported from trace-cmd.git ]
> > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>  
> 
> Humm, is that intentional, i.e. two signed-off-by you?
> 

Yes.

It was originally written by me at Red Hat (thus the "From: Steven
Rostedt (Red Hat)"), and that signed-off-by is from Red Hat Steven.
Then Tzvetomir ported it over to libtraceveent in the kernel tree,
which requires his signed-off-by, and then I pull Tzvetomir's work and
the VMware Steven Rostedt signed it off. ;-)

As Signed-off-by does have some legal meaning for "right to use this
code" I feel it's more than prudent to include both the Red Hat
Steven's signed-off-by as well as the VMware Steven's signed-off-by.

Make sense?

-- Steve
diff mbox series

Patch

diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index 27f3b07fdae8..583db99aee94 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -546,6 +546,34 @@  int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)
 	return 0;
 }
 
+/**
+ * kbuffer_subbuf_timestamp - read the timestamp from a sub buffer
+ * @kbuf:      The kbuffer to load
+ * @subbuf:    The subbuffer to read from.
+ *
+ * Return the timestamp from a subbuffer.
+ */
+unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf)
+{
+	return kbuf->read_8(subbuf);
+}
+
+/**
+ * kbuffer_ptr_delta - read the delta field from a record
+ * @kbuf:      The kbuffer to load
+ * @ptr:       The record in the buffe.
+ *
+ * Return the timestamp delta from a record
+ */
+unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr)
+{
+	unsigned int type_len_ts;
+
+	type_len_ts = read_4(kbuf, ptr);
+	return ts4host(kbuf, type_len_ts);
+}
+
+
 /**
  * kbuffer_read_event - read the next event in the kbuffer subbuffer
  * @kbuf:	The kbuffer to read from
diff --git a/tools/lib/traceevent/kbuffer.h b/tools/lib/traceevent/kbuffer.h
index ed4d697fc137..5fa8292e341b 100644
--- a/tools/lib/traceevent/kbuffer.h
+++ b/tools/lib/traceevent/kbuffer.h
@@ -49,6 +49,8 @@  int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);
 void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts);
 void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts);
 unsigned long long kbuffer_timestamp(struct kbuffer *kbuf);
+unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf);
+unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr);
 
 void *kbuffer_translate_data(int swap, void *data, unsigned int *size);