diff options
author | Yunlong Song <yunlong.song@huawei.com> | 2015-04-02 09:47:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-02 12:18:51 -0400 |
commit | e366a6d8949f3cfab01906b42c591098d59f3f35 (patch) | |
tree | f6fd5c9cad1ae9cc91ed80ccddf33fcce673e7e8 | |
parent | 44f7e432e3dc8a13f5661e8b722f53645df083d1 (diff) |
perf trace: Support using -f to override perf.data file ownership
Enable perf trace to use perf.data when it is not owned by current user
or root.
Example:
# perf trace record ls
# chown Yunlong.Song:Yunlong.Song perf.data
# ls -al perf.data
-rw------- 1 Yunlong.Song Yunlong.Song 4153101 Apr 2 15:28 perf.data
# id
uid=0(root) gid=0(root) groups=0(root),64(pkcs11)
Before this patch:
# perf trace -i perf.data
File perf.data not owned by current user or root (use -f to override)
# perf trace -i perf.data -f
Error: unknown switch `f'
usage: perf trace [<options>] [<command>]
or: perf trace [<options>] -- <command> [<options>]
or: perf trace record [<options>] [<command>]
or: perf trace record [<options>] -- <command> [<options>]
--event <event> event selector. use 'perf list' to list
available events
--comm show the thread COMM next to its id
--tool_stats show tool stats
-e, --expr <expr> list of events to trace
-o, --output <file> output file name
-i, --input <file> Analyze events in file
-p, --pid <pid> trace events on existing process id
-t, --tid <tid> trace events on existing thread id
--filter-pids <float>
...
As shown above, the -f option does not work at all.
After this patch:
# perf trace -i perf.data
File perf.data not owned by current user or root (use -f to override)
# perf trace -i perf.data -f
0.056 ( 0.002 ms): ls/47325 brk( ...
0.108 ( 0.018 ms): ls/47325 mmap(len: 4096, prot: READ|WRITE, ...
0.145 ( 0.013 ms): ls/47325 access(filename: 0x7f31259a0eb0, ...
0.172 ( 0.008 ms): ls/47325 open(filename: 0x7fffeb9a0d00, ...
0.180 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00, ...
0.185 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00, ...
0.189 ( 0.003 ms): ls/47325 stat(filename: 0x7fffeb9a0d00, ...
0.195 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00, ...
0.199 ( 0.002 ms): ls/47325 stat(filename: 0x7fffeb9a0d00, ...
0.205 ( 0.004 ms): ls/47325 open(filename: 0x7fffeb9a0d00, ...
0.211 ( 0.004 ms): ls/47325 stat(filename: 0x7fffeb9a0d00, ...
0.220 ( 0.007 ms): ls/47325 open(filename: 0x7f312599e8ff, ...
...
...
As shown above, the -f option really works now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-10-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index bcc98ce3e5b8..e124741be187 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1254,6 +1254,7 @@ struct trace { | |||
1254 | bool show_comm; | 1254 | bool show_comm; |
1255 | bool show_tool_stats; | 1255 | bool show_tool_stats; |
1256 | bool trace_syscalls; | 1256 | bool trace_syscalls; |
1257 | bool force; | ||
1257 | int trace_pgfaults; | 1258 | int trace_pgfaults; |
1258 | }; | 1259 | }; |
1259 | 1260 | ||
@@ -2345,6 +2346,7 @@ static int trace__replay(struct trace *trace) | |||
2345 | struct perf_data_file file = { | 2346 | struct perf_data_file file = { |
2346 | .path = input_name, | 2347 | .path = input_name, |
2347 | .mode = PERF_DATA_MODE_READ, | 2348 | .mode = PERF_DATA_MODE_READ, |
2349 | .force = trace->force, | ||
2348 | }; | 2350 | }; |
2349 | struct perf_session *session; | 2351 | struct perf_session *session; |
2350 | struct perf_evsel *evsel; | 2352 | struct perf_evsel *evsel; |
@@ -2693,6 +2695,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2693 | OPT_CALLBACK_DEFAULT('F', "pf", &trace.trace_pgfaults, "all|maj|min", | 2695 | OPT_CALLBACK_DEFAULT('F', "pf", &trace.trace_pgfaults, "all|maj|min", |
2694 | "Trace pagefaults", parse_pagefaults, "maj"), | 2696 | "Trace pagefaults", parse_pagefaults, "maj"), |
2695 | OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), | 2697 | OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), |
2698 | OPT_BOOLEAN('f', "force", &trace.force, "don't complain, do it"), | ||
2696 | OPT_END() | 2699 | OPT_END() |
2697 | }; | 2700 | }; |
2698 | const char * const trace_subcommands[] = { "record", NULL }; | 2701 | const char * const trace_subcommands[] = { "record", NULL }; |