All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] trace-cmd: Apply time stamp corrections by default
@ 2021-03-04 13:11 Tzvetomir Stoyanov (VMware)
  2021-03-04 13:11 ` [PATCH 1/2] trace-cmd: Enable TS correction " Tzvetomir Stoyanov (VMware)
  2021-03-04 13:11 ` [PATCH 2/2] trace-cmd: Remove APIs for pairing a tracing peer Tzvetomir Stoyanov (VMware)
  0 siblings, 2 replies; 3+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-04 13:11 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Apply all time stamp corrections from trace file meta data by default.
Removed APIs for pair and unpair tracing peers, as that logic is not
relevant any more.

Tzvetomir Stoyanov (VMware) (2):
  trace-cmd: Enable TS correction by default
  trace-cmd: Remove APIs for pairing a tracing peer.

 .../libtracecmd/libtracecmd-peer.3.txt        |  32 +-----
 Documentation/libtracecmd/libtracecmd.3.txt   |   2 -
 include/trace-cmd/trace-cmd.h                 |   3 -
 .../include/private/trace-cmd-private.h       |   1 -
 lib/trace-cmd/trace-input.c                   | 102 +-----------------
 5 files changed, 5 insertions(+), 135 deletions(-)

-- 
2.29.2


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

* [PATCH 1/2] trace-cmd: Enable TS correction by default
  2021-03-04 13:11 [PATCH 0/2] trace-cmd: Apply time stamp corrections by default Tzvetomir Stoyanov (VMware)
@ 2021-03-04 13:11 ` Tzvetomir Stoyanov (VMware)
  2021-03-04 13:11 ` [PATCH 2/2] trace-cmd: Remove APIs for pairing a tracing peer Tzvetomir Stoyanov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-04 13:11 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

