From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 1/5] trace-cmd: Remove ts offset from tsc2nsec conversion
Date: Wed, 28 Apr 2021 15:28:35 +0300 [thread overview]
Message-ID: <20210428122839.805296-2-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210428122839.805296-1-tz.stoyanov@gmail.com>
Do not get, store and use offset when converting TSC to nanoseconds.
The logic for automatically detecting the TSC offset is not stable enough
and could introduce errors, which leads to problems when reading trace
files in some use cases. The offset is not mandatory for tsc2nsec
conversion.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
lib/trace-cmd/trace-input.c | 1 -
tracecmd/trace-record.c | 62 -------------------------------------
2 files changed, 63 deletions(-)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index a00fa982..e8a257db 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1319,7 +1319,6 @@ static unsigned long long timestamp_calc(unsigned long long ts, int cpu,
ts *= handle->ts2secs;
} else if (handle->tsc_calc.mult) {
/* auto calculated TSC clock frequency */
- ts -= handle->tsc_calc.offset;
ts = mul_u64_u32_shr(ts, handle->tsc_calc.mult, handle->tsc_calc.shift);
}
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index fd03a605..d732b394 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -6483,65 +6483,6 @@ static bool has_local_instances(void)
return false;
}
-/*
- * Get the current clock value
- */
-#define CLOCK_INST_NAME "_clock_instance_"
-static unsigned long long get_clock_now(const char *clock)
-{
- struct tracefs_instance *ts_instance = NULL;
- unsigned long long ts = 0;
- struct tep_handle *tep;
- int tfd;
- int ret;
-
- /* Set up a tep to read the raw format */
- tep = get_ftrace_tep();
- if (!tep)
- return 0;
- ts_instance = tracefs_instance_create(CLOCK_INST_NAME);
- if (!ts_instance)
- goto out;
- if (clock) {
- ret = tracefs_instance_file_write(ts_instance, "trace_clock", clock);
- if (ret < strlen(clock))
- goto out;
- }
- tfd = tracefs_instance_file_open(ts_instance, "trace_marker", O_WRONLY);
- if (tfd < 0)
- goto out;
- tracefs_trace_on(ts_instance);
- ret = write(tfd, STAMP, 5);
- tracefs_trace_off(ts_instance);
- ts = find_time_stamp(tep, ts_instance);
- close(tfd);
-
-out:
- if (ts_instance) {
- if (tracefs_instance_is_new(ts_instance))
- tracefs_instance_destroy(ts_instance);
- tracefs_instance_free(ts_instance);
- }
- tep_free(tep);
-
- return ts;
-}
-
-static void get_tsc_offset(struct common_record_context *ctx)
-{
- struct buffer_instance *instance;
-
- for_all_instances(instance) {
- if (is_guest(instance) || !instance->clock)
- continue;
-
- ctx->tsc2nsec.offset = get_clock_now(instance->clock);
- return;
- }
-
- ctx->tsc2nsec.offset = get_clock_now(NULL);
-}
-
static void set_tsync_params(struct common_record_context *ctx)
{
struct buffer_instance *instance;
@@ -6566,7 +6507,6 @@ static void set_tsync_params(struct common_record_context *ctx)
die("Cannot not allocate clock");
ctx->tsc2nsec.mult = mult;
ctx->tsc2nsec.shift = shift;
- ctx->tsc2nsec.offset = get_clock_now(TSC_CLOCK);
force_tsc = true;
} else { /* Use the current clock of the first host instance */
clock = get_trace_clock(true);
@@ -6661,8 +6601,6 @@ static void record_trace(int argc, char **argv,
for_all_instances(instance)
set_clock(instance);
- if (ctx->tsc2nsec.mult)
- get_tsc_offset(ctx);
/* Record records the date first */
if (ctx->date &&
--
2.30.2
next prev parent reply other threads:[~2021-04-28 12:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 12:28 RFC [PATCH 0/5] tsc2nsec fixes Tzvetomir Stoyanov (VMware)
2021-04-28 12:28 ` Tzvetomir Stoyanov (VMware) [this message]
2021-04-28 12:28 ` [PATCH 2/5] trace-cmd library: Remove useless check before applying ts offset Tzvetomir Stoyanov (VMware)
2021-04-28 12:28 ` [PATCH 3/5] trace-cmd library: Store the timestamp of the first event when reading a trace file Tzvetomir Stoyanov (VMware)
2021-04-28 12:28 ` [PATCH 4/5] trace-cmd library: New API for modifyning the timestamp offset Tzvetomir Stoyanov (VMware)
2021-04-28 12:28 ` [PATCH 5/5] trace-cmd report: New option --align-ts 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=20210428122839.805296-2-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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).