[PATCH] perf kmem: pass additional arguments to record

From: Ian Rogers
Date: Wed Jul 08 2020 - 14:39:25 EST


perf kmem has an input file option but current an output file option
fails:
```
$ sudo perf kmem record -o /tmp/p.data sleep 1 Â
ÂError: unknown switch `o'

Usage: perf kmem [<options>] {record|stat}

 Â-f, --force      don't complain, do it
 Â-i, --input <file>  Âinput file name
 Â-l, --line <num>   Âshow n lines
 Â-s, --sort <key[,key2...]>
            Âsort by keys: ptr, callsite, bytes, hit, pingpong, frag, page, order, mig>
 Â-v, --verbose     be more verbose (show symbol address, etc)
   Â--alloc      show per-allocation statistics
   Â--caller     Âshow per-callsite statistics
   Â--live      ÂShow live page stat
   Â--page      ÂAnalyze page allocator
   Â--raw-ip     Âshow raw ip instead of symbol
   Â--slab      ÂAnalyze slab allocator
   Â--time <str>   ÂTime span of interest (start,stop)
```
perf sched is similar in implementation and avoids the problem by
passing additional arguments to perf record. This change makes perf kmem
parse command line options consistently with perf sched, although
neither actually list that -o is a supported option.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/builtin-kmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 38a5ab683ebc..a50dae2c4ae9 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -1933,7 +1933,8 @@ int cmd_kmem(int argc, const char **argv)
return ret;

argc = parse_options_subcommand(argc, argv, kmem_options,
- kmem_subcommands, kmem_usage, 0);
+ kmem_subcommands, kmem_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);

if (!argc)
usage_with_options(kmem_usage, kmem_options);
--
2.27.0.383.g050319c2ae-goog