When opening a trace.dat file with trace-cmd library, apply time stamps
corrections from the file's metadata by default. This default behaviour
can be disabled with flag TRACECMD_FL_IGNORE_DATE using tracecmd_set_flag()
API, before reading the tracing data. There is also a "trace-cmd report"
option for ignoring any timestamp corrections: "--nodate".

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 9ef7b9f1..134f6220 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1167,6 +1167,9 @@ static unsigned long long timestamp_correct(unsigned long long ts,
 	struct host_trace_info	*host = &handle->host;
 	int min, mid, max;
 
+	if (handle->flags & TRACECMD_FL_IGNORE_DATE)
+		return ts;
+
 	if (handle->ts_offset)
 		return ts + handle->ts_offset;
 
@@ -2585,6 +2588,7 @@ static int handle_options(struct tracecmd_input *handle)
 			if (!handle->host.ts_samples)
 				return -ENOMEM;
 			tsync_offset_load(handle, buf + 16);
+			tracecmd_enable_tsync(handle, true);
 			break;
 		case TRACECMD_OPTION_CPUSTAT:
 			buf[size-1] = '\n';
-- 
2.29.2


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

* [PATCH 2/2] trace-cmd: Remove APIs for pairing a tracing peer.
  2021-03-04 13:11 [PATCH 0/2] trace-cmd: Apply time stamp corrections by default Tzvetomir Stoyanov (VMware)
  2021-03-04 13:11 ` [PATCH 1/2] trace-cmd: Enable TS correction " Tzvetomir Stoyanov (VMware)
@ 2021-03-04 13:11 ` Tzvetomir Stoyanov (VMware)
  1 sibling, 0 replies; 3+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-04 13:11 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

In host-guests tracing context, tracing peers are all machines which are
being traced at the same time, as part of a single tracing session. The
logic for matching and pairing tracing peers from the same session, when
opening trace files, is used to take decision whether to apply time
stamps correction on the tracing events, in order to be in the same time
space. As there is a change in that behaviour - now these corrections
are applied by default, there is no need for pairing logic. These APIs
are removed:
 tracecmd_pair_peer()
 tracecmd_unpair_peer()
Note that the peer information is still saved in the file metadata.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 .../libtracecmd/libtracecmd-peer.3.txt        | 32 +-----
 Documentation/libtracecmd/libtracecmd.3.txt   |  2 -
 include/trace-cmd/trace-cmd.h                 |  3 -
 .../include/private/trace-cmd-private.h       |  1 -
 lib/trace-cmd/trace-input.c                   | 98 -------------------
 5 files changed, 1 insertion(+), 135 deletions(-)

diff --git a/Documentation/libtracecmd/libtracecmd-peer.3.txt b/Documentation/libtracecmd/libtracecmd-peer.3.txt
index 6cf34f9b..2e3232c6 100644
--- a/Documentation/libtracecmd/libtracecmd-peer.3.txt
+++ b/Documentation/libtracecmd/libtracecmd-peer.3.txt
@@ -3,8 +3,7 @@ libtracecmd(3)
 
 NAME
 ----
-tracecmd_pair_peer, tracecmd_unpair_peer, tracecmd_get_traceid,
-tracecmd_get_guest_cpumap - Manage trace session with multiple trace peers,
+tracecmd_get_traceid, tracecmd_get_guest_cpumap - Manage trace session with multiple trace peers,
 recorded in multiple trace files.
 
 SYNOPSIS
@@ -13,8 +12,6 @@ SYNOPSIS
 --
 *#include <trace-cmd.h>*
 
-int *tracecmd_pair_peer*(struct tracecmd_input pass:[*]_handle_, struct tracecmd_input pass:[*]_peer_);
-void *tracecmd_unpair_peer*(struct tracecmd_input pass:[*]_handle_);
 unsigned long long *tracecmd_get_traceid*(struct tracecmd_input pass:[*]_handle_);
 int *tracecmd_get_guest_cpumap*(struct tracecmd_input pass:[*]_handle_, unsigned long long _trace_id_, const char pass:[*]pass:[*]_name_, int pass:[*]_vcpu_count_, const int pass:[*]pass:[*]_cpu_pid_);
 --
@@ -28,15 +25,6 @@ Information about peers from the session is stored in the metadata of each
 trace file. These APIs use that information to extract and synchronize
 the trace data.
 
-The _tracecmd_pair_peer()_ function pairs two tracecmd_input handlers,
-associated with two trace files from the same trace session. This API must
-be called before _tracecmd_init_data()(3)_, as the initialisation of
-the trace data depends on that. If there is a tracing peer, the event
-timestamps are recalculated in order to be in the same time space.
-
-The _tracecmd_unpair_peer()_ function unpairs a peer from _handle_
-previously paired with _tracecmd_pair_peer()_.
-
 The _tracecmd_get_traceid()_ function returns the trace ID stored in
 the trace file metadata associated with _handle_. Each peer from a trace
 session has an ID unique for that peer and that trace session only.
@@ -59,9 +47,6 @@ The _name_, _vcpu_count_ and _cpu_pid_ values must *not* be freed.
 
 RETURN VALUE
 ------------
-The _tracecmd_pair_peer()_ function returns 1, if a peer is already
-paired, -1 in case of an error or 0 if it successfully paired the peers.
-
 The _tracecmd_get_traceid()_ function returns a 64 bit trace ID.
 
 The _tracecmd_get_guest_cpumap()_ function returns -1 in case of
@@ -90,7 +75,6 @@ struct tracecmd_input *guest2 = tracecmd_open_head("trace-Guest2.dat");
 
 unsigned long long guest_id_1 = tracecmd_get_traceid(guest1);
 unsigned long long guest_id_2 = tracecmd_get_traceid(guest2);
-bool g1 = false, g2 = false;
 int *cpu_pid_1, *cpu_pid_2;
 int vcount_1, vcount_2;
 char *name_1, *name_2;
@@ -99,27 +83,13 @@ char *name_1, *name_2;
 		/* The Host and a guest1 with name_1 are part of the same trace session.
 		 * Got guest1 VCPU to host PID mapping.
 		 */
-		if (!tracecmd_pair_peer(guest1, host)) {
-			/* Successfully paired guest1 to the host handler */
-			tracecmd_init_data(guest1);
-			g1 = true;
-		}
 	}
 	if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name_2, &vcount_2, &cpu_pid_2)) {
 		/* The Host and a guest2 with name_2 are part of the same trace session.
 		 * Got guest2 VCPU to host PID mapping.
 		 */
-		if (!tracecmd_pair_peer(guest2, host)) {
-			/* Successfully paired guest2 to the host handler */
-			tracecmd_init_data(guest2);
-			g2 = true;
-		}
 	}
 ...
