From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v25 10/16] trace-cmd: Add time sync protocol flags
Date: Wed, 2 Dec 2020 21:09:34 -0500 [thread overview]
Message-ID: <20201202210934.3852e5c3@oasis.local.home> (raw)
In-Reply-To: <20201029111816.247241-11-tz.stoyanov@gmail.com>
On Thu, 29 Oct 2020 13:18:10 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
> Added 32bit flags for the time synchronization protocols. The first added
> flag is TRACECMD_TSYNC_FLAG_INTERPOLATE, used to specify how the
> timestamps must be corrected.
> - If the flag is set, an interpolation is performed:
> Find the (min, max) interval from the offsets array and calculate
> offset specific to the given timestamp using interpolation in that
> interval.
> - If the flag is not set, do not interpolate:
> Find the (min, max) interval from the offsets array and use the
> min offset for all timespamps within the interval.
"timestamps"
>
> These flags are set by the timestamp synchronization protocols at the
> protocol initialization time.
>
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
> --- a/tracecmd/trace-tsync.c
> +++ b/tracecmd/trace-tsync.c
> @@ -132,7 +132,8 @@ out:
> static void write_guest_time_shift(struct buffer_instance *instance)
> {
> struct tracecmd_output *handle;
> - struct iovec vector[5];
> + struct iovec vector[6];
> + unsigned int flags;
> long long *scalings = NULL;
> long long *offsets = NULL;
> long long *ts = NULL;
> @@ -145,6 +146,9 @@ static void write_guest_time_shift(struct buffer_instance *instance)
> &ts, &offsets, &scalings);
> if (ret < 0 || !count || !ts || !offsets || !scalings)
> return;
> + ret = tracecmd_tsync_get_proto_flags(&instance->tsync, &flags);
> + if (ret < 0)
> + return;
>
> file = instance->output_file;
> fd = open(file, O_RDWR);
> @@ -154,14 +158,16 @@ static void write_guest_time_shift(struct buffer_instance *instance)
> vector[0].iov_len = 8;
> vector[0].iov_base = &top_instance.trace_id;
> vector[1].iov_len = 4;
> - vector[1].iov_base = &count;
> - vector[2].iov_len = 8 * count;
> - vector[2].iov_base = ts;
> + vector[1].iov_base = &flags;
> + vector[2].iov_len = 4;
> + vector[2].iov_base = &count;
> vector[3].iov_len = 8 * count;
> - vector[3].iov_base = offsets;
> + vector[3].iov_base = ts;
> vector[4].iov_len = 8 * count;
> - vector[4].iov_base = scalings;
> - tracecmd_add_option_v(handle, TRACECMD_OPTION_TIME_SHIFT, vector, 5);
> + vector[4].iov_base = offsets;
> + vector[5].iov_len = 8 * count;
> + vector[5].iov_base = scalings;
> + tracecmd_add_option_v(handle, TRACECMD_OPTION_TIME_SHIFT, vector, 6);
> tracecmd_append_options(handle);
> tracecmd_output_close(handle);
> #ifdef TSYNC_DEBUG
To make the above cleaner, I would use an enum to define the vector
indexes:
enum {
VECTOR_TRACE_ID,
VECTOR_FLAGS,
VECTOR_COUNT,
VECTOR_TIMES,
VECTOR_OFFSETS,
VECTOR_SCALINGS,
}
And then you can make it:
vector[VECTOR_TRACE_ID].iov_len = 8;
vector[VECTOR_TRACE_ID].iov_base = &top_instance.trace_id;
vector[VECTOR_FLAGS].iov_len = 4;
vector[VECTOR_FLAGS].iov_base = &flags;
vector[VECTOR_COUNT].iov_len = 4;
vector[VECTOR_COUNT].iov_base = &count;
vector[VECTOR_TIMES].iov_len = 8 * count;
vector[VECTOR_TIMES].iov_base = ts;
vector[VECTOR_OFFSETS].iov_len = 8 * count;
vector[VECTOR_OFFSETS].iov_base = offsets;
vector[VECTOR_SCALINGS].iov_len = 8 * count;
vector[VECTOR_SCALINGS].iov_base = scalings;
It makes it obvious what each vector is used for.
This is just an opinion. You don't need to implement it. I just hate
hard coded numbers ;-)
-- Steve
next prev parent reply other threads:[~2020-12-03 2:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 11:18 [PATCH v25 00/16] Timestamp synchronization of host - guest tracing session Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 01/16] trace-cmd: Replace time sync protocol ID with string Tzvetomir Stoyanov (VMware)
2020-11-05 14:52 ` Steven Rostedt
2020-12-02 22:43 ` Steven Rostedt
2020-10-29 11:18 ` [PATCH v25 02/16] trace-cmd: Add trace-cmd library APIs for ftrace clock name Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 03/16] trace-cmd: Move VM related logic in a separate file Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 04/16] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 05/16] trace-cmd: Add clock parameter to timestamp synchronization plugins Tzvetomir Stoyanov (VMware)
2020-12-02 22:48 ` Steven Rostedt
2020-12-03 13:09 ` Tzvetomir Stoyanov
2020-10-29 11:18 ` [PATCH v25 06/16] trace-cmd: Add role " Tzvetomir Stoyanov (VMware)
2020-12-02 23:04 ` Steven Rostedt
2020-10-29 11:18 ` [PATCH v25 07/16] trace-cmd: Add host / guest role in timestamp synchronization context Tzvetomir Stoyanov (VMware)
2020-12-02 23:07 ` Steven Rostedt
2020-10-29 11:18 ` [PATCH v25 08/16] trace-cmd: Add guest CPU count PID in tracecmd_time_sync struct Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 09/16] trace-cmd: Add scaling ratio for timestamp correction Tzvetomir Stoyanov (VMware)
2020-12-03 1:47 ` Steven Rostedt
2020-12-03 12:56 ` Tzvetomir Stoyanov
2020-10-29 11:18 ` [PATCH v25 10/16] trace-cmd: Add time sync protocol flags Tzvetomir Stoyanov (VMware)
2020-12-03 2:09 ` Steven Rostedt [this message]
2020-12-03 12:59 ` Tzvetomir Stoyanov
2020-10-29 11:18 ` [PATCH v25 11/16] trace-cmd: Add timestamp synchronization per vCPU Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 12/16] trace-cmd: Define a macro for packed structures Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 13/16] trace-cmd: Add dummy function to initialize timestamp sync logic Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 14/16] trace-cmd: [POC] PTP-like algorithm for host - guest timestamp synchronization Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 15/16] trace-cmd: Debug scripts for " Tzvetomir Stoyanov (VMware)
2020-10-29 11:18 ` [PATCH v25 16/16] trace-cmd [POC]: Add KVM timestamp synchronization plugin Tzvetomir Stoyanov (VMware)
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=20201202210934.3852e5c3@oasis.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@gmail.com \
/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).