aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-04-02 09:47:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-02 12:18:50 -0400
commit06af0f2c919d7c8f05efebe0d96a6f22297aafd4 (patch)
tree5fb70a5b2403bbae0f44619ce498a60b958f27c8
parent62a1a63a77451dee8fd318a5106ca108d6a8ebcb (diff)
perf script: Support using -f to override perf.data file ownership
Enable perf script to use perf.data when it is not owned by current user or root. Change the short option name of --fields to -F to avoid confusion with --force. Example: # perf record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 28360 Apr 2 14:53 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf script File perf.data not owned by current user or root (use -f to override) # perf script -f Error: switch `f' requires a value usage: perf script [<options>] or: perf script [<options>] record <script> [<record-options>] <command> or: perf script [<options>] report <script> [script-args] or: perf script [<options>] <script> [<record-options>] <command> or: perf script [<options>] <top-script> [script-args] -f, --fields <str> comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr,symoff,period As shown above, the -f option does not work at all. And -f is already taken up by --fields, which makes --force confused, so change the short option name of --fields to -F like what other perf commands do (e.g. perf report -F) and use -f as the short option name of --force. After this patch: # perf script File perf.data not owned by current user or root (use -f to override) # perf script -f :41298 41298 2590086.564226: 1 cycles: ffffffff8103efc6 native_write_msr_safe ([kernel.kallsyms]) :41298 41298 2590086.564244: 1 cycles: ffffffff8103efc6 native_write_msr_safe ([kernel.kallsyms]) :41298 41298 2590086.564249: 7 cycles: ffffffff8103efc6 native_write_msr_safe ([kernel.kallsyms]) :41298 41298 2590086.564255: 176 cycles: ffffffff8103efc6 native_write_msr_safe ([kernel.kallsyms]) ls 41298 2590086.567346: 4059 cycles: ffffffff8105a592 raise_softirq ([kernel.kallsyms]) ls 41298 2590086.567353: 3717 cycles: ffffffff8105a592 raise_softirq ([kernel.kallsyms]) ls 41298 2590086.567358: 63058 cycles: ffffffff8105a592 raise_softirq ([kernel.kallsyms]) ls 41298 2590086.567448: 1706255 cycles: 406ae0 [unknown] (/usr/bin/ls) 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-8-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-script.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 257dd066cb1a..58f10b8e6ff2 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1515,6 +1515,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1515 .ordering_requires_timestamps = true, 1515 .ordering_requires_timestamps = true,
1516 }, 1516 },
1517 }; 1517 };
1518 struct perf_data_file file = {
1519 .mode = PERF_DATA_MODE_READ,
1520 };
1518 const struct option options[] = { 1521 const struct option options[] = {
1519 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1522 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1520 "dump raw trace in ASCII"), 1523 "dump raw trace in ASCII"),
@@ -1542,7 +1545,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1542 "When printing symbols do not display call chain"), 1545 "When printing symbols do not display call chain"),
1543 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 1546 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
1544 "Look for files with symbols relative to this directory"), 1547 "Look for files with symbols relative to this directory"),
1545 OPT_CALLBACK('f', "fields", NULL, "str", 1548 OPT_CALLBACK('F', "fields", NULL, "str",
1546 "comma separated output fields prepend with 'type:'. " 1549 "comma separated output fields prepend with 'type:'. "
1547 "Valid types: hw,sw,trace,raw. " 1550 "Valid types: hw,sw,trace,raw. "
1548 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," 1551 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
@@ -1566,6 +1569,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1566 "Show the fork/comm/exit events"), 1569 "Show the fork/comm/exit events"),
1567 OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events, 1570 OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events,
1568 "Show the mmap events"), 1571 "Show the mmap events"),
1572 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
1569 OPT_END() 1573 OPT_END()
1570 }; 1574 };
1571 const char * const script_subcommands[] = { "record", "report", NULL }; 1575 const char * const script_subcommands[] = { "record", "report", NULL };
@@ -1577,9 +1581,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1577 "perf script [<options>] <top-script> [script-args]", 1581 "perf script [<options>] <top-script> [script-args]",
1578 NULL 1582 NULL
1579 }; 1583 };
1580 struct perf_data_file file = {
1581 .mode = PERF_DATA_MODE_READ,
1582 };
1583 1584
1584 setup_scripting(); 1585 setup_scripting();
1585 1586