[PATCH 5/5] trace-cmd: make trace-hist work with instances

From: Josef Bacik
Date: Fri May 08 2015 - 15:29:51 EST


If you recorded information completely in an instance then trace-hist wouldn't
think your trace.dat file had any events because it didn't know about instances.
Fix this.

Signed-off-by: Josef Bacik <jbacik@xxxxxx>
---
trace-hist.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/trace-hist.c b/trace-hist.c
index 574549e..2a2e780 100644
--- a/trace-hist.c
+++ b/trace-hist.c
@@ -954,13 +954,6 @@ static void do_trace_hist(struct tracecmd_input *handle)
int cpu;
int ret;

- ret = tracecmd_init_data(handle);
- if (ret < 0)
- die("failed to init data");
-
- if (ret > 0)
- die("trace-cmd hist does not work with latency traces\n");
-
cpus = tracecmd_cpus(handle);

/* Need to get any event */
@@ -1025,6 +1018,7 @@ void trace_hist(int argc, char **argv)
{
struct tracecmd_input *handle;
const char *input_file = NULL;
+ int instances;
int ret;

for (;;) {
@@ -1067,7 +1061,30 @@ void trace_hist(int argc, char **argv)
if (ret)
return;

- do_trace_hist(handle);
+ ret = tracecmd_init_data(handle);
+ if (ret < 0)
+ die("failed to init data");
+
+ if (ret > 0)
+ die("trace-cmd hist does not work with latency traces\n");
+
+ instances = tracecmd_buffer_instances(handle);
+ if (instances) {
+ struct tracecmd_input *new_handle;
+ int i;
+
+ for (i = 0; i < instances; i++) {
+ new_handle = tracecmd_buffer_instance_handle(handle, i);
+ if (!new_handle) {
+ warning("could not retrieve handle %d", i);
+ continue;
+ }
+ do_trace_hist(new_handle);
+ tracecmd_close(new_handle);
+ }
+ } else {
+ do_trace_hist(handle);
+ }

tracecmd_close(handle);
}
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/