Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752889AbbDCFJR (ORCPT ); Fri, 3 Apr 2015 01:09:17 -0400 Received: from terminus.zytor.com ([198.137.202.10]:43035 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbbDCFJP (ORCPT ); Fri, 3 Apr 2015 01:09:15 -0400 Date: Thu, 2 Apr 2015 22:08:58 -0700 From: tip-bot for Yunlong Song Message-ID: Cc: tglx@linutronix.de, acme@redhat.com, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, wangnan0@huawei.com, mingo@kernel.org, paulus@samba.org, yunlong.song@huawei.com, hpa@zytor.com Reply-To: a.p.zijlstra@chello.nl, tglx@linutronix.de, acme@redhat.com, mingo@kernel.org, paulus@samba.org, linux-kernel@vger.kernel.org, wangnan0@huawei.com, yunlong.song@huawei.com, hpa@zytor.com In-Reply-To: <1427982439-27388-5-git-send-email-yunlong.song@huawei.com> References: <1427982439-27388-5-git-send-email-yunlong.song@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf kvm: Support using -f to override perf.data.guest file ownership Git-Commit-ID: 8cc5ec1f754355ed788838390e86389c9ffb7590 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: 3643 Lines: 105 Commit-ID: 8cc5ec1f754355ed788838390e86389c9ffb7590 Gitweb: http://git.kernel.org/tip/8cc5ec1f754355ed788838390e86389c9ffb7590 Author: Yunlong Song AuthorDate: Thu, 2 Apr 2015 21:47:13 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 2 Apr 2015 13:18:47 -0300 perf kvm: Support using -f to override perf.data.guest file ownership Enable perf kvm to use perf.data.guest when it is not owned by current user or root. Example: # perf kvm stat record ls # chown Yunlong.Song:Yunlong.Song perf.data.guest # ls -al perf.data.guest -rw------- 1 Yunlong.Song Yunlong.Song 4128937 Apr 2 11:05 perf.data.guest # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf kvm stat report File perf.data.guest not owned by current user or root (use -f to override) Initializing perf session failed # perf kvm stat report -f Error: unknown switch `f' usage: perf kvm stat report [] --event event for reporting: vmexit, mmio (x86 only), ioport (x86 only) --vcpu vcpu id to report -k, --key key for sorting: sample(sort by samples number) time (sort by avg time) -p, --pid analyze events only for given process id(s) As shown above, the -f option does not work at all. After this patch: # perf kvm stat report File perf.data.guest not owned by current user or root (use -f to override) Initializing perf session failed # perf kvm stat report -f Analyze events for all VMs, all VCPUs: VM-EXIT Samples Samples% Time% Min Time Max Time Avg time Total Samples:0, Total events handled time:0.00us. As shown above, the -f option really works now. Since we have not launched any KVM related process, the result shows 0 sample here. 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-5-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kvm.c | 2 ++ tools/perf/util/kvm-stat.h | 1 + 2 files changed, 3 insertions(+) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 643722f..1f9338f 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1047,6 +1047,7 @@ static int read_events(struct perf_kvm_stat *kvm) struct perf_data_file file = { .path = kvm->file_name, .mode = PERF_DATA_MODE_READ, + .force = kvm->force, }; kvm->tool = eops; @@ -1204,6 +1205,7 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv) " time (sort by avg time)"), OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid", "analyze events only for given process id(s)"), + OPT_BOOLEAN('f', "force", &kvm->force, "don't complain, do it"), OPT_END() }; diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index cf1d7913..ae825d4 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -99,6 +99,7 @@ struct perf_kvm_stat { int timerfd; unsigned int display_time; bool live; + bool force; }; struct kvm_reg_events_ops { -- 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/