diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2012-01-04 11:54:20 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-01-06 12:47:37 -0500 |
commit | 1aed2671738785e8f5aea663a6fda91aa7ef59b5 (patch) | |
tree | c28239bcbdc3b86278cceb27e2b33187c81ac20e /tools/perf | |
parent | df25f989a4390ca0dbc9cb24516d4b10c01ceda8 (diff) |
perf kvm: Do guest-only counting by default
Make use of exclude_guest and exlude_host in perf-kvm to do only
guest-only counting by default.
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
[ committer note: Moved perf_{guest,host} & event_attr_init to util.c ]
[ so as not to drag more stuff to the python binding]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-kvm.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 5 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 1 | ||||
-rw-r--r-- | tools/perf/util/util.c | 15 | ||||
-rw-r--r-- | tools/perf/util/util.h | 4 |
5 files changed, 26 insertions, 5 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 032324a76b87..9fc6e0fa3dce 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -22,9 +22,6 @@ | |||
22 | static const char *file_name; | 22 | static const char *file_name; |
23 | static char name_buffer[256]; | 23 | static char name_buffer[256]; |
24 | 24 | ||
25 | bool perf_host = 1; | ||
26 | bool perf_guest; | ||
27 | |||
28 | static const char * const kvm_usage[] = { | 25 | static const char * const kvm_usage[] = { |
29 | "perf kvm [<options>] {top|record|report|diff|buildid-list}", | 26 | "perf kvm [<options>] {top|record|report|diff|buildid-list}", |
30 | NULL | 27 | NULL |
@@ -107,7 +104,8 @@ static int __cmd_buildid_list(int argc, const char **argv) | |||
107 | 104 | ||
108 | int cmd_kvm(int argc, const char **argv, const char *prefix __used) | 105 | int cmd_kvm(int argc, const char **argv, const char *prefix __used) |
109 | { | 106 | { |
110 | perf_host = perf_guest = 0; | 107 | perf_host = 0; |
108 | perf_guest = 1; | ||
111 | 109 | ||
112 | argc = parse_options(argc, argv, kvm_options, kvm_usage, | 110 | argc = parse_options(argc, argv, kvm_options, kvm_usage, |
113 | PARSE_OPT_STOP_AT_NON_OPTION); | 111 | PARSE_OPT_STOP_AT_NON_OPTION); |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index fa1837088ca8..3f16e08a5c8d 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -111,8 +111,11 @@ int perf_evlist__add_default(struct perf_evlist *evlist) | |||
111 | .type = PERF_TYPE_HARDWARE, | 111 | .type = PERF_TYPE_HARDWARE, |
112 | .config = PERF_COUNT_HW_CPU_CYCLES, | 112 | .config = PERF_COUNT_HW_CPU_CYCLES, |
113 | }; | 113 | }; |
114 | struct perf_evsel *evsel = perf_evsel__new(&attr, 0); | 114 | struct perf_evsel *evsel; |
115 | |||
116 | event_attr_init(&attr); | ||
115 | 117 | ||
118 | evsel = perf_evsel__new(&attr, 0); | ||
116 | if (evsel == NULL) | 119 | if (evsel == NULL) |
117 | goto error; | 120 | goto error; |
118 | 121 | ||
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 531c283fc0c5..dcf999c766b1 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -838,6 +838,7 @@ int parse_events(struct perf_evlist *evlist , const char *str, int unset __used) | |||
838 | for (;;) { | 838 | for (;;) { |
839 | ostr = str; | 839 | ostr = str; |
840 | memset(&attr, 0, sizeof(attr)); | 840 | memset(&attr, 0, sizeof(attr)); |
841 | event_attr_init(&attr); | ||
841 | ret = parse_event_symbols(evlist, &str, &attr); | 842 | ret = parse_event_symbols(evlist, &str, &attr); |
842 | if (ret == EVT_FAILED) | 843 | if (ret == EVT_FAILED) |
843 | return -1; | 844 | return -1; |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 5b3ea49aa63e..813141047fc2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -1,6 +1,21 @@ | |||
1 | #include "../perf.h" | ||
1 | #include "util.h" | 2 | #include "util.h" |
2 | #include <sys/mman.h> | 3 | #include <sys/mman.h> |
3 | 4 | ||
5 | /* | ||
6 | * XXX We need to find a better place for these things... | ||
7 | */ | ||
8 | bool perf_host = true; | ||
9 | bool perf_guest = true; | ||
10 | |||
11 | void event_attr_init(struct perf_event_attr *attr) | ||
12 | { | ||
13 | if (!perf_host) | ||
14 | attr->exclude_host = 1; | ||
15 | if (!perf_guest) | ||
16 | attr->exclude_guest = 1; | ||
17 | } | ||
18 | |||
4 | int mkdir_p(char *path, mode_t mode) | 19 | int mkdir_p(char *path, mode_t mode) |
5 | { | 20 | { |
6 | struct stat st; | 21 | struct stat st; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 37be34dff798..b9c530cce79a 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -242,6 +242,10 @@ int strtailcmp(const char *s1, const char *s2); | |||
242 | unsigned long convert_unit(unsigned long value, char *unit); | 242 | unsigned long convert_unit(unsigned long value, char *unit); |
243 | int readn(int fd, void *buf, size_t size); | 243 | int readn(int fd, void *buf, size_t size); |
244 | 244 | ||
245 | struct perf_event_attr; | ||
246 | |||
247 | void event_attr_init(struct perf_event_attr *attr); | ||
248 | |||
245 | #define _STR(x) #x | 249 | #define _STR(x) #x |
246 | #define STR(x) _STR(x) | 250 | #define STR(x) _STR(x) |
247 | 251 | ||