linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] trace-cmd: Dump fraction bits from TRACECMD_OPTION_TIME_SHIFT
Date: Tue, 9 Nov 2021 11:07:31 -0500	[thread overview]
Message-ID: <20211109110731.5e728340@gandalf.local.home> (raw)
In-Reply-To: <20211014150204.2485499-5-tz.stoyanov@gmail.com>

On Thu, 14 Oct 2021 18:02:04 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> +		read_file_number(fd, &cpus_data[j].count, 4);
> +		size -= 4;
> +		do_print(OPTIONS, "%lld [samples count for CPU %d]\n", cpus_data[j].count, j);
> +		cpus_data[j].times = calloc(cpus_data[j].count, sizeof(long long));
> +		cpus_data[j].offsets = calloc(cpus_data[j].count, sizeof(long long));
> +		cpus_data[j].scalings = calloc(cpus_data[j].count, sizeof(long long));

> +		cpus_data[j].frac = calloc(cpus_data[j].count, sizeof(long long));

> +		if (!cpus_data[j].times || !cpus_data[j].offsets ||
> +		    !cpus_data[j].scalings || !cpus_data[j].frac)
> +			goto out;
> +		for (i = 0; i < cpus_data[j].count; i++) {
> +			if (size < 8)
> +				goto out;
> +			read_file_number(fd, cpus_data[j].times + i, 8);
> +			size -= 8;
> +		}
> +		for (i = 0; i < cpus_data[j].count; i++) {
> +			if (size < 8)
> +				goto out;
> +			read_file_number(fd, cpus_data[j].offsets + i, 8);
> +			size -= 8;
> +		}
> +		for (i = 0; i < cpus_data[j].count; i++) {
> +			if (size < 8)
> +				goto out;
> +			read_file_number(fd, cpus_data[j].scalings + i, 8);
> +			size -= 8;
> +		}
> +	}
>  
> +	if (size > 0) {
> +		for (j = 0; j < cpus; j++) {
> +			if (!cpus_data[j].frac)
> +				goto out;
> +			for (i = 0; i < cpus_data[j].count; i++) {
> +				if (size < 8)
> +					goto out;
> +				read_file_number(fd, cpus_data[j].frac + i, 8);
> +				size -= 8;
> +			}
> +		}
>  	}
> +
> +	for (j = 0; j < cpus; j++) {
> +		for (i = 0; i < cpus_data[j].count; i++)
> +			do_print(OPTIONS, "\t%lld %lld %llu %llu[offset * scaling >> fraction @ time]\n",
> +				 cpus_data[j].offsets[i], cpus_data[j].scalings[i],
> +				 cpus_data[j].frac[i], cpus_data[j].times[i]);
> +
> +	}
> +
>  out:
> -	free(times);
> -	free(offsets);
> -	free(scalings);
> +	if (j < cpus)
> +		do_print(OPTIONS, "Broken time shift option\n");
> +	for (j = 0; j < cpus; j++) {
> +		free(cpus_data[j].times);
> +		free(cpus_data[j].offsets);
> +		free(cpus_data[j].scalings);

Looks like you forgot to add:

		free(cpus_data[j].frac);

This is the only issue I found in this series. I'll just add a patch to fix
it and move on.

Thanks!

-- Steve


> +	}
> +	free(cpus_data);

      reply	other threads:[~2021-11-09 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 15:02 [PATCH v2 0/4] trace-cmd: Align guest TSC calculation with the kernel Tzvetomir Stoyanov (VMware)
2021-10-14 15:02 ` [PATCH v2 1/4] trace-cmd library: Do not use strncmp() when searching for KVM debug files Tzvetomir Stoyanov (VMware)
2021-10-14 15:02 ` [PATCH v2 2/4] trace-cmd library: Extend host-guest time sync with fraction bits Tzvetomir Stoyanov (VMware)
2021-10-14 15:02 ` [PATCH v2 3/4] trace-cmd library: Read and use fraction bits from TRACECMD_OPTION_TIME_SHIFT Tzvetomir Stoyanov (VMware)
2021-10-14 15:02 ` [PATCH v2 4/4] trace-cmd: Dump " Tzvetomir Stoyanov (VMware)
2021-11-09 16:07   ` Steven Rostedt [this message]

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=20211109110731.5e728340@gandalf.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).