diff mbox series

[v4,4/7] kernel-shark-qt: Make kshark_read_at() non-static.

Message ID 20180919143657.19472-5-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series Add infrastructure for plugins. | expand

Commit Message

Yordan Karadzhov Sept. 19, 2018, 2:36 p.m. UTC
kshark_read_at() function provides a thread-safe read of a record from
a specific offset inside the trace.dat file. So far this function was
used only in libkshark.c and was defined static. This patch makes the
function non-static in order to make possible to use it from a plugin.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark-qt/src/libkshark.c | 12 ++++++++++--
 kernel-shark-qt/src/libkshark.h |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Steven Rostedt Sept. 20, 2018, 3:29 a.m. UTC | #1
On Wed, 19 Sep 2018 17:36:54 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:


> +/**
> + * @brief A thread-safe read of a record from a specific offset.
> + *
> + * @param kshark_ctx: Input location for the session context pointer.
> + * @param offset: the offset into the file to find the record.
> + *
> + * @returns The returned pevent_record must be freed.
> + */
> +struct tep_record *kshark_read_at(struct kshark_context *kshark_ctx,
> +				  uint64_t offset)
>  {
>  	/*
>  	 * It turns that tracecmd_read_at() is not thread-safe.

This code still has:

	/*
	 * It turns that tracecmd_read_at() is not thread-safe.
	 * TODO: Understand why and see if this can be fixed.
	 * For the time being use a mutex to protect the access.
	 */

Remind me to explain to you why this is the case. It wont be easy to
have it fixed.

-- Steve
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c
index 6fb08b2..fcf61bf 100644
--- a/kernel-shark-qt/src/libkshark.c
+++ b/kernel-shark-qt/src/libkshark.c
@@ -830,8 +830,16 @@  ssize_t kshark_load_data_records(struct kshark_context *kshark_ctx,
 	return -ENOMEM;
 }
 
-static struct tep_record *kshark_read_at(struct kshark_context *kshark_ctx,
-					 uint64_t offset)
+/**
+ * @brief A thread-safe read of a record from a specific offset.
+ *
+ * @param kshark_ctx: Input location for the session context pointer.
+ * @param offset: the offset into the file to find the record.
+ *
+ * @returns The returned pevent_record must be freed.
+ */
+struct tep_record *kshark_read_at(struct kshark_context *kshark_ctx,
+				  uint64_t offset)
 {
 	/*
 	 * It turns that tracecmd_read_at() is not thread-safe.
diff --git a/kernel-shark-qt/src/libkshark.h b/kernel-shark-qt/src/libkshark.h
index 203c812..ba5ea6c 100644
--- a/kernel-shark-qt/src/libkshark.h
+++ b/kernel-shark-qt/src/libkshark.h
@@ -150,6 +150,9 @@  void kshark_free(struct kshark_context *kshark_ctx);
 
 char* kshark_dump_entry(const struct kshark_entry *entry);
 
+struct tep_record *kshark_read_at(struct kshark_context *kshark_ctx,
+				  uint64_t offset);
+
 /** Bit masks used to control the visibility of the entry after filtering. */
 enum kshark_filter_masks {
 	/**