Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932559AbbEHT3s (ORCPT ); Fri, 8 May 2015 15:29:48 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:51797 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932487AbbEHT3Z (ORCPT ); Fri, 8 May 2015 15:29:25 -0400 From: Josef Bacik To: , , Subject: [PATCH 5/5] trace-cmd: make trace-hist work with instances Date: Fri, 8 May 2015 15:29:04 -0400 Message-ID: <1431113344-22579-6-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431113344-22579-1-git-send-email-jbacik@fb.com> References: <1431113344-22579-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.52.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-05-08_07:2015-05-08,2015-05-08,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1912 Lines: 75 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 --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/