Re: [PATCH v15 16/18] trace-cmd: Basic infrastructure for host - guest timestamp synchronization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 28, 2019 at 11:02 AM Tzvetomir Stoyanov (VMware)
<tz.stoyanov@xxxxxxxxx> wrote:

[...]

> --- a/Documentation/trace-cmd-record.1.txt
> +++ b/Documentation/trace-cmd-record.1.txt
> @@ -338,6 +338,12 @@ OPTIONS
>      the offset will also be in nanoseconds even if the displayed units are
>      in microseconds.
>
> +*--tsync-interval*::
> +    Set the loop interval, in ms, for timestamps synchronization with guests:
> +        If a negative number is specified, timestamps synchronization is disabled
> +        If 0 is specified, no loop is performed - timestamps offset is calculated only twice,"
> +        at the beginnig and at the end of the trace\n"

Typo in "beginnig".

[...]

> diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c
> index a34297f..8944013 100644
> --- a/lib/trace-cmd/trace-msg.c
> +++ b/lib/trace-cmd/trace-msg.c
> @@ -26,8 +26,12 @@
>  #include "trace-local.h"
>  #include "trace-msg.h"
>
> +typedef __u16 u16;
> +typedef __s16 s16;

s16 and u16 seem to not be used.

[...]

> @@ -264,6 +278,17 @@ static int tracecmd_msg_send(int fd, struct tracecmd_msg *msg)
>         return ret;
>  }
>
> +static int tracecmd_msg_send_nofree(int fd, struct tracecmd_msg *msg)
> +{
> +       int ret = 0;
> +
> +       ret = msg_write(fd, msg);
> +       if (ret < 0)
> +               ret = -ECOMM;
> +
> +       return ret;
> +}

Maybe reuse tracecmd_msg_send_nofree in tracecmd_msg_send above?

[...]

> +int tracecmd_msg_recv_time_sync(struct tracecmd_msg_handle *msg_handle,
> +                               unsigned int *sync_protocol,
> +                               unsigned int *sync_msg_id,
> +                               unsigned int *payload_size, char **payload)
> +{
> +       struct tracecmd_msg msg;
> +       int ret = -1;
> +       int buf_size;
> +
> +       memset(&msg, 0, sizeof(msg));
> +       ret = tracecmd_msg_recv(msg_handle->fd, &msg);
> +       if (ret < 0)
> +               goto out;
> +
> +       if (ntohl(msg.hdr.cmd) != MSG_TIME_SYNC) {
> +               ret = -EOPNOTSUPP;
> +               goto out;
> +       }
> +
> +       if (sync_protocol)
> +               *sync_protocol = ntohl(msg.tsync.sync_protocol);
> +       if (sync_msg_id)
> +               *sync_msg_id = ntohl(msg.tsync.sync_msg_id);
> +
> +       buf_size = msg_buf_len(&msg);
> +       if (buf_size < 0) {
> +               ret = -EINVAL;
> +               goto out;
> +       }
> +
> +       if (buf_size && payload && payload_size) {
> +               if (*payload_size) {
> +                       if (*payload_size != buf_size || *payload == NULL) {
> +                               ret = -ENOMEM;

Returning ENOMEM in this case is confusing. If this case is intended
make it so that we don't allocate on each tracecmd_msg_recv_time_sync,
maybe do realloc() here instead?

-- 
Slavomir Kaslev



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux