aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2015-04-02 09:47:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-04-02 12:18:49 -0400
commit62a1a63a77451dee8fd318a5106ca108d6a8ebcb (patch)
treecd5a863d31bf195d5446158e64f199b02a2744dd /tools/perf
parentc4ac732a0377d1544a8385393a9877b693ff0652 (diff)
perf mem: Support using -f to override perf.data file ownership
Enable perf mem to use perf.data when it is not owned by current user or root. Example: # perf mem -t load record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 16392 Apr 2 14:34 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf mem -D report File perf.data not owned by current user or root (use -f to override) # perf mem -D -f report Error: unknown switch `f' usage: perf mem [<options>] {record|report} -t, --type <type> memory operations(load,store) Default load,store -D, --dump-raw-samples dump raw samples in ASCII -U, --hide-unresolved Only display entries resolved to a symbol -i, --input <file> input file name -C, --cpu <cpu> list of cpus to profile -x, --field-separator <separator> separator for columns, no spaces will be added between columns '.' is reserved. As shown above, the -f option does not work at all. After this patch: # perf mem -D report File perf.data not owned by current user or root (use -f to override) # perf mem -D -f report # PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL 39095 39095 0xffffffff81127e40 0x016ffff887f45148338 8 0x68100142 /proc/kcore:perf_event_aux 39095 39095 0xffffffff8100a3fe 0xffff89007f8cb7d0 6 0x68100142 /proc/kcore:native_sched_clock 39095 39095 0xffffffff81309139 0xffff88bf44c9ded8 6 0x68100142 /proc/kcore:acpi_map_lookup 39095 39095 0xffffffff810f8c4c 0xffff89007f8ccd88 6 0x68100142 /proc/kcore:rcu_nmi_exit 39095 39095 0xffffffff81136346 0xffff88fea995dd50 6 0x68100142 /proc/kcore:unlock_page 39095 39095 0xffffffff812a64a2 0xffff88fea995dcc8 6 0x68100142 /proc/kcore:half_md4_transform 39095 39095 0x7f0cf877c7e9 0x25dfb94 6 0x68100142 /lib64/libc-2.19.so:__readdir64 39095 39095 0x7f0cf87575a3 0x7f0cf9163731 6 0x68100142 /lib64/libc-2.19.so:__strcoll_l 39095 39095 0xffffffff8116910e 0xffffea01c1bfbd50 23 0x68100242 /proc/kcore:page_remove_rmap 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-7-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-mem.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index b4dcf0bfc029..675216e08bfc 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -15,6 +15,7 @@ struct perf_mem {
15 char const *input_name; 15 char const *input_name;
16 bool hide_unresolved; 16 bool hide_unresolved;
17 bool dump_raw; 17 bool dump_raw;
18 bool force;
18 int operation; 19 int operation;
19 const char *cpu_list; 20 const char *cpu_list;
20 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 21 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -120,6 +121,7 @@ static int report_raw_events(struct perf_mem *mem)
120 struct perf_data_file file = { 121 struct perf_data_file file = {
121 .path = input_name, 122 .path = input_name,
122 .mode = PERF_DATA_MODE_READ, 123 .mode = PERF_DATA_MODE_READ,
124 .force = mem->force,
123 }; 125 };
124 int err = -EINVAL; 126 int err = -EINVAL;
125 int ret; 127 int ret;
@@ -290,6 +292,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
290 "separator", 292 "separator",
291 "separator for columns, no spaces will be added" 293 "separator for columns, no spaces will be added"
292 " between columns '.' is reserved."), 294 " between columns '.' is reserved."),
295 OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"),
293 OPT_END() 296 OPT_END()
294 }; 297 };
295 const char *const mem_subcommands[] = { "record", "report", NULL }; 298 const char *const mem_subcommands[] = { "record", "report", NULL };