diff options
author | Alexander Yarygin <yarygin@linux.vnet.ibm.com> | 2014-07-03 09:59:51 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-07 15:55:24 -0400 |
commit | 65c647a65c155e69bd5765d5e454982566ac1c62 (patch) | |
tree | 0d4a0ca79c4c0965e10e767cbc01f7e9f0a0736e /tools/perf | |
parent | df74c13b6c53c97576652f7b2840764ad7d5f949 (diff) |
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: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: Christian 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-kvm.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 75f354459005..41dbeaf8cc11 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -835,36 +835,45 @@ static int process_sample_event(struct perf_tool *tool, | |||
835 | return 0; | 835 | return 0; |
836 | } | 836 | } |
837 | 837 | ||
838 | static int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid) | ||
839 | { | ||
840 | if (strstr(cpuid, "Intel")) { | ||
841 | kvm->exit_reasons = vmx_exit_reasons; | ||
842 | kvm->exit_reasons_isa = "VMX"; | ||
843 | } else if (strstr(cpuid, "AMD")) { | ||
844 | kvm->exit_reasons = svm_exit_reasons; | ||
845 | kvm->exit_reasons_isa = "SVM"; | ||
846 | } else | ||
847 | return -ENOTSUP; | ||
848 | |||
849 | return 0; | ||
850 | } | ||
851 | |||
838 | static int cpu_isa_config(struct perf_kvm_stat *kvm) | 852 | static int cpu_isa_config(struct perf_kvm_stat *kvm) |
839 | { | 853 | { |
840 | char buf[64], *cpuid; | 854 | char buf[64], *cpuid; |
841 | int err, isa; | 855 | int err; |
842 | 856 | ||
843 | if (kvm->live) { | 857 | if (kvm->live) { |
844 | err = get_cpuid(buf, sizeof(buf)); | 858 | err = get_cpuid(buf, sizeof(buf)); |
845 | if (err != 0) { | 859 | if (err != 0) { |
846 | pr_err("Failed to look up CPU type (Intel or AMD)\n"); | 860 | pr_err("Failed to look up CPU type\n"); |
847 | return err; | 861 | return err; |
848 | } | 862 | } |
849 | cpuid = buf; | 863 | cpuid = buf; |
850 | } else | 864 | } else |
851 | cpuid = kvm->session->header.env.cpuid; | 865 | cpuid = kvm->session->header.env.cpuid; |
852 | 866 | ||
853 | if (strstr(cpuid, "Intel")) | 867 | if (!cpuid) { |
854 | isa = 1; | 868 | pr_err("Failed to look up CPU type\n"); |
855 | else if (strstr(cpuid, "AMD")) | 869 | return -EINVAL; |
856 | isa = 0; | ||
857 | else { | ||
858 | pr_err("CPU %s is not supported.\n", cpuid); | ||
859 | return -ENOTSUP; | ||
860 | } | 870 | } |
861 | 871 | ||
862 | if (isa == 1) { | 872 | err = cpu_isa_init(kvm, cpuid); |
863 | kvm->exit_reasons = vmx_exit_reasons; | 873 | if (err == -ENOTSUP) |
864 | kvm->exit_reasons_isa = "VMX"; | 874 | pr_err("CPU %s is not supported.\n", cpuid); |
865 | } | ||
866 | 875 | ||
867 | return 0; | 876 | return err; |
868 | } | 877 | } |
869 | 878 | ||
870 | static bool verify_vcpu(int vcpu) | 879 | 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 | .report_event = "vmexit", | 1592 | .report_event = "vmexit", |
1584 | .sort_key = "sample", | 1593 | .sort_key = "sample", |
1585 | 1594 | ||
1586 | .exit_reasons = svm_exit_reasons, | ||
1587 | .exit_reasons_isa = "SVM", | ||
1588 | }; | 1595 | }; |
1589 | 1596 | ||
1590 | if (argc == 1) { | 1597 | if (argc == 1) { |