Commit 65c647a6 authored by Alexander Yarygin's avatar Alexander Yarygin Committed by Arnaldo Carvalho de Melo

perf kvm: Refactoring of cpu_isa_config()

cpu_isa_config() does two different things: searching for cpuid and
initializing perf_kvm_stat struct with proper parameters.

Let's move initialization to a separate function cpu_isa_init(), which
is used to initialize all possible ISAs and can be used to init
arch-depended things.
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarAlexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1404395992-17095-4-git-send-email-yarygin@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent df74c13b
...@@ -835,36 +835,45 @@ static int process_sample_event(struct perf_tool *tool, ...@@ -835,36 +835,45 @@ static int process_sample_event(struct perf_tool *tool,
return 0; return 0;
} }
static int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
{
if (strstr(cpuid, "Intel")) {
kvm->exit_reasons = vmx_exit_reasons;
kvm->exit_reasons_isa = "VMX";
} else if (strstr(cpuid, "AMD")) {
kvm->exit_reasons = svm_exit_reasons;
kvm->exit_reasons_isa = "SVM";
} else
return -ENOTSUP;
return 0;
}
static int cpu_isa_config(struct perf_kvm_stat *kvm) static int cpu_isa_config(struct perf_kvm_stat *kvm)
{ {
char buf[64], *cpuid; char buf[64], *cpuid;
int err, isa; int err;
if (kvm->live) { if (kvm->live) {
err = get_cpuid(buf, sizeof(buf)); err = get_cpuid(buf, sizeof(buf));
if (err != 0) { if (err != 0) {
pr_err("Failed to look up CPU type (Intel or AMD)\n"); pr_err("Failed to look up CPU type\n");
return err; return err;
} }
cpuid = buf; cpuid = buf;
} else } else
cpuid = kvm->session->header.env.cpuid; cpuid = kvm->session->header.env.cpuid;
if (strstr(cpuid, "Intel")) if (!cpuid) {
isa = 1; pr_err("Failed to look up CPU type\n");
else if (strstr(cpuid, "AMD")) return -EINVAL;
isa = 0;
else {
pr_err("CPU %s is not supported.\n", cpuid);
return -ENOTSUP;
} }
if (isa == 1) { err = cpu_isa_init(kvm, cpuid);
kvm->exit_reasons = vmx_exit_reasons; if (err == -ENOTSUP)
kvm->exit_reasons_isa = "VMX"; pr_err("CPU %s is not supported.\n", cpuid);
}
return 0; return err;
} }
static bool verify_vcpu(int vcpu) static bool verify_vcpu(int vcpu)
...@@ -1583,8 +1592,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv) ...@@ -1583,8 +1592,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
.report_event = "vmexit", .report_event = "vmexit",
.sort_key = "sample", .sort_key = "sample",
.exit_reasons = svm_exit_reasons,
.exit_reasons_isa = "SVM",
}; };
if (argc == 1) { if (argc == 1) {
......
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