Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757210AbbDVE4w (ORCPT ); Wed, 22 Apr 2015 00:56:52 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:34507 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757171AbbDVE4i (ORCPT ); Wed, 22 Apr 2015 00:56:38 -0400 From: Howard Cochran To: Steven Rostedt Cc: Howard Cochran , linux-kernel@vger.kernel.org, Howard Cochran Subject: [PATCH v3 1/5] trace-cmd extract: Add -B and -t for multiple instances Date: Wed, 22 Apr 2015 00:55:10 -0400 Message-Id: <7b18a3f624fd1e864a86c0cee2079587953fa5ee.1429677461.git.hcochran@kernelspring.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2930 Lines: 89 Add -B option to trace-cmd extract so that it can extract listed instances. As with start, stop, and reset, the top level instance is not included when any -B are given. However, -t makes it also include the top instance. As with other commands, if neither option is given, only operate on the top instance. Signed-off-by: Howard Cochran --- trace-record.c | 20 +++++++++++++------- trace-usage.c | 6 ++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/trace-record.c b/trace-record.c index 6e0ab3b..8340416 100644 --- a/trace-record.c +++ b/trace-record.c @@ -523,17 +523,20 @@ static int create_recorder(struct buffer_instance *instance, int cpu, static void flush_threads(void) { + struct buffer_instance *instance; long ret; int i; if (!cpu_count) return; - for (i = 0; i < cpu_count; i++) { - /* Extract doesn't support sub buffers yet */ - ret = create_recorder(&top_instance, i, TRACE_TYPE_EXTRACT, NULL); - if (ret < 0) - die("error reading ring buffer"); + for_all_instances(instance) { + for (i = 0; i < cpu_count; i++) { + /* Extract doesn't support sub buffers yet */ + ret = create_recorder(instance, i, TRACE_TYPE_EXTRACT, NULL); + if (ret < 0) + die("error reading ring buffer"); + } } } @@ -3873,7 +3876,7 @@ void trace_record (int argc, char **argv) }; if (extract) - opts = "+haf:Fp:co:O:sr:g:l:n:P:N:tb:ksiT"; + opts = "+haf:Fp:co:O:sr:g:l:n:P:N:tb:B:ksiT"; else opts = "+hae:f:Fp:cC:dDGo:O:s:r:vg:l:n:P:N:tb:R:B:ksSiTm:M:H:"; c = getopt_long (argc-1, argv+1, opts, long_options, &option_index); @@ -4061,7 +4064,10 @@ void trace_record (int argc, char **argv) instance->cpumask = optarg; break; case 't': - use_tcp = 1; + if (extract) + topt = 1; /* Extract top instance also */ + else + use_tcp = 1; break; case 'b': instance->buffer_size = atoi(optarg); diff --git a/trace-usage.c b/trace-usage.c index 520b14b..a708a85 100644 --- a/trace-usage.c +++ b/trace-usage.c @@ -62,9 +62,11 @@ static struct usage_help usage_help[] = { { "extract", "extract a trace from the kernel", - " %s extract [-p plugin][-O option][-o file][-s]\n" - " Uses same options as record, but only reads an existing trace.\n" + " %s extract [-p plugin][-O option][-o file][-B buf][-s][-t]\n" + " Uses similar options as record, but only reads an existing trace.\n" " -s : extract the snapshot instead of the main buffer\n" + " -B : extract a given buffer (more than one may be specified)\n" + " -t : include the top level buffer (useful with -B)\n" }, { "stop", -- 1.9.1 -- 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/