On Thu, Dec 3, 2020 at 3:47 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > > On Thu, 29 Oct 2020 13:18:09 +0200 > "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > > @@ -2181,7 +2184,9 @@ static void tsync_offset_load(struct tracecmd_input *handle, char *buf) > > host->ts_samples[i].time = tep_read_number(handle->pevent, > > buf8 + i, 8); > > host->ts_samples[i].offset = tep_read_number(handle->pevent, > > - buf8 + host->ts_samples_count+i, 8); > > + buf8 + host->ts_samples_count + i, 8); > > + host->ts_samples[i].scaling = tep_read_number(handle->pevent, > > + buf8 + (2 * host->ts_samples_count) + i, 8); > > } > > > I was thinking the above code may read better if we changed it to: > > long long *time_buf; > long long *offset_buf; > long long *scaling_buf; > > time_buf = (long long *)buf; > offset_buf = time_buf + host->ts_samples_count; > scaling_buf = offset_buf + host->ts_samples_count; > > for (i = 0; i < host->ts_samples_count; i++) { > host->ts_samples[i].time = tep_read_number(handle->pevent, > time_buf + i, 8); > host->ts_samples[i].offset = tep_read_number(handle-> pevent, > offset_buf + i, 8); > host->ts_samples[i].scaling = tep_read_number(handle->pevent, > scaling_buf + i, 8); > } > This code is rewritten in "trace-cmd: Add timestamp synchronization per vCPU" patch in a better and safer way. > -- Steve > > > > > qsort(host->ts_samples, host->ts_samples_count, > > sizeof(struct ts_offset_sample), tsync_offset_cmp); > > @@ -2534,6 +2539,7 @@ static int handle_options(struct tracecmd_input *handle) > > * long long array of size [count] of times, > > * when the offsets were calculated. > > * long long array of size [count] of timestamp offsets. > > + * long long array of size [count] of timestamp scaling ratios.* > > */ > > if (size < 12 || handle->flags & TRACECMD_FL_IGNORE_DATE) > > break; -- Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center