linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v8 12/44] kernel-shark: Introduce Data streams
Date: Mon,  4 Jan 2021 19:46:52 +0200	[thread overview]
Message-ID: <20210104174724.70404-13-y.karadz@gmail.com> (raw)
In-Reply-To: <20210104174724.70404-1-y.karadz@gmail.com>

With the help of Data stream, KernelShark will be able to load and
merge multiple trace files (streams). Each stream can have different
plugins or filters, registered for it, which means that the raw trace
data of the streams can have different formats, and will allow for a
great degree of customization of the provided data visualization. In
this patch we only provide the basic definitions. The actual integration
of the Data streams into the C API of KernelShark will happen in the
following patches.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/libkshark.h | 199 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 199 insertions(+)

diff --git a/src/libkshark.h b/src/libkshark.h
index e34a32f..f2e29ac 100644
--- a/src/libkshark.h
+++ b/src/libkshark.h
@@ -121,6 +121,205 @@ void kshark_hash_id_free(struct kshark_hash_id *hash);
 
 int *kshark_hash_ids(struct kshark_hash_id *hash);
 
+struct kshark_data_stream;
+
+/** A function type to be used by the method interface of the data stream. */
+typedef char *(*stream_get_str_func) (struct kshark_data_stream *,
+				      const struct kshark_entry *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef const int (*stream_get_int_func) (struct kshark_data_stream *,
+					  const struct kshark_entry *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef int (*stream_find_id_func) (struct kshark_data_stream *,
+				    const char *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef int *(*stream_get_ids_func) (struct kshark_data_stream *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef int (*stream_get_names_func) (struct kshark_data_stream *,
+				      const struct kshark_entry *,
+				      char ***);
+
+/** Event field format identifier. */
+typedef enum kshark_event_field_format {
+	/** A field of unknown type. */
+	KS_INVALID_FIELD,
+
+	/** Integer number */
+	KS_INTEGER_FIELD,
+
+	/** Floating-point number */
+	KS_FLOAT_FIELD
+} kshark_event_field_format;
+
+/** A function type to be used by the method interface of the data stream. */
+typedef kshark_event_field_format
+(*stream_event_field_type) (struct kshark_data_stream *,
+			    const struct kshark_entry *,
+			    const char *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef const int (*stream_read_event_field) (struct kshark_data_stream *,
+					      const struct kshark_entry *,
+					      const char *,
+					      int64_t *);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef const int (*stream_read_record_field) (struct kshark_data_stream *,
+					       void *,
+					       const char *,
+					       int64_t *);
+
+struct kshark_context;
+
+/** A function type to be used by the method interface of the data stream. */
+typedef ssize_t (*load_entries_func) (struct kshark_data_stream *,
+				      struct kshark_context *,
+				      struct kshark_entry ***);
+
+/** A function type to be used by the method interface of the data stream. */
+typedef ssize_t (*load_matrix_func) (struct kshark_data_stream *,
+				     struct kshark_context *,
+				     int16_t **event_array,
+				     int16_t **cpu_array,
+				     int32_t **pid_array,
+				     int64_t **offset_array,
+				     int64_t **ts_array);
+
+/** Data interface identifier. */
+typedef enum kshark_data_interface_id {
+	/** An interface with unknown type. */
+	KS_INVALID_INTERFACE,
+
+	/** Generic interface suitable for Ftrace data. */
+	KS_GENERIC_DATA_INTERFACE,
+} kshark_data_interface_id;
+
+/**
+ * Structure representing the interface of methods used to operate over
+ * the data from a given stream.
+ */
+struct kshark_generic_stream_interface {
+	/** Interface version identifier. */
+	kshark_data_interface_id	type; /* MUST BE FIRST ENTRY. */
+
+	/** Method used to retrieve the Process Id of the entry. */
+	stream_get_int_func	get_pid;
+
+	/** Method used to retrieve the Event Id of the entry. */
+	stream_get_int_func	get_event_id;
+
+	/** Method used to retrieve the Event name of the entry. */
+	stream_get_str_func	get_event_name;
+
+	/** Method used to retrieve the Task name of the entry. */
+	stream_get_str_func	get_task;
+
+	/** Method used to retrieve the Info string of the entry. */
+	stream_get_str_func	get_info;
+
+	/**
+	 * Method used to retrieve an unspecified auxiliary info of the trace
+	 * record.
+	 */
+	stream_get_str_func	aux_info;
+
+	/** Method used to retrieve Id of the Event from its name. */
+	stream_find_id_func	find_event_id;
+
+	/** Method used to retrieve the array of Ids of all Events. */
+	stream_get_ids_func	get_all_event_ids;
+
+	/** Method used to dump the entry's content to string. */
+	stream_get_str_func	dump_entry;
+
+	/**
+	 * Method used to retrieve the array of all field names of a given
+	 * event.
+	 */
+	stream_get_names_func	get_all_event_field_names;
+
+	/** Method used to access the type of an event's data field. */
+	stream_event_field_type		get_event_field_type;
+
+	/** Method used to access the value of an event's data field. */
+	stream_read_event_field		read_event_field_int64;
+
+	/** Method used to access the value of an event's data field. */
+	stream_read_record_field	read_record_field_int64;
+
+	/** Method used to load the data in the form of entries. */
+	load_entries_func	load_entries;
+
+	/** Method used to load the data in matrix form. */
+	load_matrix_func	load_matrix;
+
+	/** Generic data handle. */
+	void			*handle;
+};
+
+/** The limit in size of the data format identifier string. */
+#define KS_DATA_FORMAT_SIZE	15
+
+/** Structure representing a stream of trace data. */
+struct kshark_data_stream {
+	/** Data stream identifier. */
+	uint16_t		stream_id;
+
+	/** The number of CPUs presented in this data stream. */
+	int			n_cpus;
+
+	/**
+	 * The number of distinct event types presented in this data stream.
+	 */
+	int			n_events;
+
+	/** The Process Id of the Idle task. */
+	int			idle_pid;
+
+	/** Trace data file pathname. */
+	char			*file;
+
+	/** Stream name. */
+	char			*name;
+
+	/** Hash table of task PIDs. */
+	struct kshark_hash_id	*tasks;
+
+	/** A mutex, used to protect the access to the input file. */
+	pthread_mutex_t		input_mutex;
+
+	/** Hash of tasks to filter on. */
+	struct kshark_hash_id	*show_task_filter;
+
+	/** Hash of tasks to not display. */
+	struct kshark_hash_id	*hide_task_filter;
+
+	/** Hash of events to filter on. */
+	struct kshark_hash_id	*show_event_filter;
+
+	/** Hash of events to not display. */
+	struct kshark_hash_id	*hide_event_filter;
+
+	/** Hash of CPUs to filter on. */
+	struct kshark_hash_id	*show_cpu_filter;
+
+	/** Hash of CPUs to not display. */
+	struct kshark_hash_id	*hide_cpu_filter;
+
+	/** The type of the data. */
+	char			data_format[KS_DATA_FORMAT_SIZE];
+
+	/**
+	 * The interface of methods used to operate over the data from a given
+	 * stream.
+	 */
+	void				*interface;
+};
+
 /** Size of the task's hash table. */
 #define KS_TASK_HASH_SHIFT 16
 #define KS_TASK_HASH_SIZE (1 << KS_TASK_HASH_SHIFT)
-- 
2.25.1


  parent reply	other threads:[~2021-01-04 17:49 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04 17:46 [PATCH v8 00/44] Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 01/44] kernel-shark: Adopt trace-cmd API changes Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 02/44] kernel-shark: Use libtraceevent and libtracefs Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 03/44] kernel-shark: Add license information Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 04/44] kernel-shark: Change the CMake minimum version required Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 05/44] kernel-shark: Change default libraries install location Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 06/44] kernel-shark: Split the installation in two components Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 07/44] kernel-shark: Update README Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 08/44] kernel-shark: Define build target for JSONC Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 09/44] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 10/44] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 11/44] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2021-01-04 17:46 ` Yordan Karadzhov (VMware) [this message]
2021-01-04 17:46 ` [PATCH v8 13/44] kernel-shark: Rename static methods in libkshark Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 14/44] kernel-shark: Add basic methods for Data streams Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 15/44] kernel-shark: Housekeeping before implementing stream interface Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 16/44] kernel-shark: Add stream interface for trace-cmd data Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 17/44] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 18/44] kernel-shark: Start using data streams Yordan Karadzhov (VMware)
2021-01-04 17:46 ` [PATCH v8 19/44] kernel-shark: Remove dead code Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 20/44] kernel-shark: Redesign the plugin interface Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 21/44] kernel-shark: Complete the stream integration Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 22/44] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 23/44] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 24/44] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 25/44] kernel-shark: Add ksmodel_get_bin() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 26/44] kernel-shark: Protect ksmodel_set_in_range_bining() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 27/44] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 28/44] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 29/44] kernel-shark: Add support for drawing text Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 30/44] kernel-shark: Make GLUT optional dependency Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 31/44] kernel-shark: Add ksplot_draw_polyline() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 32/44] kernel-shark: Optimize ksplot_draw_polygon() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 33/44] kernel-shark: Add basic infrastructure for testing Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 34/44] kernel-shark: Add "github Actions" workflow Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 35/44] kernel-shark: Integrate streams with KsPlotTools Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 36/44] kernel-shark: Add getStreamColorTable() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 37/44] kernel-shark: Redefine the args of KsPlot::getColor() Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 38/44] kernel-shark: Add TextBox class to KsPlot namespace Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 39/44] kernel-shark: Consistent method naming in KsPlotTools Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 40/44] kernel-shark: Make the label part of the graph Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 41/44] kernel-shark: Remove the hard-coded Idle PID Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 42/44] kernel-shark: Add class Polyline to KsPlot namespace Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 43/44] kernel-shark: Add VirtBridge and VirtGap classes Yordan Karadzhov (VMware)
2021-01-04 17:47 ` [PATCH v8 44/44] kernel-shark: Add double click interface to PlotObject Yordan Karadzhov (VMware)
2021-01-05  0:27 ` [PATCH v8 00/44] Start KernelShark v2 transformation Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210104174724.70404-13-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).