-	if (g1)
-		tracecmd_unpair_peer(guest1);
-	if (g2)
-		tracecmd_unpair_peer(guest2);
 	tracecmd_close(guest1);
 	tracecmd_close(guest2);
 	tracecmd_close(handle);
diff --git a/Documentation/libtracecmd/libtracecmd.3.txt b/Documentation/libtracecmd/libtracecmd.3.txt
index 7431c2ce..adc9321c 100644
--- a/Documentation/libtracecmd/libtracecmd.3.txt
+++ b/Documentation/libtracecmd/libtracecmd.3.txt
@@ -31,8 +31,6 @@ Read tracing instances from a trace file:
 	struct tracecmd_input pass:[*]*tracecmd_buffer_instance_handle*(struct tracecmd_input pass:[*]_handle_, int _indx_);
 
 Get traceing peer information from a trace file:
-	int *tracecmd_pair_peer*(struct tracecmd_input pass:[*]_handle_, struct tracecmd_input pass:[*]_peer_);
-	void tracecmd_unpair_peer(struct tracecmd_input pass:[*]handle);
 	unsigned long long *tracecmd_get_traceid*(struct tracecmd_input pass:[*]_handle_);
 	int *tracecmd_get_guest_cpumap*(struct tracecmd_input pass:[*]_handle_, unsigned long long _trace_id_, const char pass:[*]pass:[*]_name_, int pass:[*]_vcpu_count_, const int pass:[*]pass:[*]_cpu_pid_);
 --
diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index 65ae730f..162cd318 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -20,9 +20,6 @@ struct tracecmd_input *tracecmd_open(const char *file, int flags);
 struct tracecmd_input *tracecmd_open_fd(int fd, int flags);
 
 void tracecmd_close(struct tracecmd_input *handle);
-int tracecmd_pair_peer(struct tracecmd_input *handle,
-		       struct tracecmd_input *peer);
-void tracecmd_unpair_peer(struct tracecmd_input *handle);
 
 int tracecmd_init_data(struct tracecmd_input *handle);
 struct tep_record *
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index fc968cc9..7d7cb487 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -163,7 +163,6 @@ void tracecmd_set_flag(struct tracecmd_input *handle, int flag);
 void tracecmd_clear_flag(struct tracecmd_input *handle, int flag);
 unsigned long tracecmd_get_flags(struct tracecmd_input *handle);
 unsigned long tracecmd_get_file_state(struct tracecmd_input *handle);
-unsigned long long tracecmd_get_tsync_peer(struct tracecmd_input *handle);
 int tracecmd_enable_tsync(struct tracecmd_input *handle, bool enable);
 
 void tracecmd_parse_trace_clock(struct tracecmd_input *handle, char *file, int size);
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 134f6220..97c0b59d 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -95,7 +95,6 @@ struct host_trace_info {
 	unsigned long long	peer_trace_id;
 	unsigned int		flags;
 	bool			sync_enable;
-	struct tracecmd_input	*peer_data;
 	int			ts_samples_count;
 	struct ts_offset_sample	*ts_samples;
 };
@@ -2226,38 +2225,10 @@ static void tsync_offset_load(struct tracecmd_input *handle, char *buf)
 	host->ts_samples_count = j;
 }
 
