aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2016-02-23 12:14:02 -0500
committerSteven Rostedt <rostedt@goodmis.org>2016-02-23 14:21:25 -0500
commit92320df3c2ff50f139f3ba2e52a34255ad6cccd8 (patch)
tree9232130b4b46df94a358a90eb49df8ab4566de7a
parent853819899f74ac712cb30f31063a5d2d02106239 (diff)
downloadtrace-cmd-92320df3c2ff50f139f3ba2e52a34255ad6cccd8.tar.gz
trace-cmd report: Add --ts-offset to add to timestamps of events
When merging two or more data files, if the timestamp difference between them are known, add the --ts-offset option to let the user specify the offset from one data file to the next. This helps merging trace data files from hosts and guests where the timestamp offset is a known value. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--Documentation/trace-cmd-report.1.txt14
-rw-r--r--trace-cmd.h2
-rw-r--r--trace-input.c6
-rw-r--r--trace-read.c27
-rw-r--r--trace-usage.c2
5 files changed, 48 insertions, 3 deletions
diff --git a/Documentation/trace-cmd-report.1.txt b/Documentation/trace-cmd-report.1.txt
index 949cad82..309e33af 100644
--- a/Documentation/trace-cmd-report.1.txt
+++ b/Documentation/trace-cmd-report.1.txt
@@ -248,6 +248,20 @@ OPTIONS
If the trace.dat file recorded uname during the run, this will retrieve that
information.
+*--ts-offset* offset::
+ Add (or subtract if negative) an offset for all timestamps of the previous
+ data file specified with *-i*. This is useful to merge sort multiple trace.dat
+ files where the difference in the timestamp is known. For example if a trace
+ is done on a virtual guest, and another trace is done on the host. If the
+ host timestamp is 1000 units ahead of the guest, the following can be done:
+
+ trace-cmd report -i host.dat --ts-offset -1000 -i guest.dat
+
+ This will subtract 1000 timestamp units from all the host events as it merges
+ with the guest.dat events. Note, the units is for the raw units recorded in
+ the trace. If the units are nanoseconds, the addition (or subtraction) from
+ the offset will be nanoseconds even if the displayed units are microseconds.
+
EXAMPLES
--------
diff --git a/trace-cmd.h b/trace-cmd.h
index 09aaae37..ad3a5051 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -126,6 +126,8 @@ const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int ind
struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
int tracecmd_is_buffer_instance(struct tracecmd_input *handle);
+void tracecmd_set_ts_offset(struct tracecmd_input *handle, unsigned long long offset);
+
void tracecmd_print_events(struct tracecmd_input *handle, const char *regex);
struct hook_list *tracecmd_hooks(struct tracecmd_input *handle);
diff --git a/trace-input.c b/trace-input.c
index 958d44f8..07b5aab0 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -1933,6 +1933,12 @@ static int init_cpu(struct tracecmd_input *handle, int cpu)
return 0;
}
+void tracecmd_set_ts_offset(struct tracecmd_input *handle,
+ unsigned long long offset)
+{
+ handle->ts_offset = offset;
+}
+
static int handle_options(struct tracecmd_input *handle)
{
unsigned long long offset;
diff --git a/trace-read.c b/trace-read.c
index ccac1816..1e1778ea 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -72,8 +72,10 @@ static struct list_head handle_list;
struct input_files {
struct list_head list;
const char *file;
+ unsigned long long tsoffset;
};
static struct list_head input_files;
+static struct input_files *last_input_file;
struct pid_list {
struct pid_list *next;
@@ -292,6 +294,7 @@ static void add_input(const char *file)
die("Failed to allocate for %s", file);
item->file = file;
list_add_tail(&item->list, &input_files);
+ last_input_file = item;
}
static void add_handle(struct tracecmd_input *handle, const char *file)
@@ -1360,6 +1363,7 @@ static void add_hook(const char *arg)
}
enum {
+ OPT_tsoffset = 241,
OPT_bycomm = 242,
OPT_debug = 243,
OPT_uname = 244,
@@ -1389,6 +1393,7 @@ void trace_report (int argc, char **argv)
struct input_files *inputs;
struct handle_list *handles;
enum output_type otype;
+ unsigned long long tsoffset = 0;
int show_stat = 0;
int show_funcs = 0;
int show_endian = 0;
@@ -1438,6 +1443,7 @@ void trace_report (int argc, char **argv)
{"profile", no_argument, NULL, OPT_profile},
{"uname", no_argument, NULL, OPT_uname},
{"by-comm", no_argument, NULL, OPT_bycomm},
+ {"ts-offset", required_argument, NULL, OPT_tsoffset},
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
@@ -1452,8 +1458,11 @@ void trace_report (int argc, char **argv)
break;
case 'i':
if (input_file) {
- if (!multi_inputs)
+ if (!multi_inputs) {
add_input(input_file);
+ if (tsoffset)
+ last_input_file->tsoffset = tsoffset;
+ }
multi_inputs++;
add_input(optarg);
} else
@@ -1584,6 +1593,13 @@ void trace_report (int argc, char **argv)
case OPT_bycomm:
trace_profile_set_merge_like_comms();
break;
+ case OPT_tsoffset:
+ tsoffset = atoll(optarg);
+ if (multi_inputs)
+ last_input_file->tsoffset = tsoffset;
+ if (!input_file)
+ die("--ts-offset must come after -i");
+ break;
default:
usage(argv);
}
@@ -1598,9 +1614,11 @@ void trace_report (int argc, char **argv)
if (!input_file)
input_file = default_input_file;
- if (!multi_inputs)
+ if (!multi_inputs) {
add_input(input_file);
- else if (show_wakeup)
+ if (tsoffset)
+ last_input_file->tsoffset = tsoffset;
+ } else if (show_wakeup)
die("Wakeup tracing can only be done on a single input file");
list_for_each_entry(inputs, &input_files, list) {
@@ -1623,6 +1641,9 @@ void trace_report (int argc, char **argv)
return;
}
+ if (inputs->tsoffset)
+ tracecmd_set_ts_offset(handle, inputs->tsoffset);
+
pevent = tracecmd_get_pevent(handle);
if (nanosec)
diff --git a/trace-usage.c b/trace-usage.c
index 4a0d110e..ed6a913d 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -161,6 +161,8 @@ static struct usage_help usage_help[] = {
" -H Allows users to hook two events together for timings\n"
" (used with --profile)\n"
" --by-comm used with --profile, merge events for related comms\n"
+ " --ts-offset will add amount to timestamp of all events of the\n"
+ " previous data file.\n"
},
{
"stream",