Commit 2e73f00f authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo

perf kvm stat report: Add option to analyze specific VM

Add an option to analyze a specific VM within a data file. This allows
the collection of kvm events for all VMs and then analyze data for each
VM (or set of VMs) individually.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Reviewed-by: default avatarXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1375753297-69645-6-git-send-email-dsahern@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 62d04dbf
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "util/thread.h" #include "util/thread.h"
#include "util/header.h" #include "util/header.h"
#include "util/session.h" #include "util/session.h"
#include "util/intlist.h"
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/trace-event.h" #include "util/trace-event.h"
#include "util/debug.h" #include "util/debug.h"
...@@ -107,6 +107,9 @@ struct perf_kvm_stat { ...@@ -107,6 +107,9 @@ struct perf_kvm_stat {
u64 total_count; u64 total_count;
u64 lost_events; u64 lost_events;
const char *pid_str;
struct intlist *pid_list;
struct rb_root result; struct rb_root result;
int timerfd; int timerfd;
...@@ -777,16 +780,29 @@ static int process_lost_event(struct perf_tool *tool, ...@@ -777,16 +780,29 @@ static int process_lost_event(struct perf_tool *tool,
return 0; return 0;
} }
static bool skip_sample(struct perf_kvm_stat *kvm,
struct perf_sample *sample)
{
if (kvm->pid_list && intlist__find(kvm->pid_list, sample->pid) == NULL)
return true;
return false;
}
static int process_sample_event(struct perf_tool *tool, static int process_sample_event(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine) struct machine *machine)
{ {
struct thread *thread = machine__findnew_thread(machine, sample->tid); struct thread *thread;
struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat, struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat,
tool); tool);
if (skip_sample(kvm, sample))
return 0;
thread = machine__findnew_thread(machine, sample->tid);
if (thread == NULL) { if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n", pr_debug("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
...@@ -1209,11 +1225,27 @@ static int read_events(struct perf_kvm_stat *kvm) ...@@ -1209,11 +1225,27 @@ static int read_events(struct perf_kvm_stat *kvm)
return perf_session__process_events(kvm->session, &kvm->tool); return perf_session__process_events(kvm->session, &kvm->tool);
} }
static int parse_target_str(struct perf_kvm_stat *kvm)
{
if (kvm->pid_str) {
kvm->pid_list = intlist__new(kvm->pid_str);
if (kvm->pid_list == NULL) {
pr_err("Error parsing process id string\n");
return -EINVAL;
}
}
return 0;
}
static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm) static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm)
{ {
int ret = -EINVAL; int ret = -EINVAL;
int vcpu = kvm->trace_vcpu; int vcpu = kvm->trace_vcpu;
if (parse_target_str(kvm) != 0)
goto exit;
if (!verify_vcpu(vcpu)) if (!verify_vcpu(vcpu))
goto exit; goto exit;
...@@ -1300,6 +1332,8 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv) ...@@ -1300,6 +1332,8 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
OPT_STRING('k', "key", &kvm->sort_key, "sort-key", OPT_STRING('k', "key", &kvm->sort_key, "sort-key",
"key for sorting: sample(sort by samples number)" "key for sorting: sample(sort by samples number)"
" time (sort by avg time)"), " time (sort by avg time)"),
OPT_STRING('p', "pid", &kvm->pid_str, "pid",
"analyze events only for given process id(s)"),
OPT_END() OPT_END()
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment