diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-05-08 16:52:45 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-06-10 15:11:05 -0400 |
commit | 972f8d0f102eb64ba5147b3478c13fbacf7b6de9 (patch) | |
tree | 88c4dacf34d6a7a6a89eb02c5cda448b3890bdc8 | |
parent | 5c731d51ae340eacb77ff6c28d0b7019a6f5d64a (diff) | |
download | trace-cmd-972f8d0f102eb64ba5147b3478c13fbacf7b6de9.tar.gz |
trace-cmd split: Do not allow spliting of latency tracers
trace-cmd split is an operation to make large data records into more
manageable sized files.
But for latency tracers like:
trace-cmd record wakeup
trace-cmd does not record any binary files, it only records the ASCII
contents of the trace file that is only a snapshot of where the latency
happens (which is usually rather small). trace-cmd split is made for
"flight recording" (constant recording over a period of time) that can
cause the file to become gigabytes in size. Splitting the ASCII text does
not make any sense.
That said, trace-cmd split should not segfault either when trying to split
a latency trace. Instead do what trace-cmd hist does, which is to simply
exit with an error message that says it does not support latency traces.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-cmd.h | 2 | ||||
-rw-r--r-- | trace-input.c | 12 | ||||
-rw-r--r-- | trace-split.c | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/trace-cmd.h b/trace-cmd.h index 7bce2a56..59194ef4 100644 --- a/trace-cmd.h +++ b/trace-cmd.h @@ -94,6 +94,7 @@ enum { enum { TRACECMD_FL_IGNORE_DATE = (1 << 0), TRACECMD_FL_BUFFER_INSTANCE = (1 << 1), + TRACECMD_FL_LATENCY = (1 << 2), }; struct tracecmd_ftrace { @@ -116,6 +117,7 @@ int tracecmd_cpus(struct tracecmd_input *handle); int tracecmd_copy_headers(struct tracecmd_input *handle, int fd); void tracecmd_set_flag(struct tracecmd_input *handle, int flag); void tracecmd_clear_flag(struct tracecmd_input *handle, int flag); +unsigned long tracecmd_get_flags(struct tracecmd_input *handle); int tracecmd_make_pipe(struct tracecmd_input *handle, int cpu, int fd, int cpus); diff --git a/trace-input.c b/trace-input.c index 92eba45c..89f4e9e6 100644 --- a/trace-input.c +++ b/trace-input.c @@ -122,6 +122,11 @@ void tracecmd_clear_flag(struct tracecmd_input *handle, int flag) handle->flags &= ~flag; } +unsigned long tracecmd_get_flags(struct tracecmd_input *handle) +{ + return handle->flags; +} + #if DEBUG_RECORD static void remove_record(struct page *page, struct pevent_record *record) { @@ -2036,8 +2041,10 @@ static int read_cpu_data(struct tracecmd_input *handle) /* * Check if this is a latency report or not. */ - if (strncmp(buf, "latency", 7) == 0) + if (strncmp(buf, "latency", 7) == 0) { + handle->flags |= TRACECMD_FL_LATENCY; return 1; + } /* We expect this to be flyrecord */ if (strncmp(buf, "flyrecord", 9) != 0) @@ -2457,6 +2464,7 @@ struct tracecmd_input *tracecmd_alloc(const char *file) struct tracecmd_input *tracecmd_open_fd(int fd) { struct tracecmd_input *handle; + int ret; handle = tracecmd_alloc_fd(fd); if (!handle) @@ -2465,7 +2473,7 @@ struct tracecmd_input *tracecmd_open_fd(int fd) if (tracecmd_read_headers(handle) < 0) goto fail; - if (tracecmd_init_data(handle) < 0) + if ((ret = tracecmd_init_data(handle)) < 0) goto fail; return handle; diff --git a/trace-split.c b/trace-split.c index d7d1cb9c..e48c7b11 100644 --- a/trace-split.c +++ b/trace-split.c @@ -516,6 +516,9 @@ void trace_split (int argc, char **argv) if (!handle) die("error reading %s", input_file); + if (tracecmd_get_flags(handle) & TRACECMD_FL_LATENCY) + die("trace-cmd split does not work with latency traces\n"); + page_size = tracecmd_page_size(handle); if (!output) |