[PATCH 3/5] perf kvm: Print kvm specific --help output

2014-10-22 Thread Namhyung Kim
The 'perf kvm stat record' tool is an alias of 'perf record' with
predefined kvm related options. All options that passed to 'perf kvm
stat record' are processed by the 'perf record' tool. So, 'perf kvm
stat record --help' prints help of usage for the 'perf record'
command. There are a few options useful for 'perf kvm stat record',
the rest either break kvm related output or don't change it.

Let's print safe for 'perf kvm stat record' options in addition to
general 'perf record' --help output.

With this patch, new output looks like below:

  $ perf kvm stat record -h

   usage: perf kvm stat record []

  -p, --pidrecord events on existing process id
  -t, --tidrecord events on existing thread id
  -r, --realtime collect data with this RT SCHED_FIFO priority
  --no-bufferingcollect data without buffering
  -a, --all-cpussystem-wide collection from all CPUs
  -C, --cpulist of cpus to monitor
  -c, --countevent period to sample
  -o, --outputoutput file name
  -i, --no-inherit  child tasks do not inherit counters
  -m, --mmap-pages 
number of mmap data pages
  -v, --verbose be more verbose (show counter open errors, etc)
  -q, --quiet   don't print any message
  -s, --statper thread counts
  -D, --delayms to wait before starting measurement after 
program start
  -u, --uid   user to profile
  --per-thread  use per-thread mmaps

  $ perf kvm stat record -n sleep 1
Error: switch `n' is not usable

   usage: perf kvm stat record []

Cc: Alexander Yarygin 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-kvm.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index b65eb0507b38..3c0f3d4fb021 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1132,6 +1132,10 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
"-m", "1024",
"-c", "1",
};
+   const char * const kvm_stat_record_usage[] = {
+   "perf kvm stat record []",
+   NULL
+   };
const char * const *events_tp;
events_tp_size = 0;
 
@@ -1159,6 +1163,27 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
for (j = 1; j < (unsigned int)argc; j++, i++)
rec_argv[i] = argv[j];
 
+   set_option_flag(record_options, 'e', "event", PARSE_OPT_HIDDEN);
+   set_option_flag(record_options, 0, "filter", PARSE_OPT_HIDDEN);
+   set_option_flag(record_options, 'R', "raw-samples", PARSE_OPT_HIDDEN);
+
+   set_option_flag(record_options, 'F', "freq", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, "group", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'g', NULL, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, "call-graph", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'd', "data", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'T', "timestamp", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'P', "period", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'n', "no-samples", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'N', "no-buildid-cache", 
PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'B', "no-buildid", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'G', "cgroup", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'b', "branch-any", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'j', "branch-filter", 
PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'W', "weight", PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, "transaction", PARSE_OPT_DISABLED);
+
+   record_usage = kvm_stat_record_usage;
return cmd_record(i, rec_argv, NULL);
 }
 
-- 
2.0.0

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


[PATCH 3/5] perf kvm: Print kvm specific --help output

2014-10-22 Thread Namhyung Kim
The 'perf kvm stat record' tool is an alias of 'perf record' with
predefined kvm related options. All options that passed to 'perf kvm
stat record' are processed by the 'perf record' tool. So, 'perf kvm
stat record --help' prints help of usage for the 'perf record'
command. There are a few options useful for 'perf kvm stat record',
the rest either break kvm related output or don't change it.

Let's print safe for 'perf kvm stat record' options in addition to
general 'perf record' --help output.

With this patch, new output looks like below:

  $ perf kvm stat record -h

   usage: perf kvm stat record [options]

  -p, --pid pid   record events on existing process id
  -t, --tid tid   record events on existing thread id
  -r, --realtime ncollect data with this RT SCHED_FIFO priority
  --no-bufferingcollect data without buffering
  -a, --all-cpussystem-wide collection from all CPUs
  -C, --cpu cpu   list of cpus to monitor
  -c, --count n   event period to sample
  -o, --output file   output file name
  -i, --no-inherit  child tasks do not inherit counters
  -m, --mmap-pages pages
number of mmap data pages
  -v, --verbose be more verbose (show counter open errors, etc)
  -q, --quiet   don't print any message
  -s, --statper thread counts
  -D, --delay n   ms to wait before starting measurement after 
program start
  -u, --uid user  user to profile
  --per-thread  use per-thread mmaps

  $ perf kvm stat record -n sleep 1
Error: switch `n' is not usable

   usage: perf kvm stat record [options]

Cc: Alexander Yarygin yary...@linux.vnet.ibm.com
Signed-off-by: Namhyung Kim namhy...@kernel.org
---
 tools/perf/builtin-kvm.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index b65eb0507b38..3c0f3d4fb021 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1132,6 +1132,10 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
-m, 1024,
-c, 1,
};
+   const char * const kvm_stat_record_usage[] = {
+   perf kvm stat record [options],
+   NULL
+   };
const char * const *events_tp;
events_tp_size = 0;
 
@@ -1159,6 +1163,27 @@ kvm_events_record(struct perf_kvm_stat *kvm, int argc, 
const char **argv)
for (j = 1; j  (unsigned int)argc; j++, i++)
rec_argv[i] = argv[j];
 
+   set_option_flag(record_options, 'e', event, PARSE_OPT_HIDDEN);
+   set_option_flag(record_options, 0, filter, PARSE_OPT_HIDDEN);
+   set_option_flag(record_options, 'R', raw-samples, PARSE_OPT_HIDDEN);
+
+   set_option_flag(record_options, 'F', freq, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, group, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'g', NULL, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, call-graph, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'd', data, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'T', timestamp, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'P', period, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'n', no-samples, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'N', no-buildid-cache, 
PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'B', no-buildid, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'G', cgroup, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'b', branch-any, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'j', branch-filter, 
PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 'W', weight, PARSE_OPT_DISABLED);
+   set_option_flag(record_options, 0, transaction, PARSE_OPT_DISABLED);
+
+   record_usage = kvm_stat_record_usage;
return cmd_record(i, rec_argv, NULL);
 }
 
-- 
2.0.0

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