Message ID | 20210322095945.259300-15-tz.stoyanov@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | TSC trace clock to nanosecond conversion | expand |
On Mon, 22 Mar 2021 11:59:41 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote: > A new flag is added in the trace-cmd library for controlling events > timestamp corrections while reading a trace file. If the flag is set, > all timestamps are displayed as-is from the trace file. > TRACECMD_FL_RAW_TS > The flag can be modified with these APIs: > tracecmd_set_flag() > tracecmd_clear_flag() > > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> > --- > lib/trace-cmd/include/private/trace-cmd-private.h | 1 + > lib/trace-cmd/trace-input.c | 12 ++++++++---- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h > index c33d067a..fdca7494 100644 > --- a/lib/trace-cmd/include/private/trace-cmd-private.h > +++ b/lib/trace-cmd/include/private/trace-cmd-private.h > @@ -134,6 +134,7 @@ enum { > TRACECMD_FL_IGNORE_DATE = (1 << 0), > TRACECMD_FL_BUFFER_INSTANCE = (1 << 1), > TRACECMD_FL_IN_USECS = (1 << 2), > + TRACECMD_FL_RAW_TS = (1 << 3), > }; > > struct tracecmd_ftrace { > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c > index 5d03cd00..88007cde 100644 > --- a/lib/trace-cmd/trace-input.c > +++ b/lib/trace-cmd/trace-input.c > @@ -1289,6 +1289,9 @@ static unsigned long long timestamp_calc(unsigned long long ts, > { > unsigned long long t = ts; > > + /* do not modify raw timestamps */ > + if (handle->flags & TRACECMD_FL_RAW_TS) > + return ts; > > /* Guest trace file, sync with host timestamps */ > if (handle->host.sync_enable) > @@ -2604,7 +2607,8 @@ static int handle_options(struct tracecmd_input *handle) > * gtod. It is stored as ASCII with '0x' > * appended. > */ > - if (handle->flags & TRACECMD_FL_IGNORE_DATE) > + if ((handle->flags & TRACECMD_FL_IGNORE_DATE) || > + (handle->flags & TRACECMD_FL_RAW_TS)) > break; These are flags, let's use them as such: if (handle->flags & (TRACECMD_FL_IGNORE_DATE | TRACECMD_FL_RAW_TS)) break; > offset = strtoll(buf, NULL, 0); > /* Convert from micro to nano */ > @@ -2616,7 +2620,7 @@ static int handle_options(struct tracecmd_input *handle) > * Similar to date option, but just adds an > * offset to the timestamp. > */ > - if (handle->flags & TRACECMD_FL_IGNORE_DATE) > + if (handle->flags & TRACECMD_FL_RAW_TS) Why do we not break here for IGNORE_DATE? > break; > offset = strtoll(buf, NULL, 0); > handle->ts_offset += offset; > @@ -2631,7 +2635,7 @@ static int handle_options(struct tracecmd_input *handle) > * long long array of size [count] of timestamp offsets. > * long long array of size [count] of timestamp scaling ratios.* > */ > - if (size < 16 || handle->flags & TRACECMD_FL_IGNORE_DATE) > + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) And why did we change the code for IGNORE_DATE here too? -- Steve > break; > handle->host.peer_trace_id = tep_read_number(handle->pevent, > buf, 8); > @@ -2710,7 +2714,7 @@ static int handle_options(struct tracecmd_input *handle) > trace_guest_load(handle, buf, size); > break; > case TRACECMD_OPTION_TSC2NSEC: > - if (size < 16) > + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) > break; > handle->tsc_calc.mult = tep_read_number(handle->pevent, > buf, 4);
On Wed, Mar 24, 2021 at 3:49 AM Steven Rostedt <rostedt@goodmis.org> wrote: > > On Mon, 22 Mar 2021 11:59:41 +0200 > "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote: > > > A new flag is added in the trace-cmd library for controlling events > > timestamp corrections while reading a trace file. If the flag is set, > > all timestamps are displayed as-is from the trace file. > > TRACECMD_FL_RAW_TS > > The flag can be modified with these APIs: > > tracecmd_set_flag() > > tracecmd_clear_flag() > > > > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> > > --- > > lib/trace-cmd/include/private/trace-cmd-private.h | 1 + > > lib/trace-cmd/trace-input.c | 12 ++++++++---- > > 2 files changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h > > index c33d067a..fdca7494 100644 > > --- a/lib/trace-cmd/include/private/trace-cmd-private.h > > +++ b/lib/trace-cmd/include/private/trace-cmd-private.h > > @@ -134,6 +134,7 @@ enum { > > TRACECMD_FL_IGNORE_DATE = (1 << 0), > > TRACECMD_FL_BUFFER_INSTANCE = (1 << 1), > > TRACECMD_FL_IN_USECS = (1 << 2), > > + TRACECMD_FL_RAW_TS = (1 << 3), > > }; > > > > struct tracecmd_ftrace { > > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c > > index 5d03cd00..88007cde 100644 > > --- a/lib/trace-cmd/trace-input.c > > +++ b/lib/trace-cmd/trace-input.c > > @@ -1289,6 +1289,9 @@ static unsigned long long timestamp_calc(unsigned long long ts, > > { > > unsigned long long t = ts; > > > > + /* do not modify raw timestamps */ > > + if (handle->flags & TRACECMD_FL_RAW_TS) > > + return ts; > > > > /* Guest trace file, sync with host timestamps */ > > if (handle->host.sync_enable) > > @@ -2604,7 +2607,8 @@ static int handle_options(struct tracecmd_input *handle) > > * gtod. It is stored as ASCII with '0x' > > * appended. > > */ > > - if (handle->flags & TRACECMD_FL_IGNORE_DATE) > > + if ((handle->flags & TRACECMD_FL_IGNORE_DATE) || > > + (handle->flags & TRACECMD_FL_RAW_TS)) > > break; > > These are flags, let's use them as such: > > if (handle->flags & > (TRACECMD_FL_IGNORE_DATE | TRACECMD_FL_RAW_TS)) > break; > > > offset = strtoll(buf, NULL, 0); > > /* Convert from micro to nano */ > > @@ -2616,7 +2620,7 @@ static int handle_options(struct tracecmd_input *handle) > > * Similar to date option, but just adds an > > * offset to the timestamp. > > */ > > - if (handle->flags & TRACECMD_FL_IGNORE_DATE) > > + if (handle->flags & TRACECMD_FL_RAW_TS) > > Why do we not break here for IGNORE_DATE? > > > break; > > offset = strtoll(buf, NULL, 0); > > handle->ts_offset += offset; > > @@ -2631,7 +2635,7 @@ static int handle_options(struct tracecmd_input *handle) > > * long long array of size [count] of timestamp offsets. > > * long long array of size [count] of timestamp scaling ratios.* > > */ > > - if (size < 16 || handle->flags & TRACECMD_FL_IGNORE_DATE) > > + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) > > And why did we change the code for IGNORE_DATE here too? When we discuss the priorities of the various time sync options, I understood that the "--nodate" should affect the "--date" option only. For all other time sync options, the new flag should be used. That's why I changed IGNORE_DATE to RAW_TS in these two places. > > -- Steve > > > break; > > handle->host.peer_trace_id = tep_read_number(handle->pevent, > > buf, 8); > > @@ -2710,7 +2714,7 @@ static int handle_options(struct tracecmd_input *handle) > > trace_guest_load(handle, buf, size); > > break; > > case TRACECMD_OPTION_TSC2NSEC: > > - if (size < 16) > > + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) > > break; > > handle->tsc_calc.mult = tep_read_number(handle->pevent, > > buf, 4); >
On Wed, 24 Mar 2021 14:10:56 +0200 Tzvetomir Stoyanov <tz.stoyanov@gmail.com> wrote: > > And why did we change the code for IGNORE_DATE here too? > > When we discuss the priorities of the various time sync options, I > understood that the "--nodate" should affect the "--date" option only. > For all other time sync options, the new flag should be used. That's > why I changed IGNORE_DATE to RAW_TS in these two places. I kind of remember that, but as it's unrelated to this patch, let's make that a separate change, as it doesn't match the change log. Thanks! -- Steve
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h index c33d067a..fdca7494 100644 --- a/lib/trace-cmd/include/private/trace-cmd-private.h +++ b/lib/trace-cmd/include/private/trace-cmd-private.h @@ -134,6 +134,7 @@ enum { TRACECMD_FL_IGNORE_DATE = (1 << 0), TRACECMD_FL_BUFFER_INSTANCE = (1 << 1), TRACECMD_FL_IN_USECS = (1 << 2), + TRACECMD_FL_RAW_TS = (1 << 3), }; struct tracecmd_ftrace { diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 5d03cd00..88007cde 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -1289,6 +1289,9 @@ static unsigned long long timestamp_calc(unsigned long long ts, { unsigned long long t = ts; + /* do not modify raw timestamps */ + if (handle->flags & TRACECMD_FL_RAW_TS) + return ts; /* Guest trace file, sync with host timestamps */ if (handle->host.sync_enable) @@ -2604,7 +2607,8 @@ static int handle_options(struct tracecmd_input *handle) * gtod. It is stored as ASCII with '0x' * appended. */ - if (handle->flags & TRACECMD_FL_IGNORE_DATE) + if ((handle->flags & TRACECMD_FL_IGNORE_DATE) || + (handle->flags & TRACECMD_FL_RAW_TS)) break; offset = strtoll(buf, NULL, 0); /* Convert from micro to nano */ @@ -2616,7 +2620,7 @@ static int handle_options(struct tracecmd_input *handle) * Similar to date option, but just adds an * offset to the timestamp. */ - if (handle->flags & TRACECMD_FL_IGNORE_DATE) + if (handle->flags & TRACECMD_FL_RAW_TS) break; offset = strtoll(buf, NULL, 0); handle->ts_offset += offset; @@ -2631,7 +2635,7 @@ static int handle_options(struct tracecmd_input *handle) * long long array of size [count] of timestamp offsets. * long long array of size [count] of timestamp scaling ratios.* */ - if (size < 16 || handle->flags & TRACECMD_FL_IGNORE_DATE) + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) break; handle->host.peer_trace_id = tep_read_number(handle->pevent, buf, 8); @@ -2710,7 +2714,7 @@ static int handle_options(struct tracecmd_input *handle) trace_guest_load(handle, buf, size); break; case TRACECMD_OPTION_TSC2NSEC: - if (size < 16) + if (size < 16 || (handle->flags & TRACECMD_FL_RAW_TS)) break; handle->tsc_calc.mult = tep_read_number(handle->pevent, buf, 4);
A new flag is added in the trace-cmd library for controlling events timestamp corrections while reading a trace file. If the flag is set, all timestamps are displayed as-is from the trace file. TRACECMD_FL_RAW_TS The flag can be modified with these APIs: tracecmd_set_flag() tracecmd_clear_flag() Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-input.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)