Skip to content

Commit

Permalink
perf kvm: Do guest-only counting by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joerg Roedel authored and Arnaldo Carvalho de Melo committed Jan 6, 2012
1 parent df25f98 commit 1aed267
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
6 changes: 2 additions & 4 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
static const char *file_name;
static char name_buffer[256];

bool perf_host = 1;
bool perf_guest;

static const char * const kvm_usage[] = {
"perf kvm [<options>] {top|record|report|diff|buildid-list}",
NULL
Expand Down Expand Up @@ -107,7 +104,8 @@ static int __cmd_buildid_list(int argc, const char **argv)

int cmd_kvm(int argc, const char **argv, const char *prefix __used)
{
perf_host = perf_guest = 0;
perf_host = 0;
perf_guest = 1;

argc = parse_options(argc, argv, kvm_options, kvm_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
Expand Down
5 changes: 4 additions & 1 deletion tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
.type = PERF_TYPE_HARDWARE,
.config = PERF_COUNT_HW_CPU_CYCLES,
};
struct perf_evsel *evsel = perf_evsel__new(&attr, 0);
struct perf_evsel *evsel;

event_attr_init(&attr);

evsel = perf_evsel__new(&attr, 0);
if (evsel == NULL)
goto error;

Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ int parse_events(struct perf_evlist *evlist , const char *str, int unset __used)
for (;;) {
ostr = str;
memset(&attr, 0, sizeof(attr));
event_attr_init(&attr);
ret = parse_event_symbols(evlist, &str, &attr);
if (ret == EVT_FAILED)
return -1;
Expand Down
15 changes: 15 additions & 0 deletions tools/perf/util/util.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#include "../perf.h"
#include "util.h"
#include <sys/mman.h>

/*
* XXX We need to find a better place for these things...
*/
bool perf_host = true;
bool perf_guest = true;

void event_attr_init(struct perf_event_attr *attr)
{
if (!perf_host)
attr->exclude_host = 1;
if (!perf_guest)
attr->exclude_guest = 1;
}

int mkdir_p(char *path, mode_t mode)
{
struct stat st;
Expand Down
4 changes: 4 additions & 0 deletions tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ int strtailcmp(const char *s1, const char *s2);
unsigned long convert_unit(unsigned long value, char *unit);
int readn(int fd, void *buf, size_t size);

struct perf_event_attr;

void event_attr_init(struct perf_event_attr *attr);

#define _STR(x) #x
#define STR(x) _STR(x)

Expand Down

0 comments on commit 1aed267

Please sign in to comment.