aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2023-12-26 13:13:39 -0500
committerSteven Rostedt (Google) <rostedt@goodmis.org>2023-12-26 23:16:00 -0500
commit6b21b4c995c73f6df3d899de4c43ca3e8b5fee34 (patch)
tree651e7cbde13da86d4133786325677090760897ab
parent8cf5315f7f22fccc6083fcef1f9ec01d52106371 (diff)
downloadlibtraceevent-6b21b4c995c73f6df3d899de4c43ca3e8b5fee34.tar.gz
libtraceevent: Add tep_get_sub_buffer_data_size()
Add an API to be able to read the header page file and return the data size of the sub buffers. This is the total size of the sub buffer minus the meta data. Link: https://lore.kernel.org/linux-trace-devel/20231226131339.7b0b727c@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--Documentation/libtraceevent-page_size.txt6
-rw-r--r--Documentation/libtraceevent.txt1
-rw-r--r--include/traceevent/event-parse.h1
-rw-r--r--src/event-parse-api.c14
4 files changed, 21 insertions, 1 deletions
diff --git a/Documentation/libtraceevent-page_size.txt b/Documentation/libtraceevent-page_size.txt
index 0264e52..18fa5ae 100644
--- a/Documentation/libtraceevent-page_size.txt
+++ b/Documentation/libtraceevent-page_size.txt
@@ -3,7 +3,7 @@ libtraceevent(3)
NAME
----
-tep_get_page_size, tep_set_page_size, tep_get_sub_buffer_size - Get / set the size of a memory page on
+tep_get_page_size, tep_set_page_size, tep_get_sub_buffer_data_size, tep_get_sub_buffer_size - Get / set the size of a memory page on
the machine, where the trace is generated
SYNOPSIS
@@ -15,6 +15,7 @@ SYNOPSIS
int *tep_get_page_size*(struct tep_handle pass:[*]_tep_);
void *tep_set_page_size*(struct tep_handle pass:[*]_tep_, int _page_size_);
int *tep_get_sub_buffer_size*(struct tep_handle pass:[*]_tep_);
+int *tep_get_sub_buffer_data_size*(struct tep_handle pass:[*]_tep_);
int *tep_get_sub_buffer_commit_offset*(struct tep_handle pass:[*]_tep_);
--
@@ -33,6 +34,9 @@ The *tep_get_sub_buffer_size()* returns the size of each "sub buffer" of the
ring buffer. The Linux kernel ring buffer is broken up into sections called
sub buffers. This returns the size of those buffers.
+The *tep_get_sub_buffer_data_size()* returns the size of just the data portion
+of the sub buffers.
+
The *tep_get_sub_buffer_commit_offset()* returns the offset on the sub buffer
that holds the committed portion of data. This number contains the index from
the data portion of the sub buffer that is the end of the last element on the
diff --git a/Documentation/libtraceevent.txt b/Documentation/libtraceevent.txt
index d1aef40..26e3ad2 100644
--- a/Documentation/libtraceevent.txt
+++ b/Documentation/libtraceevent.txt
@@ -27,6 +27,7 @@ Management of tep handler data structure and access of its members:
int *tep_get_page_size*(struct tep_handle pass:[*]_tep_);
void *tep_set_page_size*(struct tep_handle pass:[*]_tep_, int _page_size_);
int *tep_get_sub_buffer_size*(struct tep_handle pass:[*]_tep_);
+ int *tep_get_sub_buffer_data_size*(struct tep_handle pass:[*]_tep_);
int *tep_get_sub_buffer_commit_offset*(struct tep_handle pass:[*]_tep_);
int *tep_get_header_page_size*(struct tep_handle pass:[*]_tep_);
int *tep_get_header_timestamp_size*(struct tep_handle pass:[*]_tep_);
diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index adfb770..c03f459 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -588,6 +588,7 @@ int tep_get_long_size(struct tep_handle *tep);
void tep_set_long_size(struct tep_handle *tep, int long_size);
int tep_get_page_size(struct tep_handle *tep);
int tep_get_sub_buffer_size(struct tep_handle *tep);
+int tep_get_sub_buffer_data_size(struct tep_handle *tep);
int tep_get_sub_buffer_commit_offset(struct tep_handle *tep);
void tep_set_page_size(struct tep_handle *tep, int _page_size);
bool tep_is_file_bigendian(struct tep_handle *tep);
diff --git a/src/event-parse-api.c b/src/event-parse-api.c
index 1a94573..fd03daf 100644
--- a/src/event-parse-api.c
+++ b/src/event-parse-api.c
@@ -263,6 +263,20 @@ void tep_set_page_size(struct tep_handle *tep, int _page_size)
}
/**
+ * tep_get_sub_buffer_data_size - get the size of the data portion
+ * @tep: The handle to the tep to get the data size from
+ *
+ * Returns the size of the data portion of the sub buffer
+ */
+int tep_get_sub_buffer_data_size(struct tep_handle *tep)
+{
+ if (!tep)
+ return -1;
+
+ return tep->header_page_data_size;
+}
+
+/**
* tep_get_sub_buffer_size - get the size of a trace buffer page
* @tep: a handle to the tep_handle
*