From: Yunlong Song <yunlong.song@huawei.com>
To: <a.p.zijlstra@chello.nl>, <paulus@samba.org>, <mingo@redhat.com>,
<acme@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <wangnan0@huawei.com>
Subject: [PATCH 04/10] perf tools: Support using -f to override perf.data.guest file ownership for kvm
Date: Thu, 2 Apr 2015 21:47:13 +0800 [thread overview]
Message-ID: <1427982439-27388-5-git-send-email-yunlong.song@huawei.com> (raw)
In-Reply-To: <1427982439-27388-1-git-send-email-yunlong.song@huawei.com>
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 [<options>]
--event <report event>
event for reporting: vmexit, mmio (x86 only),
ioport (x86 only)
--vcpu <n> vcpu id to report
-k, --key <sort-key> key for sorting: sample(sort by samples
number) time (sort by avg time)
-p, --pid <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 <yunlong.song@huawei.com>
---
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 {
--
1.8.5.2
next prev parent reply other threads:[~2015-04-02 13:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 13:47 [PATCH 00/10] perf tools: Support using -f to override file ownership for perf commands Yunlong Song
2015-04-02 13:47 ` [PATCH 01/10] perf tools: Support using -f to override perf.data file ownership for evlist Yunlong Song
2015-04-03 5:08 ` [tip:perf/core] perf evlist: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 02/10] perf tools: Support using -f to override perf.data file ownership for inject Yunlong Song
2015-04-03 5:08 ` [tip:perf/core] perf inject: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 03/10] perf tools: Support using -f to override perf.data file ownership for kmem Yunlong Song
2015-04-03 5:08 ` [tip:perf/core] perf kmem: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` Yunlong Song [this message]
2015-04-03 5:08 ` [tip:perf/core] perf kvm: Support using -f to override perf.data.guest " tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 05/10] perf tools: Support using -f to override perf.data file ownership for lock Yunlong Song
2015-04-03 5:09 ` [tip:perf/core] perf lock: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 06/10] perf tools: Support using -f to override perf.data file ownership for mem Yunlong Song
2015-04-03 5:09 ` [tip:perf/core] perf mem: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 07/10] perf tools: Support using -f to override perf.data file ownership for script Yunlong Song
2015-04-03 5:09 ` [tip:perf/core] perf script: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 08/10] perf tools: Support using -f to override perf.data file ownership for timechart Yunlong Song
2015-04-03 5:10 ` [tip:perf/core] perf timechart: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 09/10] perf tools: Support using -f to override perf.data file ownership for trace Yunlong Song
2015-04-03 5:10 ` [tip:perf/core] perf trace: Support using -f to override perf.data file ownership tip-bot for Yunlong Song
2015-04-02 13:47 ` [PATCH 10/10] perf tools: Support using -f to override perf.data file ownership for data convert Yunlong Song
2015-04-03 5:10 ` [tip:perf/core] perf data: Support using -f to override perf.data file ownership for 'convert' tip-bot for Yunlong Song
2015-04-02 15:13 ` [PATCH 00/10] perf tools: Support using -f to override file ownership for perf commands Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427982439-27388-5-git-send-email-yunlong.song@huawei.com \
--to=yunlong.song@huawei.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).