diff options
author | Yunlong Song <yunlong.song@huawei.com> | 2015-04-02 09:47:13 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-02 12:18:47 -0400 |
commit | 8cc5ec1f754355ed788838390e86389c9ffb7590 (patch) | |
tree | eb7bff5803b6684b2c12574f16e7bc133bb27cd6 /tools/perf | |
parent | d1eeb77c1811fd178442ccb8f58004a19ec40dd3 (diff) |
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 [<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>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1427982439-27388-5-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-kvm.c | 2 | ||||
-rw-r--r-- | tools/perf/util/kvm-stat.h | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 643722f40075..1f9338f6109c 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) | |||
1047 | struct perf_data_file file = { | 1047 | struct perf_data_file file = { |
1048 | .path = kvm->file_name, | 1048 | .path = kvm->file_name, |
1049 | .mode = PERF_DATA_MODE_READ, | 1049 | .mode = PERF_DATA_MODE_READ, |
1050 | .force = kvm->force, | ||
1050 | }; | 1051 | }; |
1051 | 1052 | ||
1052 | kvm->tool = eops; | 1053 | kvm->tool = eops; |
@@ -1204,6 +1205,7 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv) | |||
1204 | " time (sort by avg time)"), | 1205 | " time (sort by avg time)"), |
1205 | OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid", | 1206 | OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid", |
1206 | "analyze events only for given process id(s)"), | 1207 | "analyze events only for given process id(s)"), |
1208 | OPT_BOOLEAN('f', "force", &kvm->force, "don't complain, do it"), | ||
1207 | OPT_END() | 1209 | OPT_END() |
1208 | }; | 1210 | }; |
1209 | 1211 | ||
diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index cf1d7913783b..ae825d4ec110 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h | |||
@@ -99,6 +99,7 @@ struct perf_kvm_stat { | |||
99 | int timerfd; | 99 | int timerfd; |
100 | unsigned int display_time; | 100 | unsigned int display_time; |
101 | bool live; | 101 | bool live; |
102 | bool force; | ||
102 | }; | 103 | }; |
103 | 104 | ||
104 | struct kvm_reg_events_ops { | 105 | struct kvm_reg_events_ops { |