* [PATCH 0/4] perf kvm: Refactoring and small improvements
@ 2014-07-03 13:59 Alexander Yarygin
2014-07-03 13:59 ` [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag Alexander Yarygin
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Alexander Yarygin @ 2014-07-03 13:59 UTC (permalink / raw)
To: Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Christian Borntraeger, Cornelia Huck,
linux-kernel, Alexander Yarygin
Hello,
We divided patch series "perf/s390/kvm: trace events, perf kvm stat"
into 2 parts.
This patch set is a preparation for the next one, which adds support for
perf kvm stat support on s390.
Patch 1 removes direct dependence of perf kvm stat from x86.
Patches 2-3 are refactoring.
Patch 4 adds arch/s390/header.c to be used by perf kvm stat on s390.
Compared to the previous version, patches contain some minor style/typo fixes.
Link to the previous thread: https://lkml.org/lkml/2014/4/25/331
(mirror: http://marc.info/?l=linux-kernel&m=139841718926897)
Please consider to merge.
Thanks.
Alexander Yarygin (4):
perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
perf kvm: Simplify of exit reasons tables definitions
perf kvm: Refactoring of cpu_isa_config()
perf: Allow to use cpuinfo on s390
tools/perf/arch/s390/Makefile | 1 +
tools/perf/arch/s390/util/header.c | 28 ++++++++++++++
tools/perf/arch/x86/Makefile | 1 +
tools/perf/builtin-kvm.c | 72 +++++++++++++++++++-----------------
tools/perf/config/Makefile | 4 ++
tools/perf/perf-sys.h | 1 +
6 files changed, 73 insertions(+), 34 deletions(-)
create mode 100644 tools/perf/arch/s390/util/header.c
--
1.7.9.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
@ 2014-07-03 13:59 ` Alexander Yarygin
2014-07-16 19:15 ` [tip:perf/core] " tip-bot for Alexander Yarygin
2014-07-03 13:59 ` [PATCH 2/4] perf kvm: Simplify of exit reasons tables definitions Alexander Yarygin
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Alexander Yarygin @ 2014-07-03 13:59 UTC (permalink / raw)
To: Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Christian Borntraeger, Cornelia Huck,
linux-kernel, Alexander Yarygin
kvm stat support is currently conditional on i386/x86_64. Let's
abstract this into a HAVE_KVM_STAT_SUPPORT flag, so that other
architectures can support kvm stat as well.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
tools/perf/arch/x86/Makefile | 1 +
tools/perf/builtin-kvm.c | 6 +++---
tools/perf/config/Makefile | 4 ++++
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 1641542..d393901 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -15,3 +15,4 @@ endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
LIB_H += arch/$(ARCH)/util/tsc.h
+HAVE_KVM_STAT_SUPPORT := 1
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 0f1e5a2..214ec0e 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -29,7 +29,7 @@
#include <pthread.h>
#include <math.h>
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef HAVE_KVM_STAT_SUPPORT
#include <asm/svm.h>
#include <asm/vmx.h>
#include <asm/kvm.h>
@@ -1609,7 +1609,7 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
perf_stat:
return cmd_stat(argc, argv, NULL);
}
-#endif
+#endif /* HAVE_KVM_STAT_SUPPORT */
static int __cmd_record(const char *file_name, int argc, const char **argv)
{
@@ -1726,7 +1726,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
return cmd_top(argc, argv, NULL);
else if (!strncmp(argv[0], "buildid-list", 12))
return __cmd_buildid_list(file_name, argc, argv);
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef HAVE_KVM_STAT_SUPPORT
else if (!strncmp(argv[0], "stat", 4))
return kvm_cmd_stat(file_name, argc, argv);
#endif
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 4f100b5..82d7db5 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -586,6 +586,10 @@ ifndef NO_LIBNUMA
endif
endif
+ifdef HAVE_KVM_STAT_SUPPORT
+ CFLAGS += -DHAVE_KVM_STAT_SUPPORT
+endif
+
# Among the variables below, these:
# perfexecdir
# template_dir
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] perf kvm: Simplify of exit reasons tables definitions
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
2014-07-03 13:59 ` [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag Alexander Yarygin
@ 2014-07-03 13:59 ` Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] perf kvm: Simplify " tip-bot for Alexander Yarygin
2014-07-03 13:59 ` [PATCH 3/4] perf kvm: Refactoring of cpu_isa_config() Alexander Yarygin
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Alexander Yarygin @ 2014-07-03 13:59 UTC (permalink / raw)
To: Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Christian Borntraeger, Cornelia Huck,
linux-kernel, Alexander Yarygin
perf_kvm_stat struct keeps the size of a table of exit reasons in the field
'exit_reasons_size'. The field is initialized and then
used by get_exit_reason() for serial access to the table, so that the
calling function does not actually need to know table size.
Usage of tables with 'end of sequence' marker can simplify
get_exit_reason() function.
Also patch introduces a define_exit_reasons_table, which makes easier to
define new tables.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
tools/perf/builtin-kvm.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 214ec0e..75f3544 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -99,7 +99,6 @@ struct perf_kvm_stat {
int trace_vcpu;
struct exit_reasons_table *exit_reasons;
- int exit_reasons_size;
const char *exit_reasons_isa;
struct kvm_events_ops *events_ops;
@@ -158,20 +157,19 @@ static bool exit_event_end(struct perf_evsel *evsel,
return kvm_entry_event(evsel);
}
-static struct exit_reasons_table vmx_exit_reasons[] = {
- VMX_EXIT_REASONS
-};
+#define define_exit_reasons_table(name, symbols) \
+ static struct exit_reasons_table name[] = { \
+ symbols, { -1, NULL } \
+ }
-static struct exit_reasons_table svm_exit_reasons[] = {
- SVM_EXIT_REASONS
-};
+define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
+define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
-static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code)
+static const char *get_exit_reason(struct perf_kvm_stat *kvm,
+ struct exit_reasons_table *tbl,
+ u64 exit_code)
{
- int i = kvm->exit_reasons_size;
- struct exit_reasons_table *tbl = kvm->exit_reasons;
-
- while (i--) {
+ while (tbl->reason != NULL) {
if (tbl->exit_code == exit_code)
return tbl->reason;
tbl++;
@@ -186,7 +184,8 @@ static void exit_event_decode_key(struct perf_kvm_stat *kvm,
struct event_key *key,
char decode[20])
{
- const char *exit_reason = get_exit_reason(kvm, key->key);
+ const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
+ key->key);
scnprintf(decode, 20, "%s", exit_reason);
}
@@ -862,7 +861,6 @@ static int cpu_isa_config(struct perf_kvm_stat *kvm)
if (isa == 1) {
kvm->exit_reasons = vmx_exit_reasons;
- kvm->exit_reasons_size = ARRAY_SIZE(vmx_exit_reasons);
kvm->exit_reasons_isa = "VMX";
}
@@ -1586,7 +1584,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
.sort_key = "sample",
.exit_reasons = svm_exit_reasons,
- .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
.exit_reasons_isa = "SVM",
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] perf kvm: Refactoring of cpu_isa_config()
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
2014-07-03 13:59 ` [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag Alexander Yarygin
2014-07-03 13:59 ` [PATCH 2/4] perf kvm: Simplify of exit reasons tables definitions Alexander Yarygin
@ 2014-07-03 13:59 ` Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] " tip-bot for Alexander Yarygin
2014-07-03 14:08 ` [PATCH 4/4] perf: Allow to use cpuinfo on s390 Alexander Yarygin
2014-07-03 14:47 ` [PATCH 0/4] perf kvm: Refactoring and small improvements Christian Borntraeger
4 siblings, 1 reply; 11+ messages in thread
From: Alexander Yarygin @ 2014-07-03 13:59 UTC (permalink / raw)
To: Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Christian Borntraeger, Cornelia Huck,
linux-kernel, Alexander Yarygin
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.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
tools/perf/builtin-kvm.c | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 75f3544..41dbeaf 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,
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)
{
char buf[64], *cpuid;
- int err, isa;
+ int err;
if (kvm->live) {
err = get_cpuid(buf, sizeof(buf));
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;
}
cpuid = buf;
} else
cpuid = kvm->session->header.env.cpuid;
- if (strstr(cpuid, "Intel"))
- isa = 1;
- else if (strstr(cpuid, "AMD"))
- isa = 0;
- else {
- pr_err("CPU %s is not supported.\n", cpuid);
- return -ENOTSUP;
+ if (!cpuid) {
+ pr_err("Failed to look up CPU type\n");
+ return -EINVAL;
}
- if (isa == 1) {
- kvm->exit_reasons = vmx_exit_reasons;
- kvm->exit_reasons_isa = "VMX";
- }
+ err = cpu_isa_init(kvm, cpuid);
+ if (err == -ENOTSUP)
+ pr_err("CPU %s is not supported.\n", cpuid);
- return 0;
+ return err;
}
static bool verify_vcpu(int vcpu)
@@ -1583,8 +1592,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
.report_event = "vmexit",
.sort_key = "sample",
- .exit_reasons = svm_exit_reasons,
- .exit_reasons_isa = "SVM",
};
if (argc == 1) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] perf: Allow to use cpuinfo on s390
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
` (2 preceding siblings ...)
2014-07-03 13:59 ` [PATCH 3/4] perf kvm: Refactoring of cpu_isa_config() Alexander Yarygin
@ 2014-07-03 14:08 ` Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] perf tools: " tip-bot for Alexander Yarygin
2014-07-03 14:47 ` [PATCH 0/4] perf kvm: Refactoring and small improvements Christian Borntraeger
4 siblings, 1 reply; 11+ messages in thread
From: Alexander Yarygin @ 2014-07-03 14:08 UTC (permalink / raw)
To: Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Christian Borntraeger, Cornelia Huck,
linux-kernel
This patch defines CPUINFO_PROC for s390 and implements get_cpuid().
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
tools/perf/arch/s390/Makefile | 1 +
| 28 ++++++++++++++++++++++++++++
tools/perf/perf-sys.h | 1 +
3 files changed, 30 insertions(+)
create mode 100644 tools/perf/arch/s390/util/header.c
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 15130b5..744e629 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
--git a/tools/perf/arch/s390/util/header.c b/tools/perf/arch/s390/util/header.c
new file mode 100644
index 0000000..9fa6c3e
--- /dev/null
+++ b/tools/perf/arch/s390/util/header.c
@@ -0,0 +1,28 @@
+/*
+ * Implementation of get_cpuid().
+ *
+ * Copyright 2014 IBM Corp.
+ * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "../../util/header.h"
+
+int get_cpuid(char *buffer, size_t sz)
+{
+ const char *cpuid = "IBM/S390";
+
+ if (strlen(cpuid) + 1 > sz)
+ return -1;
+
+ strcpy(buffer, cpuid);
+ return 0;
+}
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 5268a14..937e432 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -54,6 +54,7 @@
#define mb() asm volatile("bcr 15,0" ::: "memory")
#define wmb() asm volatile("bcr 15,0" ::: "memory")
#define rmb() asm volatile("bcr 15,0" ::: "memory")
+#define CPUINFO_PROC "vendor_id"
#endif
#ifdef __sh__
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] perf kvm: Refactoring and small improvements
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
` (3 preceding siblings ...)
2014-07-03 14:08 ` [PATCH 4/4] perf: Allow to use cpuinfo on s390 Alexander Yarygin
@ 2014-07-03 14:47 ` Christian Borntraeger
2014-07-03 15:22 ` Arnaldo Carvalho de Melo
4 siblings, 1 reply; 11+ messages in thread
From: Christian Borntraeger @ 2014-07-03 14:47 UTC (permalink / raw)
To: Alexander Yarygin, Jiri Olsa
Cc: David Ahern, Peter Zijlstra, Paul Mackerras,
Arnaldo Carvalho de Melo, Cornelia Huck, linux-kernel,
Paolo Bonzini
On 03/07/14 15:59, Alexander Yarygin wrote:
> Hello,
>
> We divided patch series "perf/s390/kvm: trace events, perf kvm stat"
> into 2 parts.
>
> This patch set is a preparation for the next one, which adds support for
> perf kvm stat support on s390.
>
> Patch 1 removes direct dependence of perf kvm stat from x86.
> Patches 2-3 are refactoring.
> Patch 4 adds arch/s390/header.c to be used by perf kvm stat on s390.
>
> Compared to the previous version, patches contain some minor style/typo fixes.
>
> Link to the previous thread: https://lkml.org/lkml/2014/4/25/331
> (mirror: http://marc.info/?l=linux-kernel&m=139841718926897)
>
> Please consider to merge.
>
> Thanks.
>
> Alexander Yarygin (4):
> perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
> perf kvm: Simplify of exit reasons tables definitions
> perf kvm: Refactoring of cpu_isa_config()
> perf: Allow to use cpuinfo on s390
>
> tools/perf/arch/s390/Makefile | 1 +
> tools/perf/arch/s390/util/header.c | 28 ++++++++++++++
> tools/perf/arch/x86/Makefile | 1 +
> tools/perf/builtin-kvm.c | 72 +++++++++++++++++++-----------------
> tools/perf/config/Makefile | 4 ++
> tools/perf/perf-sys.h | 1 +
> 6 files changed, 73 insertions(+), 34 deletions(-)
> create mode 100644 tools/perf/arch/s390/util/header.c
>
> --
> 1.7.9.5
>
CCing Paolo to allow him to comment.
FWIW, all patches
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Should be good for next merge window.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/4] perf kvm: Refactoring and small improvements
2014-07-03 14:47 ` [PATCH 0/4] perf kvm: Refactoring and small improvements Christian Borntraeger
@ 2014-07-03 15:22 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 11+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-07-03 15:22 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Alexander Yarygin, Jiri Olsa, David Ahern, Peter Zijlstra,
Paul Mackerras, Cornelia Huck, linux-kernel, Paolo Bonzini
Em Thu, Jul 03, 2014 at 04:47:04PM +0200, Christian Borntraeger escreveu:
> FWIW, all patches
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Should be good for next merge window.
Ok, thanks for work and for the reviewing, applying to my perf/core
branch.
- Arnaldo
^ permalink raw reply [flat|nested] 11+ messages in thread
* [tip:perf/core] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
2014-07-03 13:59 ` [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag Alexander Yarygin
@ 2014-07-16 19:15 ` tip-bot for Alexander Yarygin
0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Alexander Yarygin @ 2014-07-16 19:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
borntraeger, jolsa, cornelia.huck, yarygin, dsahern, tglx
Commit-ID: da50ad69723111e0292f1943dad77b41bb9a25b0
Gitweb: http://git.kernel.org/tip/da50ad69723111e0292f1943dad77b41bb9a25b0
Author: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
AuthorDate: Thu, 3 Jul 2014 17:59:49 +0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 7 Jul 2014 16:55:23 -0300
perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
kvm stat support is currently conditional on i386/x86_64. Let's abstract
this into a HAVE_KVM_STAT_SUPPORT flag, so that other architectures can
support kvm stat as well.
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-2-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/arch/x86/Makefile | 1 +
tools/perf/builtin-kvm.c | 6 +++---
tools/perf/config/Makefile | 4 ++++
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 1641542..d393901 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -15,3 +15,4 @@ endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
LIB_H += arch/$(ARCH)/util/tsc.h
+HAVE_KVM_STAT_SUPPORT := 1
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 0f1e5a2..214ec0e 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -29,7 +29,7 @@
#include <pthread.h>
#include <math.h>
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef HAVE_KVM_STAT_SUPPORT
#include <asm/svm.h>
#include <asm/vmx.h>
#include <asm/kvm.h>
@@ -1609,7 +1609,7 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
perf_stat:
return cmd_stat(argc, argv, NULL);
}
-#endif
+#endif /* HAVE_KVM_STAT_SUPPORT */
static int __cmd_record(const char *file_name, int argc, const char **argv)
{
@@ -1726,7 +1726,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
return cmd_top(argc, argv, NULL);
else if (!strncmp(argv[0], "buildid-list", 12))
return __cmd_buildid_list(file_name, argc, argv);
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef HAVE_KVM_STAT_SUPPORT
else if (!strncmp(argv[0], "stat", 4))
return kvm_cmd_stat(file_name, argc, argv);
#endif
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 346bdb6..b7f42d5 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -594,6 +594,10 @@ ifndef NO_LIBNUMA
endif
endif
+ifdef HAVE_KVM_STAT_SUPPORT
+ CFLAGS += -DHAVE_KVM_STAT_SUPPORT
+endif
+
# Among the variables below, these:
# perfexecdir
# template_dir
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [tip:perf/core] perf kvm: Simplify exit reasons tables definitions
2014-07-03 13:59 ` [PATCH 2/4] perf kvm: Simplify of exit reasons tables definitions Alexander Yarygin
@ 2014-07-16 19:16 ` tip-bot for Alexander Yarygin
0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Alexander Yarygin @ 2014-07-16 19:16 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
borntraeger, jolsa, cornelia.huck, yarygin, dsahern, tglx
Commit-ID: df74c13b6c53c97576652f7b2840764ad7d5f949
Gitweb: http://git.kernel.org/tip/df74c13b6c53c97576652f7b2840764ad7d5f949
Author: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
AuthorDate: Thu, 3 Jul 2014 17:59:50 +0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 7 Jul 2014 16:55:24 -0300
perf kvm: Simplify exit reasons tables definitions
The perf_kvm_stat struct keeps the size of a table of exit reasons in
the field 'exit_reasons_size'.
The field is initialized and then used by get_exit_reason() for serial
access to the table, so that the calling function does not actually need
to know table size.
Usage of tables with 'end of sequence' marker simplifies the
get_exit_reason() function.
Also the patch introduces a define_exit_reasons_table, which makes it
easier to define new tables.
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-3-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-kvm.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 214ec0e..75f3544 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -99,7 +99,6 @@ struct perf_kvm_stat {
int trace_vcpu;
struct exit_reasons_table *exit_reasons;
- int exit_reasons_size;
const char *exit_reasons_isa;
struct kvm_events_ops *events_ops;
@@ -158,20 +157,19 @@ static bool exit_event_end(struct perf_evsel *evsel,
return kvm_entry_event(evsel);
}
-static struct exit_reasons_table vmx_exit_reasons[] = {
- VMX_EXIT_REASONS
-};
+#define define_exit_reasons_table(name, symbols) \
+ static struct exit_reasons_table name[] = { \
+ symbols, { -1, NULL } \
+ }
-static struct exit_reasons_table svm_exit_reasons[] = {
- SVM_EXIT_REASONS
-};
+define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
+define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
-static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code)
+static const char *get_exit_reason(struct perf_kvm_stat *kvm,
+ struct exit_reasons_table *tbl,
+ u64 exit_code)
{
- int i = kvm->exit_reasons_size;
- struct exit_reasons_table *tbl = kvm->exit_reasons;
-
- while (i--) {
+ while (tbl->reason != NULL) {
if (tbl->exit_code == exit_code)
return tbl->reason;
tbl++;
@@ -186,7 +184,8 @@ static void exit_event_decode_key(struct perf_kvm_stat *kvm,
struct event_key *key,
char decode[20])
{
- const char *exit_reason = get_exit_reason(kvm, key->key);
+ const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
+ key->key);
scnprintf(decode, 20, "%s", exit_reason);
}
@@ -862,7 +861,6 @@ static int cpu_isa_config(struct perf_kvm_stat *kvm)
if (isa == 1) {
kvm->exit_reasons = vmx_exit_reasons;
- kvm->exit_reasons_size = ARRAY_SIZE(vmx_exit_reasons);
kvm->exit_reasons_isa = "VMX";
}
@@ -1586,7 +1584,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
.sort_key = "sample",
.exit_reasons = svm_exit_reasons,
- .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
.exit_reasons_isa = "SVM",
};
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [tip:perf/core] perf kvm: Refactoring of cpu_isa_config()
2014-07-03 13:59 ` [PATCH 3/4] perf kvm: Refactoring of cpu_isa_config() Alexander Yarygin
@ 2014-07-16 19:16 ` tip-bot for Alexander Yarygin
0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Alexander Yarygin @ 2014-07-16 19:16 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
borntraeger, jolsa, cornelia.huck, yarygin, dsahern, tglx
Commit-ID: 65c647a65c155e69bd5765d5e454982566ac1c62
Gitweb: http://git.kernel.org/tip/65c647a65c155e69bd5765d5e454982566ac1c62
Author: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
AuthorDate: Thu, 3 Jul 2014 17:59:51 +0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 7 Jul 2014 16:55:24 -0300
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>
---
tools/perf/builtin-kvm.c | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 75f3544..41dbeaf 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,
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)
{
char buf[64], *cpuid;
- int err, isa;
+ int err;
if (kvm->live) {
err = get_cpuid(buf, sizeof(buf));
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;
}
cpuid = buf;
} else
cpuid = kvm->session->header.env.cpuid;
- if (strstr(cpuid, "Intel"))
- isa = 1;
- else if (strstr(cpuid, "AMD"))
- isa = 0;
- else {
- pr_err("CPU %s is not supported.\n", cpuid);
- return -ENOTSUP;
+ if (!cpuid) {
+ pr_err("Failed to look up CPU type\n");
+ return -EINVAL;
}
- if (isa == 1) {
- kvm->exit_reasons = vmx_exit_reasons;
- kvm->exit_reasons_isa = "VMX";
- }
+ err = cpu_isa_init(kvm, cpuid);
+ if (err == -ENOTSUP)
+ pr_err("CPU %s is not supported.\n", cpuid);
- return 0;
+ return err;
}
static bool verify_vcpu(int vcpu)
@@ -1583,8 +1592,6 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
.report_event = "vmexit",
.sort_key = "sample",
- .exit_reasons = svm_exit_reasons,
- .exit_reasons_isa = "SVM",
};
if (argc == 1) {
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [tip:perf/core] perf tools: Allow to use cpuinfo on s390
2014-07-03 14:08 ` [PATCH 4/4] perf: Allow to use cpuinfo on s390 Alexander Yarygin
@ 2014-07-16 19:16 ` tip-bot for Alexander Yarygin
0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Alexander Yarygin @ 2014-07-16 19:16 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra,
borntraeger, jolsa, cornelia.huck, yarygin, dsahern, tglx
Commit-ID: f8d9ccde2be4c24bfb8787af36a59a981b00a02d
Gitweb: http://git.kernel.org/tip/f8d9ccde2be4c24bfb8787af36a59a981b00a02d
Author: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
AuthorDate: Thu, 3 Jul 2014 18:08:22 +0400
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 7 Jul 2014 16:55:24 -0300
perf tools: Allow to use cpuinfo on s390
This patch defines CPUINFO_PROC for s390 and implements get_cpuid().
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/87ioneo7qh.wl%yarygin@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/arch/s390/Makefile | 1 +
| 28 ++++++++++++++++++++++++++++
tools/perf/perf-sys.h | 1 +
3 files changed, 30 insertions(+)
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 15130b5..744e629 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
--git a/tools/perf/arch/s390/util/header.c b/tools/perf/arch/s390/util/header.c
new file mode 100644
index 0000000..9fa6c3e
--- /dev/null
+++ b/tools/perf/arch/s390/util/header.c
@@ -0,0 +1,28 @@
+/*
+ * Implementation of get_cpuid().
+ *
+ * Copyright 2014 IBM Corp.
+ * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "../../util/header.h"
+
+int get_cpuid(char *buffer, size_t sz)
+{
+ const char *cpuid = "IBM/S390";
+
+ if (strlen(cpuid) + 1 > sz)
+ return -1;
+
+ strcpy(buffer, cpuid);
+ return 0;
+}
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 5268a14..937e432 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -54,6 +54,7 @@
#define mb() asm volatile("bcr 15,0" ::: "memory")
#define wmb() asm volatile("bcr 15,0" ::: "memory")
#define rmb() asm volatile("bcr 15,0" ::: "memory")
+#define CPUINFO_PROC "vendor_id"
#endif
#ifdef __sh__
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-07-16 19:17 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-03 13:59 [PATCH 0/4] perf kvm: Refactoring and small improvements Alexander Yarygin
2014-07-03 13:59 ` [PATCH 1/4] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag Alexander Yarygin
2014-07-16 19:15 ` [tip:perf/core] " tip-bot for Alexander Yarygin
2014-07-03 13:59 ` [PATCH 2/4] perf kvm: Simplify of exit reasons tables definitions Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] perf kvm: Simplify " tip-bot for Alexander Yarygin
2014-07-03 13:59 ` [PATCH 3/4] perf kvm: Refactoring of cpu_isa_config() Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] " tip-bot for Alexander Yarygin
2014-07-03 14:08 ` [PATCH 4/4] perf: Allow to use cpuinfo on s390 Alexander Yarygin
2014-07-16 19:16 ` [tip:perf/core] perf tools: " tip-bot for Alexander Yarygin
2014-07-03 14:47 ` [PATCH 0/4] perf kvm: Refactoring and small improvements Christian Borntraeger
2014-07-03 15:22 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).