From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753580AbbDBNrB (ORCPT ); Thu, 2 Apr 2015 09:47:01 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:10319 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753066AbbDBNoz (ORCPT ); Thu, 2 Apr 2015 09:44:55 -0400 From: Yunlong Song To: , , , CC: , Subject: [PATCH 06/10] perf tools: Support using -f to override perf.data file ownership for mem Date: Thu, 2 Apr 2015 21:47:15 +0800 Message-ID: <1427982439-27388-7-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1427982439-27388-1-git-send-email-yunlong.song@huawei.com> References: <1427982439-27388-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.110.52.30] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.551D47D3.028E,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 23f1463a61130b7d4e5b8ab2061b138f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 [] {record|report} -t, --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 input file name -C, --cpu list of cpus to profile -x, --field-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 --- tools/perf/builtin-mem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index b4dcf0b..675216e 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -15,6 +15,7 @@ struct perf_mem { char const *input_name; bool hide_unresolved; bool dump_raw; + bool force; int operation; const char *cpu_list; DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); @@ -120,6 +121,7 @@ static int report_raw_events(struct perf_mem *mem) struct perf_data_file file = { .path = input_name, .mode = PERF_DATA_MODE_READ, + .force = mem->force, }; int err = -EINVAL; int ret; @@ -290,6 +292,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) "separator", "separator for columns, no spaces will be added" " between columns '.' is reserved."), + OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"), OPT_END() }; const char *const mem_subcommands[] = { "record", "report", NULL }; -- 1.8.5.2