Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbbDCFJA (ORCPT ); Fri, 3 Apr 2015 01:09:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:43018 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbbDCFI5 (ORCPT ); Fri, 3 Apr 2015 01:08:57 -0400 Date: Thu, 2 Apr 2015 22:08:40 -0700 From: tip-bot for Yunlong Song Message-ID: Cc: wangnan0@huawei.com, tglx@linutronix.de, acme@redhat.com, a.p.zijlstra@chello.nl, hpa@zytor.com, paulus@samba.org, yunlong.song@huawei.com, mingo@kernel.org, linux-kernel@vger.kernel.org Reply-To: a.p.zijlstra@chello.nl, acme@redhat.com, wangnan0@huawei.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, paulus@samba.org, yunlong.song@huawei.com, hpa@zytor.com In-Reply-To: <1427982439-27388-4-git-send-email-yunlong.song@huawei.com> References: <1427982439-27388-4-git-send-email-yunlong.song@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf kmem: Support using -f to override perf.data file ownership Git-Commit-ID: d1eeb77c1811fd178442ccb8f58004a19ec40dd3 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: 3866 Lines: 107 Commit-ID: d1eeb77c1811fd178442ccb8f58004a19ec40dd3 Gitweb: http://git.kernel.org/tip/d1eeb77c1811fd178442ccb8f58004a19ec40dd3 Author: Yunlong Song AuthorDate: Thu, 2 Apr 2015 21:47:12 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 2 Apr 2015 13:18:46 -0300 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 [] {record|stat} -i, --input input file name -v, --verbose be more verbose (show symbol address, etc) --caller show per-callsite statistics --alloc show per-allocation statistics -s, --sort sort by keys: ptr, call_site, bytes, hit, pingpong, frag -l, --line 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 Tested-by: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1427982439-27388-4-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kmem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 64d3623..ac303ef 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) int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) { const char * const default_sort_order = "frag,hit,bytes"; + struct perf_data_file file = { + .path = input_name, + .mode = PERF_DATA_MODE_READ, + }; const struct option kmem_options[] = { OPT_STRING('i', "input", &input_name, "file", "input file name"), OPT_INCR('v', "verbose", &verbose, @@ -675,6 +679,7 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) parse_sort_opt), OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt), OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), + OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), OPT_END() }; 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) NULL }; struct perf_session *session; - struct perf_data_file file = { - .path = input_name, - .mode = PERF_DATA_MODE_READ, - }; int ret = -1; argc = parse_options_subcommand(argc, argv, kmem_options, -- 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/