Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174AbbDCFKs (ORCPT ); Fri, 3 Apr 2015 01:10:48 -0400 Received: from terminus.zytor.com ([198.137.202.10]:43102 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752393AbbDCFKn (ORCPT ); Fri, 3 Apr 2015 01:10:43 -0400 Date: Thu, 2 Apr 2015 22:10:25 -0700 From: tip-bot for Yunlong Song Message-ID: Cc: mingo@kernel.org, paulus@samba.org, wangnan0@huawei.com, tglx@linutronix.de, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com, yunlong.song@huawei.com Reply-To: mingo@kernel.org, paulus@samba.org, wangnan0@huawei.com, tglx@linutronix.de, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com, yunlong.song@huawei.com In-Reply-To: <1427982439-27388-10-git-send-email-yunlong.song@huawei.com> References: <1427982439-27388-10-git-send-email-yunlong.song@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf trace: Support using -f to override perf.data file ownership Git-Commit-ID: e366a6d8949f3cfab01906b42c591098d59f3f35 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4409 Lines: 113 Commit-ID: e366a6d8949f3cfab01906b42c591098d59f3f35 Gitweb: http://git.kernel.org/tip/e366a6d8949f3cfab01906b42c591098d59f3f35 Author: Yunlong Song AuthorDate: Thu, 2 Apr 2015 21:47:18 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 2 Apr 2015 13:18:51 -0300 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 [] [] or: perf trace [] -- [] or: perf trace record [] [] or: perf trace record [] -- [] --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 list of events to trace -o, --output output file name -i, --input Analyze events in file -p, --pid trace events on existing process id -t, --tid trace events on existing thread id --filter-pids ... 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 Tested-by: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1427982439-27388-10-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index bcc98ce..e124741 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1254,6 +1254,7 @@ struct trace { bool show_comm; bool show_tool_stats; bool trace_syscalls; + bool force; int trace_pgfaults; }; @@ -2345,6 +2346,7 @@ static int trace__replay(struct trace *trace) struct perf_data_file file = { .path = input_name, .mode = PERF_DATA_MODE_READ, + .force = trace->force, }; struct perf_session *session; struct perf_evsel *evsel; @@ -2693,6 +2695,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) OPT_CALLBACK_DEFAULT('F', "pf", &trace.trace_pgfaults, "all|maj|min", "Trace pagefaults", parse_pagefaults, "maj"), OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), + OPT_BOOLEAN('f', "force", &trace.force, "don't complain, do it"), OPT_END() }; const char * const trace_subcommands[] = { "record", NULL }; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/