-static void tsync_check_enable(struct tracecmd_input *handle)
-{
-	struct host_trace_info	*host = &handle->host;
-	struct guest_trace_info *guest;
-
-	host->sync_enable = false;
-
-	if (!host->peer_data || !host->peer_data->guest ||
-	    !host->ts_samples_count || !host->ts_samples)
-		return;
-	if (host->peer_trace_id != host->peer_data->trace_id)
-		return;
-	guest = host->peer_data->guest;
-	while (guest) {
-		if (guest->trace_id == handle->trace_id)
-			break;
-		guest = guest->next;
-	}
-	if (!guest)
-		return;
-
-	host->sync_enable = true;
-}
-
 static void trace_tsync_offset_free(struct host_trace_info *host)
 {
 	free(host->ts_samples);
 	host->ts_samples = NULL;
-	if (host->peer_data) {
-		tracecmd_close(host->peer_data);
-		host->peer_data = NULL;
-	}
 }
 
 static int trace_pid_map_cmp(const void *a, const void *b)
@@ -2266,7 +2237,6 @@ static int trace_pid_map_cmp(const void *a, const void *b)
 	struct tracecmd_proc_addr_map *m_b = (struct tracecmd_proc_addr_map *)b;
 
 	if (m_a->start > m_b->start)
-		return 1;
 	if (m_a->start < m_b->start)
 		return -1;
 	return 0;
@@ -3278,61 +3248,6 @@ fail:
 	return NULL;
 }
 
-/**
- * tracecmd_unpair_peer - Remove the linked tracing peer of this handle
- * @handle: input handle for the trace.dat file
- *
- * When tracing host and one or more guest machines at the same time,
- * guest and host are tracing peers. There is information in both trace
- * files, related to host PID to guest vCPU mapping, timestamp synchronization
- * and other. This information is useful when opening files at the same time and
- * merging the events. When the host is set as a tracing peer to the guest, then
- * the timestamps of guest's events are recalculated to match the host event's time
- *
- * This removes any peer that is linked to the  @handle.
- */
-void tracecmd_unpair_peer(struct tracecmd_input *handle)
-{
-	if (!handle)
-		return;
-
-	if (handle->host.peer_data) {
-		tracecmd_close(handle->host.peer_data);
-		handle->host.peer_data = NULL;
-		tsync_check_enable(handle);
-	}
-}
-
-/**
- * tracecmd_pair_peer - Link a tracing peer to this handle
- * @handle: input handle for the trace.dat file
- * @peer: input handle for the tracing peer
- *
- * When tracing host and one or more guest machines at the same time,
- * guest and host are tracing peers. There is information in both trace
- * files, related to host PID to guest vCPU mapping, timestamp synchronization
- * and other. This information is useful when opening files at the same time and
- * merging the events. When the host is set as a tracing peer to the guest, then
- * the timestamps of guest's events are recalculated to match the host event's time
- *
- * Returns 1, if a peer is already paired, -1 in case of an error or 0 otherwise
- */
-int tracecmd_pair_peer(struct tracecmd_input *handle,
-		       struct tracecmd_input *peer)
-{
-	if (!handle)
-		return -1;
-
-	if (handle->host.peer_data)
-		return 1;
-
-	handle->host.peer_data = peer;
-	tracecmd_ref(peer);
-	tsync_check_enable(handle);
-
-	return 0;
-}
-
 /**
  * tracecmd_ref - add a reference to the handle
  * @handle: input handle for the trace.dat file
@@ -3910,19 +3825,6 @@ int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
 	return 0;
 }
 
-/**
- * tracecmd_get_tsync_peer - get the trace session id of the peer host
- * @handle: input handle for the trace.dat file
- *
- * Returns the trace id of the peer host, written in the trace file
- *
- * This information is stored in guest trace.dat file
- */
-unsigned long long tracecmd_get_tsync_peer(struct tracecmd_input *handle)
-{
-	return handle->host.peer_trace_id;
-}
-
 /**
  * tracecmd_enable_tsync - enable / disable the timestamps correction
  * @handle: input handle for the trace.dat file
-- 
2.29.2


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

end of thread, other threads:[~2021-03-04 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 13:11 [PATCH 0/2] trace-cmd: Apply time stamp corrections by default Tzvetomir Stoyanov (VMware)
2021-03-04 13:11 ` [PATCH 1/2] trace-cmd: Enable TS correction " Tzvetomir Stoyanov (VMware)
2021-03-04 13:11 ` [PATCH 2/2] trace-cmd: Remove APIs for pairing a tracing peer Tzvetomir Stoyanov (VMware)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.