Skip to contentSkip to conversation

perf kvm: Refactoring and small improvements

PATCH In review Alexander Yarygin 4 participants 11 messages Jul 3, 2014 – Jul 16, 2014 perf events

lore
Share & tools
lore
#0 lore raw

cover perf kvm: Refactoring and small improvements

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

#1 lore raw

PATCH 1/4 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.

---
 tools/perf/arch/x86/Makefile |    1 +
 tools/perf/builtin-kvm.c     |    6 +++---
 tools/perf/config/Makefile   |    4 ++++
 3 files changed, 8 insertions(+), 3 deletions(-)
tools/perf/arch/x86/Makefile +1 -0
index 1641542..d393901 100644
@@ -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
tools/perf/builtin-kvm.c +3 -3
index 0f1e5a2..214ec0e 100644
@@ -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
tools/perf/config/Makefile +4 -0
index 4f100b5..82d7db5 100644
@@ -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
Signature · 1 line
1.7.9.5
#2 lore raw

[tip:perf/core] perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag

perf kvm: Introduce HAVE_KVM_STAT_SUPPORT flag
Commit-ID:  da50ad69723111e0292f1943dad77b41bb9a25b0
Gitweb:     http://git.kernel.org/tip/da50ad69723111e0292f1943dad77b41bb9a25b0
Author:     Alexander Yarygin <[email protected]>
AuthorDate: Thu, 3 Jul 2014 17:59:49 +0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/arch/x86/Makefile | 1 +
 tools/perf/builtin-kvm.c     | 6 +++---
 tools/perf/config/Makefile   | 4 ++++
 3 files changed, 8 insertions(+), 3 deletions(-)
tools/perf/arch/x86/Makefile +1 -0
index 1641542..d393901 100644
@@ -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
tools/perf/builtin-kvm.c +3 -3
index 0f1e5a2..214ec0e 100644
@@ -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
tools/perf/config/Makefile +4 -0
index 346bdb6..b7f42d5 100644
@@ -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
#3 lore raw

PATCH 2/4 perf kvm: Simplify of exit reasons tables definitions

In reply to 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.

---
 tools/perf/builtin-kvm.c |   27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
tools/perf/builtin-kvm.c +12 -15
index 214ec0e..75f3544 100644
@@ -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",
 	};
 
Signature · 1 line
1.7.9.5
#4 lore raw

[tip:perf/core] perf kvm: Simplify exit reasons tables definitions

perf kvm: Simplify exit reasons tables definitions
Commit-ID:  df74c13b6c53c97576652f7b2840764ad7d5f949
Gitweb:     http://git.kernel.org/tip/df74c13b6c53c97576652f7b2840764ad7d5f949
Author:     Alexander Yarygin <[email protected]>
AuthorDate: Thu, 3 Jul 2014 17:59:50 +0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/builtin-kvm.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
tools/perf/builtin-kvm.c +12 -15
index 214ec0e..75f3544 100644
@@ -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",
 	};
 
#5 lore raw

PATCH 3/4 perf kvm: Refactoring of cpu_isa_config()

In reply to 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.

---
 tools/perf/builtin-kvm.c |   39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
tools/perf/builtin-kvm.c +23 -16
index 75f3544..41dbeaf 100644
@@ -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) {
Signature · 1 line
1.7.9.5
#6 lore raw

[tip:perf/core] perf kvm: Refactoring of cpu_isa_config()

perf kvm: Refactoring of cpu_isa_config()
Commit-ID:  65c647a65c155e69bd5765d5e454982566ac1c62
Gitweb:     http://git.kernel.org/tip/65c647a65c155e69bd5765d5e454982566ac1c62
Author:     Alexander Yarygin <[email protected]>
AuthorDate: Thu, 3 Jul 2014 17:59:51 +0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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.

---
 tools/perf/builtin-kvm.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)
tools/perf/builtin-kvm.c +23 -16
index 75f3544..41dbeaf 100644
@@ -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) {
#7 lore raw

PATCH 4/4 perf: Allow to use cpuinfo on s390

In reply to Alexander Yarygin

This patch defines CPUINFO_PROC for s390 and implements get_cpuid().

---
 tools/perf/arch/s390/Makefile      |    1 +
 tools/perf/arch/s390/util/header.c |   28 ++++++++++++++++++++++++++++
 tools/perf/perf-sys.h              |    1 +
 3 files changed, 30 insertions(+)
 create mode 100644 tools/perf/arch/s390/util/header.c
tools/perf/arch/s390/Makefile +1 -0
index 15130b5..744e629 100644
@@ -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
tools/perf/arch/s390/util/header.c new file +28 -0
new file mode 100644
index 0000000..9fa6c3e
@@ -0,0 +1,28 @@
+/*
+ * Implementation of get_cpuid().
+ *
+ * Copyright 2014 IBM Corp.
+ * Author(s): Alexander Yarygin <[email protected]>
+ *
+ * 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;
+}
tools/perf/perf-sys.h +1 -0
index 5268a14..937e432 100644
@@ -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__
Signature · 1 line
1.7.9.5
#8 lore raw

[tip:perf/core] perf tools: Allow to use cpuinfo on s390

perf tools: Allow to use cpuinfo on s390
Commit-ID:  f8d9ccde2be4c24bfb8787af36a59a981b00a02d
Gitweb:     http://git.kernel.org/tip/f8d9ccde2be4c24bfb8787af36a59a981b00a02d
Author:     Alexander Yarygin <[email protected]>
AuthorDate: Thu, 3 Jul 2014 18:08:22 +0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
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().

---
 tools/perf/arch/s390/Makefile      |  1 +
 tools/perf/arch/s390/util/header.c | 28 ++++++++++++++++++++++++++++
 tools/perf/perf-sys.h              |  1 +
 3 files changed, 30 insertions(+)
tools/perf/arch/s390/Makefile +1 -0
index 15130b5..744e629 100644
@@ -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
tools/perf/arch/s390/util/header.c new file +28 -0
new file mode 100644
index 0000000..9fa6c3e
@@ -0,0 +1,28 @@
+/*
+ * Implementation of get_cpuid().
+ *
+ * Copyright 2014 IBM Corp.
+ * Author(s): Alexander Yarygin <[email protected]>
+ *
+ * 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;
+}
tools/perf/perf-sys.h +1 -0
index 5268a14..937e432 100644
@@ -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__
Acked-by on the v1 series
#9 lore raw
In reply to Alexander Yarygin
Quoted 36 lines · 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
Quoted 3 lines

--
1.7.9.5

CCing Paolo to allow him to comment.

FWIW, all patches

Should be good for next merge window.