aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-04-02 09:47:12 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-02 12:18:46 -0400
commitd1eeb77c1811fd178442ccb8f58004a19ec40dd3 (patch)
treea30d6ff25aa2b6d6cd681f40927e5bdf4a9c7b7a
parentccaa474c8a0983d26ecb3eac755672b546b997c3 (diff)
perf kmem: Support using -f to override perf.data file ownership
Enable perf kmem to use perf.data when it is not owned by current user or root. Example: # perf kmem record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 5315665 Apr 2 10:54 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf kmem stat File perf.data not owned by current user or root (use -f to override) # perf kmem stat -f Error: unknown switch `f' usage: perf kmem [<options>] {record|stat} -i, --input <file> input file name -v, --verbose be more verbose (show symbol address, etc) --caller show per-callsite statistics --alloc show per-allocation statistics -s, --sort <key[,key2...]> sort by keys: ptr, call_site, bytes, hit, pingpong, frag -l, --line <num> show n lines --raw-ip show raw ip instead of symbol As shown above, the -f option does not work at all. After this patch: # perf kmem stat File perf.data not owned by current user or root (use -f to override) # perf kmem stat -f SUMMARY ======= Total bytes requested: 437599 Total bytes allocated: 615472 Total bytes wasted on internal fragmentation: 177873 Internal fragmentation: 28.900259% Cross CPU allocations: 6/1192 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-4-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-kmem.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 64d3623d45a0..ac303ef9f2f0 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -662,6 +662,10 @@ static int __cmd_record(int argc, const char **argv)
662int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) 662int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
663{ 663{
664 const char * const default_sort_order = "frag,hit,bytes"; 664 const char * const default_sort_order = "frag,hit,bytes";
665 struct perf_data_file file = {
666 .path = input_name,
667 .mode = PERF_DATA_MODE_READ,
668 };
665 const struct option kmem_options[] = { 669 const struct option kmem_options[] = {
666 OPT_STRING('i', "input", &input_name, "file", "input file name"), 670 OPT_STRING('i', "input", &input_name, "file", "input file name"),
667 OPT_INCR('v', "verbose", &verbose, 671 OPT_INCR('v', "verbose", &verbose,
@@ -675,6 +679,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
675 parse_sort_opt), 679 parse_sort_opt),
676 OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt), 680 OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt),
677 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), 681 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
682 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
678 OPT_END() 683 OPT_END()
679 }; 684 };
680 const char *const kmem_subcommands[] = { "record", "stat", NULL }; 685 const char *const kmem_subcommands[] = { "record", "stat", NULL };
@@ -683,10 +688,6 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
683 NULL 688 NULL
684 }; 689 };
685 struct perf_session *session; 690 struct perf_session *session;
686 struct perf_data_file file = {
687 .path = input_name,
688 .mode = PERF_DATA_MODE_READ,
689 };
690 int ret = -1; 691 int ret = -1;
691 692
692 argc = parse_options_subcommand(argc, argv, kmem_options, 693 argc = parse_options_subcommand(argc, argv, kmem_options,