linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Open multiple trace files and, if possible, pair them
@ 2021-03-05  6:28 Stefano De Venuto
  2021-03-05  9:18 ` raistlin.df
  2021-03-05 13:50 ` Tzvetomir Stoyanov
  0 siblings, 2 replies; 8+ messages in thread
From: Stefano De Venuto @ 2021-03-05  6:28 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, Stefano De Venuto

The goal of this patch is to teach to trace-cmd how to open multiple
files and, if they are generated by an host and some guests, pair and
synchronize them.

We do that by checking, for every input file, whether or not
it has a corresponding peer, and if that's the case pairs them.

We know that the code must be changed following the new API, but we
would like to have an opinion on the work done so far.

Signed-off-by: Stefano De Venuto <stefano.devenuto99@gmail.com>
---
 tracecmd/trace-read.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index ce07b6b..734c2e7 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -1191,6 +1191,39 @@ enum output_type {
 	OUTPUT_VERSION_ONLY,
 };
 
+static void pair_host_guest(struct list_head *handle_list,
+				struct tracecmd_input *peer_handle)
+{
+	unsigned long long current_trace_id;
+	unsigned long long peer_trace_id;
+	struct handle_list *handles;
+
+	peer_trace_id = tracecmd_get_traceid(peer_handle);
+
+	list_for_each_entry(handles, handle_list, list) {
+
+		current_trace_id = tracecmd_get_traceid(handles->handle);
+
+		/* If the current handle represents a Host */
+		if (tracecmd_get_guest_cpumap(handles->handle, peer_trace_id,
+						NULL, NULL, NULL) != -1) {
+
+			current_trace_id = tracecmd_get_traceid(handles->handle);
+			if (tracecmd_get_tsync_peer(peer_handle) == current_trace_id)
+				tracecmd_pair_peer(peer_handle, handles->handle);
+
+		/* If the current handle represents a Guest */
+		} else if (tracecmd_get_tsync_peer(handles->handle) == peer_trace_id) {
+
+			current_trace_id = tracecmd_get_traceid(handles->handle);
+			if (tracecmd_get_guest_cpumap(peer_handle, current_trace_id,
+							NULL, NULL, NULL) != -1)
+				tracecmd_pair_peer(handles->handle, peer_handle);
+
+		}
+	}
+}
+
 static void read_data_info(struct list_head *handle_list, enum output_type otype,
 			   int global)
 {
@@ -1837,6 +1870,8 @@ void trace_report (int argc, char **argv)
 				return;
 		}
 
+		pair_host_guest(&handle_list, handle);
+
 		if (show_funcs) {
 			tep_print_funcs(pevent);
 			return;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-11 18:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-05  6:28 [RFC] Open multiple trace files and, if possible, pair them Stefano De Venuto
2021-03-05  9:18 ` raistlin.df
2021-03-05 14:47   ` Steven Rostedt
2021-03-05 13:50 ` Tzvetomir Stoyanov
2021-03-11 17:37   ` Dario Faggioli
2021-03-11 17:50     ` Steven Rostedt
2021-03-11 17:53       ` Steven Rostedt
2021-03-11 18:32       ` Dario Faggioli

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).