Commit 1aed2671738785e8f5aea663a6fda91aa7ef59b5

Authored by Joerg Roedel
Committed by Arnaldo Carvalho de Melo
1 parent df25f989a4

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>

Showing 5 changed files with 26 additions and 5 deletions Side-by-side Diff

tools/perf/builtin-kvm.c
... ... @@ -22,9 +22,6 @@
22 22 static const char *file_name;
23 23 static char name_buffer[256];
24 24  
25   -bool perf_host = 1;
26   -bool perf_guest;
27   -
28 25 static const char * const kvm_usage[] = {
29 26 "perf kvm [<options>] {top|record|report|diff|buildid-list}",
30 27 NULL
... ... @@ -107,7 +104,8 @@
107 104  
108 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 110 argc = parse_options(argc, argv, kvm_options, kvm_usage,
113 111 PARSE_OPT_STOP_AT_NON_OPTION);
tools/perf/util/evlist.c
... ... @@ -111,8 +111,11 @@
111 111 .type = PERF_TYPE_HARDWARE,
112 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 115  
  116 + event_attr_init(&attr);
  117 +
  118 + evsel = perf_evsel__new(&attr, 0);
116 119 if (evsel == NULL)
117 120 goto error;
118 121  
tools/perf/util/parse-events.c
... ... @@ -838,6 +838,7 @@
838 838 for (;;) {
839 839 ostr = str;
840 840 memset(&attr, 0, sizeof(attr));
  841 + event_attr_init(&attr);
841 842 ret = parse_event_symbols(evlist, &str, &attr);
842 843 if (ret == EVT_FAILED)
843 844 return -1;
tools/perf/util/util.c
  1 +#include "../perf.h"
1 2 #include "util.h"
2 3 #include <sys/mman.h>
  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 +}
3 18  
4 19 int mkdir_p(char *path, mode_t mode)
5 20 {
tools/perf/util/util.h
... ... @@ -242,6 +242,10 @@
242 242 unsigned long convert_unit(unsigned long value, char *unit);
243 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 249 #define _STR(x) #x
246 250 #define STR(x) _STR(x)
247 251