All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat
@ 2014-04-25  9:12 Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 01/11] s390: add sie exit reasons tables Christian Borntraeger
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

The goal of this series is to
- enable perf kvm stat on s390
- get rid of a perf warning "insn_to_mnemonic not found" when it tries to
  decode s390 perf trace events

Review feedback is welcome.
In addition, The patch set touches s390/kvm code and perf code.
So any feedback on which tree to use for this series is also 
welcome.

Christian


Alexander Yarygin (11):
  s390: add sie exit reasons tables
  KVM: s390: Use trace tables from sie.h.
  KVM: s390: decoder of SIE intercepted instructions
  KVM: s390: Use intercept_insn decoder in trace event
  perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag
  perf kvm: simplify of exit reasons tables definitions
  perf kvm: Refactoring of cpu_isa_config()
  perf kvm: allow for variable string sizes
  perf kvm: use defines of kvm events
  perf: allow to use cpuinfo on s390
  perf kvm: add stat support on s390

 arch/s390/include/uapi/asm/kvm.h   |   7 +
 arch/s390/include/uapi/asm/sie.h   | 245 ++++++++++++++++++++++++++++++++++
 arch/s390/kvm/trace.h              |  39 +-----
 arch/x86/include/uapi/asm/kvm.h    |   8 ++
 tools/perf/MANIFEST                |   3 +
 tools/perf/arch/s390/Makefile      |   2 +
 tools/perf/arch/s390/util/header.c |  17 +++
 tools/perf/arch/x86/Makefile       |   1 +
 tools/perf/builtin-kvm.c           | 263 +++++++++++++++++++++++++++++--------
 tools/perf/config/Makefile         |   4 +
 tools/perf/perf.h                  |   1 +
 11 files changed, 499 insertions(+), 91 deletions(-)
 create mode 100644 arch/s390/include/uapi/asm/sie.h
 create mode 100644 tools/perf/arch/s390/util/header.c

-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/11] s390: add sie exit reasons tables
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 02/11] KVM: s390: Use trace tables from sie.h Christian Borntraeger
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

This patch defines tables of reasons for exiting from SIE mode
in a new sie.h header file. Tables contain SIE intercepted codes,
intercepted instructions and program interruptions codes.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/uapi/asm/sie.h | 212 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 212 insertions(+)
 create mode 100644 arch/s390/include/uapi/asm/sie.h

diff --git a/arch/s390/include/uapi/asm/sie.h b/arch/s390/include/uapi/asm/sie.h
new file mode 100644
index 0000000..5f942a2
--- /dev/null
+++ b/arch/s390/include/uapi/asm/sie.h
@@ -0,0 +1,212 @@
+#ifndef _UAPI_ASM_S390_SIE_H
+#define _UAPI_ASM_S390_SIE_H
+
+#include <asm/sigp.h>
+
+#define diagnose_codes						\
+	{ 0x10, "DIAG (0x10) release pages" },			\
+	{ 0x44, "DIAG (0x44) time slice end" },			\
+	{ 0x9c, "DIAG (0x9c) time slice end directed" },	\
+	{ 0x204, "DIAG (0x204) logical-cpu utilization" },	\
+	{ 0x258, "DIAG (0x258) page-reference services" },	\
+	{ 0x308, "DIAG (0x308) ipl functions" },		\
+	{ 0x500, "DIAG (0x500) KVM virtio functions" },		\
+	{ 0x501, "DIAG (0x501) KVM breakpoint" }
+
+#define sigp_order_codes                                                \
+	{ SIGP_SENSE, "SIGP sense" },					\
+	{ SIGP_EXTERNAL_CALL, "SIGP external call" },			\
+	{ SIGP_EMERGENCY_SIGNAL, "SIGP emergency signal" },		\
+	{ SIGP_STOP, "SIGP stop" },					\
+	{ SIGP_STOP_AND_STORE_STATUS, "SIGP stop and store status" },	\
+	{ SIGP_SET_ARCHITECTURE, "SIGP set architecture" },		\
+	{ SIGP_SET_PREFIX, "SIGP set prefix" },				\
+	{ SIGP_SENSE_RUNNING, "SIGP sense running" },			\
+	{ SIGP_RESTART, "SIGP restart" },				\
+	{ SIGP_INITIAL_CPU_RESET, "SIGP initial cpu reset" },		\
+	{ SIGP_STORE_STATUS_AT_ADDRESS, "SIGP store status at address" }
+
+#define icpt_prog_codes						\
+	{ 0x0001, "Prog Operation" },				\
+	{ 0x0002, "Prog Privileged Operation" },		\
+	{ 0x0003, "Prog Execute" },				\
+	{ 0x0004, "Prog Protection" },				\
+	{ 0x0005, "Prog Addressing" },				\
+	{ 0x0006, "Prog Specification" },			\
+	{ 0x0007, "Prog Data" },				\
+	{ 0x0008, "Prog Fixedpoint overflow" },			\
+	{ 0x0009, "Prog Fixedpoint divide" },			\
+	{ 0x000A, "Prog Decimal overflow" },			\
+	{ 0x000B, "Prog Decimal divide" },			\
+	{ 0x000C, "Prog HFP exponent overflow" },		\
+	{ 0x000D, "Prog HFP exponent underflow" },		\
+	{ 0x000E, "Prog HFP significance" },			\
+	{ 0x000F, "Prog HFP divide" },				\
+	{ 0x0010, "Prog Segment translation" },			\
+	{ 0x0011, "Prog Page translation" },			\
+	{ 0x0012, "Prog Translation specification" },		\
+	{ 0x0013, "Prog Special operation" },			\
+	{ 0x0015, "Prog Operand" },				\
+	{ 0x0016, "Prog Trace table" },				\
+	{ 0x0017, "Prog ASNtranslation specification" },	\
+	{ 0x001C, "Prog Spaceswitch event" },			\
+	{ 0x001D, "Prog HFP square root" },			\
+	{ 0x001F, "Prog PCtranslation specification" },		\
+	{ 0x0020, "Prog AFX translation" },			\
+	{ 0x0021, "Prog ASX translation" },			\
+	{ 0x0022, "Prog LX translation" },			\
+	{ 0x0023, "Prog EX translation" },			\
+	{ 0x0024, "Prog Primary authority" },			\
+	{ 0x0025, "Prog Secondary authority" },			\
+	{ 0x0026, "Prog LFXtranslation exception" },		\
+	{ 0x0027, "Prog LSXtranslation exception" },		\
+	{ 0x0028, "Prog ALET specification" },			\
+	{ 0x0029, "Prog ALEN translation" },			\
+	{ 0x002A, "Prog ALE sequence" },			\
+	{ 0x002B, "Prog ASTE validity" },			\
+	{ 0x002C, "Prog ASTE sequence" },			\
+	{ 0x002D, "Prog Extended authority" },			\
+	{ 0x002E, "Prog LSTE sequence" },			\
+	{ 0x002F, "Prog ASTE instance" },			\
+	{ 0x0030, "Prog Stack full" },				\
+	{ 0x0031, "Prog Stack empty" },				\
+	{ 0x0032, "Prog Stack specification" },			\
+	{ 0x0033, "Prog Stack type" },				\
+	{ 0x0034, "Prog Stack operation" },			\
+	{ 0x0039, "Prog Region first translation" },		\
+	{ 0x003A, "Prog Region second translation" },		\
+	{ 0x003B, "Prog Region third translation" },		\
+	{ 0x0040, "Prog Monitor event" },			\
+	{ 0x0080, "Prog PER event" },				\
+	{ 0x0119, "Prog Crypto operation" }
+
+#define exit_code_ipa0(ipa0, opcode, mnemonic)		\
+	{ (ipa0 << 8 | opcode), #ipa0 " " mnemonic }
+#define exit_code(opcode, mnemonic)			\
+	{ opcode, mnemonic }
+
+#define icpt_insn_codes				\
+	exit_code_ipa0(0x01, 0x01, "PR"),	\
+	exit_code_ipa0(0x01, 0x04, "PTFF"),	\
+	exit_code_ipa0(0x01, 0x07, "SCKPF"),	\
+	exit_code_ipa0(0xAA, 0x00, "RINEXT"),	\
+	exit_code_ipa0(0xAA, 0x01, "RION"),	\
+	exit_code_ipa0(0xAA, 0x02, "TRIC"),	\
+	exit_code_ipa0(0xAA, 0x03, "RIOFF"),	\
+	exit_code_ipa0(0xAA, 0x04, "RIEMIT"),	\
+	exit_code_ipa0(0xB2, 0x02, "STIDP"),	\
+	exit_code_ipa0(0xB2, 0x04, "SCK"),	\
+	exit_code_ipa0(0xB2, 0x05, "STCK"),	\
+	exit_code_ipa0(0xB2, 0x06, "SCKC"),	\
+	exit_code_ipa0(0xB2, 0x07, "STCKC"),	\
+	exit_code_ipa0(0xB2, 0x08, "SPT"),	\
+	exit_code_ipa0(0xB2, 0x09, "STPT"),	\
+	exit_code_ipa0(0xB2, 0x0d, "PTLB"),	\
+	exit_code_ipa0(0xB2, 0x10, "SPX"),	\
+	exit_code_ipa0(0xB2, 0x11, "STPX"),	\
+	exit_code_ipa0(0xB2, 0x12, "STAP"),	\
+	exit_code_ipa0(0xB2, 0x14, "SIE"),	\
+	exit_code_ipa0(0xB2, 0x16, "SETR"),	\
+	exit_code_ipa0(0xB2, 0x17, "STETR"),	\
+	exit_code_ipa0(0xB2, 0x18, "PC"),	\
+	exit_code_ipa0(0xB2, 0x20, "SERVC"),	\
+	exit_code_ipa0(0xB2, 0x28, "PT"),	\
+	exit_code_ipa0(0xB2, 0x29, "ISKE"),	\
+	exit_code_ipa0(0xB2, 0x2a, "RRBE"),	\
+	exit_code_ipa0(0xB2, 0x2b, "SSKE"),	\
+	exit_code_ipa0(0xB2, 0x2c, "TB"),	\
+	exit_code_ipa0(0xB2, 0x2e, "PGIN"),	\
+	exit_code_ipa0(0xB2, 0x2f, "PGOUT"),	\
+	exit_code_ipa0(0xB2, 0x30, "CSCH"),	\
+	exit_code_ipa0(0xB2, 0x31, "HSCH"),	\
+	exit_code_ipa0(0xB2, 0x32, "MSCH"),	\
+	exit_code_ipa0(0xB2, 0x33, "SSCH"),	\
+	exit_code_ipa0(0xB2, 0x34, "STSCH"),	\
+	exit_code_ipa0(0xB2, 0x35, "TSCH"),	\
+	exit_code_ipa0(0xB2, 0x36, "TPI"),	\
+	exit_code_ipa0(0xB2, 0x37, "SAL"),	\
+	exit_code_ipa0(0xB2, 0x38, "RSCH"),	\
+	exit_code_ipa0(0xB2, 0x39, "STCRW"),	\
+	exit_code_ipa0(0xB2, 0x3a, "STCPS"),	\
+	exit_code_ipa0(0xB2, 0x3b, "RCHP"),	\
+	exit_code_ipa0(0xB2, 0x3c, "SCHM"),	\
+	exit_code_ipa0(0xB2, 0x40, "BAKR"),	\
+	exit_code_ipa0(0xB2, 0x48, "PALB"),	\
+	exit_code_ipa0(0xB2, 0x4c, "TAR"),	\
+	exit_code_ipa0(0xB2, 0x50, "CSP"),	\
+	exit_code_ipa0(0xB2, 0x54, "MVPG"),	\
+	exit_code_ipa0(0xB2, 0x58, "BSG"),	\
+	exit_code_ipa0(0xB2, 0x5a, "BSA"),	\
+	exit_code_ipa0(0xB2, 0x5f, "CHSC"),	\
+	exit_code_ipa0(0xB2, 0x74, "SIGA"),	\
+	exit_code_ipa0(0xB2, 0x76, "XSCH"),	\
+	exit_code_ipa0(0xB2, 0x78, "STCKE"),	\
+	exit_code_ipa0(0xB2, 0x7c, "STCKF"),	\
+	exit_code_ipa0(0xB2, 0x7d, "STSI"),	\
+	exit_code_ipa0(0xB2, 0xb0, "STFLE"),	\
+	exit_code_ipa0(0xB2, 0xb1, "STFL"),	\
+	exit_code_ipa0(0xB2, 0xb2, "LPSWE"),	\
+	exit_code_ipa0(0xB2, 0xf8, "TEND"),	\
+	exit_code_ipa0(0xB2, 0xfc, "TABORT"),	\
+	exit_code_ipa0(0xB9, 0x1e, "KMAC"),	\
+	exit_code_ipa0(0xB9, 0x28, "PCKMO"),	\
+	exit_code_ipa0(0xB9, 0x2a, "KMF"),	\
+	exit_code_ipa0(0xB9, 0x2b, "KMO"),	\
+	exit_code_ipa0(0xB9, 0x2d, "KMCTR"),	\
+	exit_code_ipa0(0xB9, 0x2e, "KM"),	\
+	exit_code_ipa0(0xB9, 0x2f, "KMC"),	\
+	exit_code_ipa0(0xB9, 0x3e, "KIMD"),	\
+	exit_code_ipa0(0xB9, 0x3f, "KLMD"),	\
+	exit_code_ipa0(0xB9, 0x8a, "CSPG"),	\
+	exit_code_ipa0(0xB9, 0x8d, "EPSW"),	\
+	exit_code_ipa0(0xB9, 0x8e, "IDTE"),	\
+	exit_code_ipa0(0xB9, 0x8f, "CRDTE"),	\
+	exit_code_ipa0(0xB9, 0x9c, "EQBS"),	\
+	exit_code_ipa0(0xB9, 0xa2, "PTF"),	\
+	exit_code_ipa0(0xB9, 0xab, "ESSA"),	\
+	exit_code_ipa0(0xB9, 0xae, "RRBM"),	\
+	exit_code_ipa0(0xB9, 0xaf, "PFMF"),	\
+	exit_code_ipa0(0xE3, 0x03, "LRAG"),	\
+	exit_code_ipa0(0xE3, 0x13, "LRAY"),	\
+	exit_code_ipa0(0xE3, 0x25, "NTSTG"),	\
+	exit_code_ipa0(0xE5, 0x00, "LASP"),	\
+	exit_code_ipa0(0xE5, 0x01, "TPROT"),	\
+	exit_code_ipa0(0xE5, 0x60, "TBEGIN"),	\
+	exit_code_ipa0(0xE5, 0x61, "TBEGINC"),	\
+	exit_code_ipa0(0xEB, 0x25, "STCTG"),	\
+	exit_code_ipa0(0xEB, 0x2f, "LCTLG"),	\
+	exit_code_ipa0(0xEB, 0x60, "LRIC"),	\
+	exit_code_ipa0(0xEB, 0x61, "STRIC"),	\
+	exit_code_ipa0(0xEB, 0x62, "MRIC"),	\
+	exit_code_ipa0(0xEB, 0x8a, "SQBS"),	\
+	exit_code_ipa0(0xC8, 0x01, "ECTG"),	\
+	exit_code(0x0a, "SVC"),			\
+	exit_code(0x80, "SSM"),			\
+	exit_code(0x82, "LPSW"),		\
+	exit_code(0x83, "DIAG"),		\
+	exit_code(0xae, "SIGP"),		\
+	exit_code(0xac, "STNSM"),		\
+	exit_code(0xad, "STOSM"),		\
+	exit_code(0xb1, "LRA"),			\
+	exit_code(0xb6, "STCTL"),		\
+	exit_code(0xb7, "LCTL"),		\
+	exit_code(0xee, "PLO")
+
+#define sie_intercept_code					\
+	{ 0x00, "Host interruption" },				\
+	{ 0x04, "Instruction" },				\
+	{ 0x08, "Program interruption" },			\
+	{ 0x0c, "Instruction and program interruption" },	\
+	{ 0x10, "External request" },				\
+	{ 0x14, "External interruption" },			\
+	{ 0x18, "I/O request" },				\
+	{ 0x1c, "Wait state" },					\
+	{ 0x20, "Validity" },					\
+	{ 0x28, "Stop request" },				\
+	{ 0x2c, "Operation exception" },			\
+	{ 0x38, "Partial-execution" },				\
+	{ 0x3c, "I/O interruption" },				\
+	{ 0x40, "I/O instruction" },				\
+	{ 0x48, "Timing subset" }
+
+#endif /* _UAPI_ASM_S390_SIE_H */
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/11] KVM: s390: Use trace tables from sie.h.
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 01/11] s390: add sie exit reasons tables Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions Christian Borntraeger
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

Use the symbolic translation tables from sie.h for decoding diag, sigp
and sie exit codes.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/trace.h | 32 +-------------------------------
 1 file changed, 1 insertion(+), 31 deletions(-)

diff --git a/arch/s390/kvm/trace.h b/arch/s390/kvm/trace.h
index abf6ba5..00f57a5 100644
--- a/arch/s390/kvm/trace.h
+++ b/arch/s390/kvm/trace.h
@@ -2,7 +2,7 @@
 #define _TRACE_KVM_H
 
 #include <linux/tracepoint.h>
-#include <asm/sigp.h>
+#include <asm/sie.h>
 #include <asm/debug.h>
 #include <asm/dis.h>
 
@@ -125,17 +125,6 @@ TRACE_EVENT(kvm_s390_sie_fault,
 	    VCPU_TP_PRINTK("%s", "fault in sie instruction")
 	);
 
-#define sie_intercept_code				\
-	{0x04, "Instruction"},				\
-	{0x08, "Program interruption"},			\
-	{0x0C, "Instruction and program interruption"},	\
-	{0x10, "External request"},			\
-	{0x14, "External interruption"},		\
-	{0x18, "I/O request"},				\
-	{0x1C, "Wait state"},				\
-	{0x20, "Validity"},				\
-	{0x28, "Stop request"}
-
 TRACE_EVENT(kvm_s390_sie_exit,
 	    TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode),
 	    TP_ARGS(VCPU_ARGS_COMMON, icptcode),
@@ -227,18 +216,6 @@ TRACE_EVENT(kvm_s390_intercept_validity,
  * Trace points for instructions that are of special interest.
  */
 
-#define sigp_order_codes					\
-	{SIGP_SENSE, "sense"},					\
-	{SIGP_EXTERNAL_CALL, "external call"},			\
-	{SIGP_EMERGENCY_SIGNAL, "emergency signal"},		\
-	{SIGP_STOP, "stop"},					\
-	{SIGP_STOP_AND_STORE_STATUS, "stop and store status"},	\
-	{SIGP_SET_ARCHITECTURE, "set architecture"},		\
-	{SIGP_SET_PREFIX, "set prefix"},			\
-	{SIGP_STORE_STATUS_AT_ADDRESS, "store status at addr"},	\
-	{SIGP_SENSE_RUNNING, "sense running"},			\
-	{SIGP_RESTART, "restart"}
-
 TRACE_EVENT(kvm_s390_handle_sigp,
 	    TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr, \
 		     __u32 parameter),
@@ -265,13 +242,6 @@ TRACE_EVENT(kvm_s390_handle_sigp,
 			   __entry->cpu_addr, __entry->parameter)
 	);
 
-#define diagnose_codes				\
-	{0x10, "release pages"},		\
-	{0x44, "time slice end"},		\
-	{0x308, "ipl functions"},		\
-	{0x500, "kvm hypercall"},		\
-	{0x501, "kvm breakpoint"}
-
 TRACE_EVENT(kvm_s390_handle_diag,
 	    TP_PROTO(VCPU_PROTO_COMMON, __u16 code),
 	    TP_ARGS(VCPU_ARGS_COMMON, code),
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 01/11] s390: add sie exit reasons tables Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 02/11] KVM: s390: Use trace tables from sie.h Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event Christian Borntraeger
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

This patch adds a new decoder of SIE intercepted instructions.

The decoder implemented as a macro and potentially can be used in
both kernelspace and userspace.

Note that this simplified instruction decoder is only intended to be
used with the subset of instructions that may cause a SIE intercept.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/uapi/asm/sie.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/arch/s390/include/uapi/asm/sie.h b/arch/s390/include/uapi/asm/sie.h
index 5f942a2..30e8ee7 100644
--- a/arch/s390/include/uapi/asm/sie.h
+++ b/arch/s390/include/uapi/asm/sie.h
@@ -209,4 +209,37 @@
 	{ 0x40, "I/O instruction" },				\
 	{ 0x48, "Timing subset" }
 
+/*
+ * This is the simple interceptable instructions decoder.
+ *
+ * It will be used as userspace interface and it can be used in places
+ * that does not allow to use general decoder functions,
+ * such as trace events declarations.
+ *
+ * Some userspace tools may want to parse this code
+ * and would be confused by switch(), if() and other statements,
+ * but they can understand conditional operator.
+ */
+#define INSN_DECODE_IPA0(ipa0, insn, rshift, mask)               \
+	(insn >> 56) == (ipa0) ?				 \
+		((ipa0 << 8) | ((insn >> rshift) & mask)) :
+
+#define INSN_DECODE(insn) (insn >> 56)
+
+/*
+ * The macro icpt_insn_decoder() takes an intercepted instruction
+ * and returns a key, which can be used to find a mnemonic name
+ * of the instruction in the icpt_insn_codes table.
+ */
+#define icpt_insn_decoder(insn)			\
+	INSN_DECODE_IPA0(0x01, insn, 48, 0xff)	\
+	INSN_DECODE_IPA0(0xaa, insn, 48, 0x0f)	\
+	INSN_DECODE_IPA0(0xb2, insn, 48, 0xff)	\
+	INSN_DECODE_IPA0(0xb9, insn, 48, 0xff)	\
+	INSN_DECODE_IPA0(0xe3, insn, 48, 0xff)	\
+	INSN_DECODE_IPA0(0xe5, insn, 48, 0xff)	\
+	INSN_DECODE_IPA0(0xeb, insn, 16, 0xff)	\
+	INSN_DECODE_IPA0(0xc8, insn, 48, 0x0f)	\
+	INSN_DECODE(insn)
+
 #endif /* _UAPI_ASM_S390_SIE_H */
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (2 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag Christian Borntraeger
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

The current trace definition doesn't work very well with the perf tool.
Perf shows a "insn_to_mnemonic not found" message. Let's handle the
decoding completely in a parseable format.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/trace.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kvm/trace.h b/arch/s390/kvm/trace.h
index 00f57a5..579b42a 100644
--- a/arch/s390/kvm/trace.h
+++ b/arch/s390/kvm/trace.h
@@ -154,7 +154,6 @@ TRACE_EVENT(kvm_s390_intercept_instruction,
 	    TP_STRUCT__entry(
 		    VCPU_FIELD_COMMON
 		    __field(__u64, instruction)
-		    __field(char, insn[8])
 		    ),
 
 	    TP_fast_assign(
@@ -165,10 +164,8 @@ TRACE_EVENT(kvm_s390_intercept_instruction,
 
 	    VCPU_TP_PRINTK("intercepted instruction %016llx (%s)",
 			   __entry->instruction,
-			   insn_to_mnemonic((unsigned char *)
-					    &__entry->instruction,
-					 __entry->insn, sizeof(__entry->insn)) ?
-			   "unknown" : __entry->insn)
+			   __print_symbolic(icpt_insn_decoder(__entry->instruction),
+					    icpt_insn_codes))
 	);
 
 /*
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (3 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 06/11] perf kvm: simplify of exit reasons tables definitions Christian Borntraeger
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

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>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.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 21c164b..202b9b0 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>
@@ -1608,7 +1608,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)
 {
@@ -1725,7 +1725,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 c234182..6251d6b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -562,6 +562,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.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/11] perf kvm: simplify of exit reasons tables definitions
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (4 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 07/11] perf kvm: Refactoring of cpu_isa_config() Christian Borntraeger
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

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>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.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 202b9b0..9b97737 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);
 }
@@ -861,7 +860,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";
 	}
 
@@ -1585,7 +1583,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.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/11] perf kvm: Refactoring of cpu_isa_config()
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (5 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 06/11] perf kvm: simplify of exit reasons tables definitions Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 08/11] perf kvm: allow for variable string sizes Christian Borntraeger
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

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>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 tools/perf/builtin-kvm.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 9b97737..922706c 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -834,10 +834,26 @@ 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 {
+		pr_err("CPU %s is not supported.\n", cpuid);
+		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));
@@ -849,21 +865,12 @@ static int cpu_isa_config(struct perf_kvm_stat *kvm)
 	} 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 (isa == 1) {
-		kvm->exit_reasons = vmx_exit_reasons;
-		kvm->exit_reasons_isa = "VMX";
+	if (!cpuid) {
+		pr_err("Failed to look up CPU type\n");
+		return -EINVAL;
 	}
 
-	return 0;
+	return cpu_isa_init(kvm, cpuid);
 }
 
 static bool verify_vcpu(int vcpu)
@@ -1582,8 +1589,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.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/11] perf kvm: allow for variable string sizes
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (6 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 07/11] perf kvm: Refactoring of cpu_isa_config() Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-05-05 10:27   ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 09/11] perf kvm: use defines of kvm events Christian Borntraeger
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

This makes it possible for other architectures to decode to different
string lengths.

Needed by follow-up patch "perf kvm: add stat support on s390".

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 tools/perf/builtin-kvm.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 922706c..806c0e4 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -75,7 +75,7 @@ struct kvm_events_ops {
 	bool (*is_end_event)(struct perf_evsel *evsel,
 			     struct perf_sample *sample, struct event_key *key);
 	void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
-			   char decode[20]);
+			   char *decode);
 	const char *name;
 };
 
@@ -84,6 +84,8 @@ struct exit_reasons_table {
 	const char *reason;
 };
 
+#define DECODE_STR_LEN_MAX 80
+
 #define EVENTS_BITS		12
 #define EVENTS_CACHE_SIZE	(1UL << EVENTS_BITS)
 
@@ -101,6 +103,8 @@ struct perf_kvm_stat {
 	struct exit_reasons_table *exit_reasons;
 	const char *exit_reasons_isa;
 
+	int decode_str_len;
+
 	struct kvm_events_ops *events_ops;
 	key_cmp_fun compare;
 	struct list_head kvm_events_cache[EVENTS_CACHE_SIZE];
@@ -182,12 +186,12 @@ static const char *get_exit_reason(struct perf_kvm_stat *kvm,
 
 static void exit_event_decode_key(struct perf_kvm_stat *kvm,
 				  struct event_key *key,
-				  char decode[20])
+				  char *decode)
 {
 	const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
 						  key->key);
 
-	scnprintf(decode, 20, "%s", exit_reason);
+	scnprintf(decode, kvm->decode_str_len, "%s", exit_reason);
 }
 
 static struct kvm_events_ops exit_events = {
@@ -249,10 +253,11 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
 
 static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
 				  struct event_key *key,
-				  char decode[20])
+				  char *decode)
 {
-	scnprintf(decode, 20, "%#lx:%s", (unsigned long)key->key,
-				key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
+	scnprintf(decode, kvm->decode_str_len, "%#lx:%s",
+		  (unsigned long)key->key,
+		  key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
 }
 
 static struct kvm_events_ops mmio_events = {
@@ -292,10 +297,11 @@ static bool ioport_event_end(struct perf_evsel *evsel,
 
 static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
 				    struct event_key *key,
-				    char decode[20])
+				    char *decode)
 {
-	scnprintf(decode, 20, "%#llx:%s", (unsigned long long)key->key,
-				key->info ? "POUT" : "PIN");
+	scnprintf(decode, kvm->decode_str_len, "%#llx:%s",
+		  (unsigned long long)key->key,
+		  key->info ? "POUT" : "PIN");
 }
 
 static struct kvm_events_ops ioport_events = {
@@ -523,13 +529,13 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
 	time_diff = sample->time - time_begin;
 
 	if (kvm->duration && time_diff > kvm->duration) {
-		char decode[32];
+		char decode[DECODE_STR_LEN_MAX];
 
 		kvm->events_ops->decode_key(kvm, &event->key, decode);
 		if (strcmp(decode, "HLT")) {
-			pr_info("%" PRIu64 " VM %d, vcpu %d: %s event took %" PRIu64 "usec\n",
+			pr_info("%" PRIu64 " VM %d, vcpu %d: %*s event took %" PRIu64 "usec\n",
 				 sample->time, sample->pid, vcpu_record->vcpu_id,
-				 decode, time_diff/1000);
+				 32, decode, time_diff/1000);
 		}
 	}
 
@@ -738,7 +744,7 @@ static void show_timeofday(void)
 
 static void print_result(struct perf_kvm_stat *kvm)
 {
-	char decode[20];
+	char decode[DECODE_STR_LEN_MAX];
 	struct kvm_event *event;
 	int vcpu = kvm->trace_vcpu;
 
@@ -749,7 +755,7 @@ static void print_result(struct perf_kvm_stat *kvm)
 
 	pr_info("\n\n");
 	print_vcpu_info(kvm);
-	pr_info("%20s ", kvm->events_ops->name);
+	pr_info("%*s ", kvm->decode_str_len, kvm->events_ops->name);
 	pr_info("%10s ", "Samples");
 	pr_info("%9s ", "Samples%");
 
@@ -768,7 +774,7 @@ static void print_result(struct perf_kvm_stat *kvm)
 		min = get_event_min(event, vcpu);
 
 		kvm->events_ops->decode_key(kvm, &event->key, decode);
-		pr_info("%20s ", decode);
+		pr_info("%*s ", kvm->decode_str_len, decode);
 		pr_info("%10llu ", (unsigned long long)ecount);
 		pr_info("%8.2f%% ", (double)ecount / kvm->total_count * 100);
 		pr_info("%8.2f%% ", (double)etime / kvm->total_time * 100);
@@ -839,9 +845,11 @@ 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";
+		kvm->decode_str_len = 20;
 	} else if (strstr(cpuid, "AMD")) {
 		kvm->exit_reasons = svm_exit_reasons;
 		kvm->exit_reasons_isa = "SVM";
+		kvm->decode_str_len = 20;
 	} else {
 		pr_err("CPU %s is not supported.\n", cpuid);
 		return -ENOTSUP;
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/11] perf kvm: use defines of kvm events
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (7 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 08/11] perf kvm: allow for variable string sizes Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-05-05 13:33   ` Paolo Bonzini
  2014-04-25  9:12 ` [PATCH 10/11] perf: allow to use cpuinfo on s390 Christian Borntraeger
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

Currently perf-kvm uses string literals for kvm event names,
but it works only for x86, because other architectures may have
other names for those events.

This patch introduces defines for kvm_entry and kvm_exit events
and lets perf-kvm replace literals.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/x86/include/uapi/asm/kvm.h |  8 ++++++++
 tools/perf/builtin-kvm.c        | 10 ++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index d3a8778..88c0099 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -8,6 +8,8 @@
 
 #include <linux/types.h>
 #include <linux/ioctl.h>
+#include <asm/svm.h>
+#include <asm/vmx.h>
 
 #define DE_VECTOR 0
 #define DB_VECTOR 1
@@ -342,4 +344,10 @@ struct kvm_xcrs {
 struct kvm_sync_regs {
 };
 
+#define VCPU_ID "vcpu_id"
+
+#define KVM_ENTRY "kvm:kvm_entry"
+#define KVM_EXIT "kvm:kvm_exit"
+#define KVM_EXIT_REASON "exit_reason"
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 806c0e4..9a162ae 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -30,8 +30,6 @@
 #include <math.h>
 
 #ifdef HAVE_KVM_STAT_SUPPORT
-#include <asm/svm.h>
-#include <asm/vmx.h>
 #include <asm/kvm.h>
 
 struct event_key {
@@ -130,12 +128,12 @@ static void exit_event_get_key(struct perf_evsel *evsel,
 			       struct event_key *key)
 {
 	key->info = 0;
-	key->key = perf_evsel__intval(evsel, sample, "exit_reason");
+	key->key = perf_evsel__intval(evsel, sample, KVM_EXIT_REASON);
 }
 
 static bool kvm_exit_event(struct perf_evsel *evsel)
 {
-	return !strcmp(evsel->name, "kvm:kvm_exit");
+	return !strcmp(evsel->name, KVM_EXIT);
 }
 
 static bool exit_event_begin(struct perf_evsel *evsel,
@@ -151,7 +149,7 @@ static bool exit_event_begin(struct perf_evsel *evsel,
 
 static bool kvm_entry_event(struct perf_evsel *evsel)
 {
-	return !strcmp(evsel->name, "kvm:kvm_entry");
+	return !strcmp(evsel->name, KVM_ENTRY);
 }
 
 static bool exit_event_end(struct perf_evsel *evsel,
@@ -557,7 +555,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
 			return NULL;
 		}
 
-		vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, "vcpu_id");
+		vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, VCPU_ID);
 		thread->priv = vcpu_record;
 	}
 
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/11] perf: allow to use cpuinfo on s390
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (8 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 09/11] perf kvm: use defines of kvm events Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-04-25  9:12 ` [PATCH 11/11] perf kvm: add stat support " Christian Borntraeger
  2014-05-02  9:16 ` [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Jiri Olsa
  11 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

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>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 tools/perf/arch/s390/Makefile      |  1 +
 tools/perf/arch/s390/util/header.c | 17 +++++++++++++++++
 tools/perf/perf.h                  |  1 +
 3 files changed, 19 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
diff --git a/tools/perf/arch/s390/util/header.c b/tools/perf/arch/s390/util/header.c
new file mode 100644
index 0000000..8b2ed46
--- /dev/null
+++ b/tools/perf/arch/s390/util/header.c
@@ -0,0 +1,17 @@
+#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.h b/tools/perf/perf.h
index 5c11eca..6f6772d 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -43,6 +43,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.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/11] perf kvm: add stat support on s390
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (9 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 10/11] perf: allow to use cpuinfo on s390 Christian Borntraeger
@ 2014-04-25  9:12 ` Christian Borntraeger
  2014-05-05 10:43     ` Christian Borntraeger
  2014-05-02  9:16 ` [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Jiri Olsa
  11 siblings, 1 reply; 20+ messages in thread
From: Christian Borntraeger @ 2014-04-25  9:12 UTC (permalink / raw)
  To: Paolo Bonzini, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin,
	Christian Borntraeger

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

This patch allows perf to record SIE trace events, decode them and print
performance statistics.

Commands perf kvm stat record, report and stat are supported.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/uapi/asm/kvm.h |   7 ++
 tools/perf/MANIFEST              |   3 +
 tools/perf/arch/s390/Makefile    |   1 +
 tools/perf/builtin-kvm.c         | 151 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 159 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index 0fc2643..7ef3dd4 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -13,6 +13,7 @@
  *               Christian Borntraeger <borntraeger@de.ibm.com>
  */
 #include <linux/types.h>
+#include <asm/sie.h>
 
 #define __KVM_S390
 #define __KVM_HAVE_GUEST_DEBUG
@@ -128,4 +129,10 @@ struct kvm_sync_regs {
 #define KVM_REG_S390_PFSELECT	(KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x7)
 #define KVM_REG_S390_PP		(KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x8)
 #define KVM_REG_S390_GBEA	(KVM_REG_S390 | KVM_REG_SIZE_U64 | 0x9)
+
+#define VCPU_ID "id"
+
+#define KVM_ENTRY "kvm:kvm_s390_sie_enter"
+#define KVM_EXIT "kvm:kvm_s390_sie_exit"
+#define KVM_EXIT_REASON "icptcode"
 #endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index c0c87c8..021124d 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -35,3 +35,6 @@ arch/x86/include/asm/kvm_host.h
 arch/x86/include/uapi/asm/svm.h
 arch/x86/include/uapi/asm/vmx.h
 arch/x86/include/uapi/asm/kvm.h
+arch/s390/include/asm/sigp.h
+arch/s390/include/uapi/asm/sie.h
+arch/s390/include/uapi/asm/kvm.h
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 744e629..ddfdb80 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -3,3 +3,4 @@ PERF_HAVE_DWARF_REGS := 1
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
 endif
 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
+HAVE_KVM_STAT_SUPPORT := 1
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 9a162ae..7ca4d31 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -36,6 +36,7 @@ struct event_key {
 	#define INVALID_KEY     (~0ULL)
 	u64 key;
 	int info;
+	struct exit_reasons_table *exit_reasons;
 };
 
 struct kvm_event_stats {
@@ -70,6 +71,9 @@ struct kvm_events_ops {
 	bool (*is_begin_event)(struct perf_evsel *evsel,
 			       struct perf_sample *sample,
 			       struct event_key *key);
+	bool (*is_child_event)(struct perf_evsel *evsel,
+			       struct perf_sample *sample,
+			       struct event_key *key);
 	bool (*is_end_event)(struct perf_evsel *evsel,
 			     struct perf_sample *sample, struct event_key *key);
 	void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
@@ -82,6 +86,13 @@ struct exit_reasons_table {
 	const char *reason;
 };
 
+struct child_event_ops {
+	const char *name;
+	void (*get_key)(struct perf_evsel *evsel,
+			struct perf_sample *sample,
+			struct event_key *key);
+};
+
 #define DECODE_STR_LEN_MAX 80
 
 #define EVENTS_BITS		12
@@ -164,9 +175,84 @@ static bool exit_event_end(struct perf_evsel *evsel,
 		symbols, { -1, NULL }			\
 	}
 
+#if defined(__i386__) || defined(__x86_64__)
+
 define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
 define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
 
+static struct child_event_ops child_events[] = {};
+
+#elif defined(__s390x__)
+
+define_exit_reasons_table(sie_exit_reasons, sie_intercept_code);
+define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes);
+define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes);
+define_exit_reasons_table(sie_diagnose_codes, diagnose_codes);
+define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes);
+
+static void event_icpt_insn_get_key(struct perf_evsel *evsel,
+				    struct perf_sample *sample,
+				    struct event_key *key)
+{
+	unsigned long insn;
+	insn = perf_evsel__intval(evsel, sample, "instruction");
+	key->key = icpt_insn_decoder(insn);
+	key->exit_reasons = sie_icpt_insn_codes;
+}
+
+static void event_sigp_get_key(struct perf_evsel *evsel,
+			       struct perf_sample *sample,
+			       struct event_key *key)
+{
+	key->key = perf_evsel__intval(evsel, sample, "order_code");
+	key->exit_reasons = sie_sigp_order_codes;
+}
+
+static void event_diag_get_key(struct perf_evsel *evsel,
+			       struct perf_sample *sample,
+			       struct event_key *key)
+{
+	key->key = perf_evsel__intval(evsel, sample, "code");
+	key->exit_reasons = sie_diagnose_codes;
+}
+
+static void event_icpt_prog_get_key(struct perf_evsel *evsel,
+				    struct perf_sample *sample,
+				    struct event_key *key)
+{
+	key->key = perf_evsel__intval(evsel, sample, "code");
+	key->exit_reasons = sie_icpt_prog_codes;
+}
+
+static struct child_event_ops child_events[] = {
+	{ .name = "kvm:kvm_s390_intercept_instruction",
+	  .get_key = event_icpt_insn_get_key },
+	{ .name = "kvm:kvm_s390_handle_sigp",
+	  .get_key = event_sigp_get_key },
+	{ .name = "kvm:kvm_s390_handle_diag",
+	  .get_key = event_diag_get_key },
+	{ .name = "kvm:kvm_s390_intercept_prog",
+	  .get_key = event_icpt_prog_get_key },
+};
+#endif
+
+static bool exit_event_child(struct perf_evsel *evsel,
+			     struct perf_sample *sample,
+			     struct event_key *key)
+{
+	int i;
+	int nevents = ARRAY_SIZE(child_events);
+
+	for (i = 0; i < nevents; i++) {
+		if (!strcmp(evsel->name, child_events[i].name)) {
+			child_events[i].get_key(evsel, sample, key);
+			return true;
+		}
+	}
+
+	return false;
+}
+
 static const char *get_exit_reason(struct perf_kvm_stat *kvm,
 				   struct exit_reasons_table *tbl,
 				   u64 exit_code)
@@ -186,7 +272,7 @@ static void exit_event_decode_key(struct perf_kvm_stat *kvm,
 				  struct event_key *key,
 				  char *decode)
 {
-	const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
+	const char *exit_reason = get_exit_reason(kvm, key->exit_reasons,
 						  key->key);
 
 	scnprintf(decode, kvm->decode_str_len, "%s", exit_reason);
@@ -195,10 +281,12 @@ static void exit_event_decode_key(struct perf_kvm_stat *kvm,
 static struct kvm_events_ops exit_events = {
 	.is_begin_event = exit_event_begin,
 	.is_end_event = exit_event_end,
+	.is_child_event = exit_event_child,
 	.decode_key = exit_event_decode_key,
 	.name = "VM-EXIT"
 };
 
+#if defined(__i386__) || defined(__x86_64__)
 /*
  * For the mmio events, we treat:
  * the time of MMIO write: kvm_mmio(KVM_TRACE_MMIO_WRITE...) -> kvm_entry
@@ -308,6 +396,7 @@ static struct kvm_events_ops ioport_events = {
 	.decode_key = ioport_event_decode_key,
 	.name = "IO Port Access"
 };
+#endif
 
 static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
 {
@@ -315,10 +404,12 @@ static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
 
 	if (!strcmp(kvm->report_event, "vmexit"))
 		kvm->events_ops = &exit_events;
+#if defined(__i386__) || defined(__x86_64__)
 	else if (!strcmp(kvm->report_event, "mmio"))
 		kvm->events_ops = &mmio_events;
 	else if (!strcmp(kvm->report_event, "ioport"))
 		kvm->events_ops = &ioport_events;
+#endif
 	else {
 		pr_err("Unknown report event:%s\n", kvm->report_event);
 		ret = false;
@@ -530,16 +621,38 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
 		char decode[DECODE_STR_LEN_MAX];
 
 		kvm->events_ops->decode_key(kvm, &event->key, decode);
+
+#if defined(__i386__) || defined(__x86_64__)
 		if (strcmp(decode, "HLT")) {
 			pr_info("%" PRIu64 " VM %d, vcpu %d: %*s event took %" PRIu64 "usec\n",
 				 sample->time, sample->pid, vcpu_record->vcpu_id,
 				 32, decode, time_diff/1000);
 		}
+
+#elif defined(__s390x__)
+		pr_info("%" PRIu64 " VM %d, vcpu %d: %*s event took %" PRIu64 "usec\n",
+			sample->time, sample->pid, vcpu_record->vcpu_id,
+			kvm->decode_str_len, decode, time_diff/1000);
+#endif
 	}
 
 	return update_kvm_event(event, vcpu, time_diff);
 }
 
+static bool handle_child_event(struct perf_kvm_stat *kvm,
+			       struct vcpu_event_record *vcpu_record,
+			       struct event_key *key)
+{
+	struct kvm_event *event = NULL;
+
+	if (key->key != INVALID_KEY)
+		event = find_create_kvm_event(kvm, key);
+
+	vcpu_record->last_event = event;
+
+	return true;
+}
+
 static
 struct vcpu_event_record *per_vcpu_record(struct thread *thread,
 					  struct perf_evsel *evsel,
@@ -568,7 +681,8 @@ static bool handle_kvm_event(struct perf_kvm_stat *kvm,
 			     struct perf_sample *sample)
 {
 	struct vcpu_event_record *vcpu_record;
-	struct event_key key = {.key = INVALID_KEY};
+	struct event_key key = { .key = INVALID_KEY,
+				 .exit_reasons = kvm->exit_reasons };
 
 	vcpu_record = per_vcpu_record(thread, evsel, sample);
 	if (!vcpu_record)
@@ -582,6 +696,9 @@ static bool handle_kvm_event(struct perf_kvm_stat *kvm,
 	if (kvm->events_ops->is_begin_event(evsel, sample, &key))
 		return handle_begin_event(kvm, vcpu_record, &key, sample->time);
 
+	if (kvm->events_ops->is_child_event(evsel, sample, &key))
+		return handle_child_event(kvm, vcpu_record, &key);
+
 	if (kvm->events_ops->is_end_event(evsel, sample, &key))
 		return handle_end_event(kvm, vcpu_record, &key, sample);
 
@@ -838,6 +955,7 @@ static int process_sample_event(struct perf_tool *tool,
 	return 0;
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 static int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
 {
 	if (strstr(cpuid, "Intel")) {
@@ -856,6 +974,22 @@ static int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
 	return 0;
 }
 
+#elif defined(__s390x__)
+static int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
+{
+	if (strstr(cpuid, "IBM/S390")) {
+		kvm->exit_reasons = sie_exit_reasons;
+		kvm->decode_str_len = 40;
+		kvm->exit_reasons_isa = "SIE";
+	} else {
+		pr_err("CPU %s is not supported.\n", cpuid);
+		return -ENOTSUP;
+	}
+
+	return 0;
+}
+#endif
+
 static int cpu_isa_config(struct perf_kvm_stat *kvm)
 {
 	char buf[64], *cpuid;
@@ -864,7 +998,7 @@ static int cpu_isa_config(struct perf_kvm_stat *kvm)
 	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;
@@ -1310,12 +1444,23 @@ exit:
 	return ret;
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 static const char * const kvm_events_tp[] = {
 	"kvm:kvm_entry",
 	"kvm:kvm_exit",
 	"kvm:kvm_mmio",
 	"kvm:kvm_pio",
 };
+#elif defined(__s390x__)
+static const char * const kvm_events_tp[] = {
+	"kvm:kvm_s390_sie_enter",
+	"kvm:kvm_s390_sie_exit",
+	"kvm:kvm_s390_intercept_instruction",
+	"kvm:kvm_s390_handle_sigp",
+	"kvm:kvm_s390_handle_diag",
+	"kvm:kvm_s390_intercept_prog",
+};
+#endif
 
 #define STRDUP_FAIL_EXIT(s)		\
 	({	char *_p;		\
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat
  2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
                   ` (10 preceding siblings ...)
  2014-04-25  9:12 ` [PATCH 11/11] perf kvm: add stat support " Christian Borntraeger
@ 2014-05-02  9:16 ` Jiri Olsa
  2014-05-02 18:14   ` David Ahern
  11 siblings, 1 reply; 20+ messages in thread
From: Jiri Olsa @ 2014-05-02  9:16 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Paolo Bonzini, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin, David Ahern

On Fri, Apr 25, 2014 at 11:12:22AM +0200, Christian Borntraeger wrote:
> The goal of this series is to
> - enable perf kvm stat on s390
> - get rid of a perf warning "insn_to_mnemonic not found" when it tries to
>   decode s390 perf trace events

perf tools changes look good to me

> 
> Review feedback is welcome.

CC-ing David Ahern

jirka

> In addition, The patch set touches s390/kvm code and perf code.
> So any feedback on which tree to use for this series is also 
> welcome.
> 
> Christian
> 
> 
> Alexander Yarygin (11):
>   s390: add sie exit reasons tables
>   KVM: s390: Use trace tables from sie.h.
>   KVM: s390: decoder of SIE intercepted instructions
>   KVM: s390: Use intercept_insn decoder in trace event
>   perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag
>   perf kvm: simplify of exit reasons tables definitions
>   perf kvm: Refactoring of cpu_isa_config()
>   perf kvm: allow for variable string sizes
>   perf kvm: use defines of kvm events
>   perf: allow to use cpuinfo on s390
>   perf kvm: add stat support on s390
> 
>  arch/s390/include/uapi/asm/kvm.h   |   7 +
>  arch/s390/include/uapi/asm/sie.h   | 245 ++++++++++++++++++++++++++++++++++
>  arch/s390/kvm/trace.h              |  39 +-----
>  arch/x86/include/uapi/asm/kvm.h    |   8 ++
>  tools/perf/MANIFEST                |   3 +
>  tools/perf/arch/s390/Makefile      |   2 +
>  tools/perf/arch/s390/util/header.c |  17 +++
>  tools/perf/arch/x86/Makefile       |   1 +
>  tools/perf/builtin-kvm.c           | 263 +++++++++++++++++++++++++++++--------
>  tools/perf/config/Makefile         |   4 +
>  tools/perf/perf.h                  |   1 +
>  11 files changed, 499 insertions(+), 91 deletions(-)
>  create mode 100644 arch/s390/include/uapi/asm/sie.h
>  create mode 100644 tools/perf/arch/s390/util/header.c
> 
> -- 
> 1.8.4.2
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat
  2014-05-02  9:16 ` [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Jiri Olsa
@ 2014-05-02 18:14   ` David Ahern
  2014-05-05 10:36     ` Christian Borntraeger
  0 siblings, 1 reply; 20+ messages in thread
From: David Ahern @ 2014-05-02 18:14 UTC (permalink / raw)
  To: Jiri Olsa, Christian Borntraeger
  Cc: Paolo Bonzini, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin

On 5/2/14, 3:16 AM, Jiri Olsa wrote:
> On Fri, Apr 25, 2014 at 11:12:22AM +0200, Christian Borntraeger wrote:
>> The goal of this series is to
>> - enable perf kvm stat on s390
>> - get rid of a perf warning "insn_to_mnemonic not found" when it tries to
>>    decode s390 perf trace events
>
> perf tools changes look good to me
>
>>
>> Review feedback is welcome.
>
> CC-ing David Ahern
>
I don't have the original emails, but looking at
https://lkml.org/lkml/2014/4/25/331


[PATCH 01/11] s390: add sie exit reasons tables
[PATCH 02/11] KVM: s390: Use trace tables from sie.h
[PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions
[PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event
- not perf related


[PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag
[PATCH 06/11] perf kvm: simplify of exit reasons tables definitions
[PATCH 07/11] perf kvm: Refactoring of cpu_isa_config()
[PATCH 10/11] perf: allow to use cpuinfo on s390
Reviewed-by: David Ahern <dsahern@gmail.com>


[PATCH 09/11] perf kvm: use defines of kvm events
- KVM team should ack kvm.h change
- perf side looks fine to me

[PATCH 11/11] perf kvm: add stat support on s390
- like to see the arch bits moved to arch/x86 and arch/s390 rather than 
adding #ifdefs
- disabling ioport and mmio options is ok, but if you are going to 
compile it out update the documentation accordingly.

David

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/11] perf kvm: allow for variable string sizes
  2014-04-25  9:12 ` [PATCH 08/11] perf kvm: allow for variable string sizes Christian Borntraeger
@ 2014-05-05 10:27   ` Christian Borntraeger
  2014-05-05 15:29     ` David Ahern
  0 siblings, 1 reply; 20+ messages in thread
From: Christian Borntraeger @ 2014-05-05 10:27 UTC (permalink / raw)
  To: David Ahern
  Cc: Paolo Bonzini, Jiri Olsa, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin

David,

thanks for the review. 

Are you ok with this change as well? The alternative is to shorten our descriptions (in 1/11 s390: add sie exit reasons tables), which would make the trace output less comprehensible, though.

Christian

On 25/04/14 11:12, Christian Borntraeger wrote:
> From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
> 
> This makes it possible for other architectures to decode to different
> string lengths.
> 
> Needed by follow-up patch "perf kvm: add stat support on s390".
> 
> Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  tools/perf/builtin-kvm.c | 38 +++++++++++++++++++++++---------------
>  1 file changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 922706c..806c0e4 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -75,7 +75,7 @@ struct kvm_events_ops {
>  	bool (*is_end_event)(struct perf_evsel *evsel,
>  			     struct perf_sample *sample, struct event_key *key);
>  	void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
> -			   char decode[20]);
> +			   char *decode);
>  	const char *name;
>  };
> 
> @@ -84,6 +84,8 @@ struct exit_reasons_table {
>  	const char *reason;
>  };
> 
> +#define DECODE_STR_LEN_MAX 80
> +
>  #define EVENTS_BITS		12
>  #define EVENTS_CACHE_SIZE	(1UL << EVENTS_BITS)
> 
> @@ -101,6 +103,8 @@ struct perf_kvm_stat {
>  	struct exit_reasons_table *exit_reasons;
>  	const char *exit_reasons_isa;
> 
> +	int decode_str_len;
> +
>  	struct kvm_events_ops *events_ops;
>  	key_cmp_fun compare;
>  	struct list_head kvm_events_cache[EVENTS_CACHE_SIZE];
> @@ -182,12 +186,12 @@ static const char *get_exit_reason(struct perf_kvm_stat *kvm,
> 
>  static void exit_event_decode_key(struct perf_kvm_stat *kvm,
>  				  struct event_key *key,
> -				  char decode[20])
> +				  char *decode)
>  {
>  	const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
>  						  key->key);
> 
> -	scnprintf(decode, 20, "%s", exit_reason);
> +	scnprintf(decode, kvm->decode_str_len, "%s", exit_reason);
>  }
> 
>  static struct kvm_events_ops exit_events = {
> @@ -249,10 +253,11 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
> 
>  static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
>  				  struct event_key *key,
> -				  char decode[20])
> +				  char *decode)
>  {
> -	scnprintf(decode, 20, "%#lx:%s", (unsigned long)key->key,
> -				key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
> +	scnprintf(decode, kvm->decode_str_len, "%#lx:%s",
> +		  (unsigned long)key->key,
> +		  key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
>  }
> 
>  static struct kvm_events_ops mmio_events = {
> @@ -292,10 +297,11 @@ static bool ioport_event_end(struct perf_evsel *evsel,
> 
>  static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
>  				    struct event_key *key,
> -				    char decode[20])
> +				    char *decode)
>  {
> -	scnprintf(decode, 20, "%#llx:%s", (unsigned long long)key->key,
> -				key->info ? "POUT" : "PIN");
> +	scnprintf(decode, kvm->decode_str_len, "%#llx:%s",
> +		  (unsigned long long)key->key,
> +		  key->info ? "POUT" : "PIN");
>  }
> 
>  static struct kvm_events_ops ioport_events = {
> @@ -523,13 +529,13 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
>  	time_diff = sample->time - time_begin;
> 
>  	if (kvm->duration && time_diff > kvm->duration) {
> -		char decode[32];
> +		char decode[DECODE_STR_LEN_MAX];
> 
>  		kvm->events_ops->decode_key(kvm, &event->key, decode);
>  		if (strcmp(decode, "HLT")) {
> -			pr_info("%" PRIu64 " VM %d, vcpu %d: %s event took %" PRIu64 "usec\n",
> +			pr_info("%" PRIu64 " VM %d, vcpu %d: %*s event took %" PRIu64 "usec\n",
>  				 sample->time, sample->pid, vcpu_record->vcpu_id,
> -				 decode, time_diff/1000);
> +				 32, decode, time_diff/1000);
>  		}
>  	}
> 
> @@ -738,7 +744,7 @@ static void show_timeofday(void)
> 
>  static void print_result(struct perf_kvm_stat *kvm)
>  {
> -	char decode[20];
> +	char decode[DECODE_STR_LEN_MAX];
>  	struct kvm_event *event;
>  	int vcpu = kvm->trace_vcpu;
> 
> @@ -749,7 +755,7 @@ static void print_result(struct perf_kvm_stat *kvm)
> 
>  	pr_info("\n\n");
>  	print_vcpu_info(kvm);
> -	pr_info("%20s ", kvm->events_ops->name);
> +	pr_info("%*s ", kvm->decode_str_len, kvm->events_ops->name);
>  	pr_info("%10s ", "Samples");
>  	pr_info("%9s ", "Samples%");
> 
> @@ -768,7 +774,7 @@ static void print_result(struct perf_kvm_stat *kvm)
>  		min = get_event_min(event, vcpu);
> 
>  		kvm->events_ops->decode_key(kvm, &event->key, decode);
> -		pr_info("%20s ", decode);
> +		pr_info("%*s ", kvm->decode_str_len, decode);
>  		pr_info("%10llu ", (unsigned long long)ecount);
>  		pr_info("%8.2f%% ", (double)ecount / kvm->total_count * 100);
>  		pr_info("%8.2f%% ", (double)etime / kvm->total_time * 100);
> @@ -839,9 +845,11 @@ 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";
> +		kvm->decode_str_len = 20;
>  	} else if (strstr(cpuid, "AMD")) {
>  		kvm->exit_reasons = svm_exit_reasons;
>  		kvm->exit_reasons_isa = "SVM";
> +		kvm->decode_str_len = 20;
>  	} else {
>  		pr_err("CPU %s is not supported.\n", cpuid);
>  		return -ENOTSUP;
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat
  2014-05-02 18:14   ` David Ahern
@ 2014-05-05 10:36     ` Christian Borntraeger
  0 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-05-05 10:36 UTC (permalink / raw)
  To: David Ahern, Jiri Olsa
  Cc: Paolo Bonzini, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin

On 02/05/14 20:14, David Ahern wrote:
> On 5/2/14, 3:16 AM, Jiri Olsa wrote:
[...]
>> CC-ing David Ahern
>>
> I don't have the original emails, but looking at
> https://lkml.org/lkml/2014/4/25/331
> 
> 
> [PATCH 01/11] s390: add sie exit reasons tables
> [PATCH 02/11] KVM: s390: Use trace tables from sie.h
> [PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions
> [PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event
> - not perf related
> 
> 
> [PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag
> [PATCH 06/11] perf kvm: simplify of exit reasons tables definitions
> [PATCH 07/11] perf kvm: Refactoring of cpu_isa_config()
> [PATCH 10/11] perf: allow to use cpuinfo on s390
> Reviewed-by: David Ahern <dsahern@gmail.com>
> 
> 
> [PATCH 09/11] perf kvm: use defines of kvm events
> - KVM team should ack kvm.h change

Paolo,
any chance to ack these changes?


> - perf side looks fine to me
> 
> [PATCH 11/11] perf kvm: add stat support on s390
> - like to see the arch bits moved to arch/x86 and arch/s390 rather than adding #ifdefs
> - disabling ioport and mmio options is ok, but if you are going to compile it out update the documentation accordingly.
> 
> David
> 

Thanks.

Question is now how to proceed:

Patch 1-4 are s390/kvm specific. I am s390/kvm maintainer, so I can hereby Ack them.
Patch 5-10 are perf specific
Patch 11 is s390/kvm/perf specific and needs both patch series as a base.

I see several variants for the next submission:

a: all patches via Paolos KVM tree
b: all patches via perf tree  (e.g. via Jiri)
c: via both trees. (e.g. I prepare a git branch based on 3.15-rc1 so that during next merge window the common history should make most things work out fine)
d: patch 1-4 via KVM, patch 5-10 via perf, patch 11 after both trees are merged into Linus

Christian


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/11] perf kvm: add stat support on s390
  2014-04-25  9:12 ` [PATCH 11/11] perf kvm: add stat support " Christian Borntraeger
@ 2014-05-05 10:43     ` Christian Borntraeger
  0 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-05-05 10:43 UTC (permalink / raw)
  Cc: Paolo Bonzini, Jiri Olsa, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin, David Ahern

On 25/04/14 11:12, Christian Borntraeger wrote:
> +#if defined(__i386__) || defined(__x86_64__)
>  	else if (!strcmp(kvm->report_event, "mmio"))
>  		kvm->events_ops = &mmio_events;
>  	else if (!strcmp(kvm->report_event, "ioport"))
>  		kvm->events_ops = &ioport_events;
> +#endif

To address Davids review, the next version will have this hunk as well:

diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt
index 52276a6..e974749 100644
--- a/tools/perf/Documentation/perf-kvm.txt
+++ b/tools/perf/Documentation/perf-kvm.txt
@@ -103,8 +103,8 @@ STAT REPORT OPTIONS
        analyze events which occures on this vcpu. (default: all vcpus)
 
 --event=<value>::
-       event to be analyzed. Possible values: vmexit, mmio, ioport.
-       (default: vmexit)
+       event to be analyzed. Possible values: vmexit, mmio (x86 only),
+       ioport (x86 only). (default: vmexit)
 -k::
 --key=<value>::
        Sorting key. Possible values: sample (default, sort by samples


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/11] perf kvm: add stat support on s390
@ 2014-05-05 10:43     ` Christian Borntraeger
  0 siblings, 0 replies; 20+ messages in thread
From: Christian Borntraeger @ 2014-05-05 10:43 UTC (permalink / raw)
  Cc: Paolo Bonzini, Jiri Olsa, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin, David Ahern

On 25/04/14 11:12, Christian Borntraeger wrote:
> +#if defined(__i386__) || defined(__x86_64__)
>  	else if (!strcmp(kvm->report_event, "mmio"))
>  		kvm->events_ops = &mmio_events;
>  	else if (!strcmp(kvm->report_event, "ioport"))
>  		kvm->events_ops = &ioport_events;
> +#endif

To address Davids review, the next version will have this hunk as well:

diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt
index 52276a6..e974749 100644
--- a/tools/perf/Documentation/perf-kvm.txt
+++ b/tools/perf/Documentation/perf-kvm.txt
@@ -103,8 +103,8 @@ STAT REPORT OPTIONS
        analyze events which occures on this vcpu. (default: all vcpus)
 
 --event=<value>::
-       event to be analyzed. Possible values: vmexit, mmio, ioport.
-       (default: vmexit)
+       event to be analyzed. Possible values: vmexit, mmio (x86 only),
+       ioport (x86 only). (default: vmexit)
 -k::
 --key=<value>::
        Sorting key. Possible values: sample (default, sort by samples

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 09/11] perf kvm: use defines of kvm events
  2014-04-25  9:12 ` [PATCH 09/11] perf kvm: use defines of kvm events Christian Borntraeger
@ 2014-05-05 13:33   ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2014-05-05 13:33 UTC (permalink / raw)
  To: Christian Borntraeger, Jiri Olsa
  Cc: KVM, linux-s390, Cornelia Huck, Arnaldo Carvalho de Melo,
	linux-kernel, Ingo Molnar, Alexander Yarygin

Il 25/04/2014 11:12, Christian Borntraeger ha scritto:
> From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
>
> Currently perf-kvm uses string literals for kvm event names,
> but it works only for x86, because other architectures may have
> other names for those events.
>
> This patch introduces defines for kvm_entry and kvm_exit events
> and lets perf-kvm replace literals.
>
> Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/x86/include/uapi/asm/kvm.h |  8 ++++++++
>  tools/perf/builtin-kvm.c        | 10 ++++------
>  2 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
> index d3a8778..88c0099 100644
> --- a/arch/x86/include/uapi/asm/kvm.h
> +++ b/arch/x86/include/uapi/asm/kvm.h
> @@ -8,6 +8,8 @@
>
>  #include <linux/types.h>
>  #include <linux/ioctl.h>
> +#include <asm/svm.h>
> +#include <asm/vmx.h>
>
>  #define DE_VECTOR 0
>  #define DB_VECTOR 1
> @@ -342,4 +344,10 @@ struct kvm_xcrs {
>  struct kvm_sync_regs {
>  };
>
> +#define VCPU_ID "vcpu_id"
> +
> +#define KVM_ENTRY "kvm:kvm_entry"
> +#define KVM_EXIT "kvm:kvm_exit"
> +#define KVM_EXIT_REASON "exit_reason"
> +
>  #endif /* _ASM_X86_KVM_H */

What about adding a new asm/kvm-perf.h header instead?

1) I don't like very much the namespace pollution that the first hunk 
causes (and the second one isn't really pretty either).

2) perf doesn't need most of uapi/asm/kvm.h, in fact it only needs a 
couple of #defines because it is a dependency of uapi/asm/svm.h.  So it 
is uapi/asm/svm.h that should include uapi/asm/kvm.h, not perf.

Paolo

> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index 806c0e4..9a162ae 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -30,8 +30,6 @@
>  #include <math.h>
>
>  #ifdef HAVE_KVM_STAT_SUPPORT
> -#include <asm/svm.h>
> -#include <asm/vmx.h>
>  #include <asm/kvm.h>
>
>  struct event_key {
> @@ -130,12 +128,12 @@ static void exit_event_get_key(struct perf_evsel *evsel,
>  			       struct event_key *key)
>  {
>  	key->info = 0;
> -	key->key = perf_evsel__intval(evsel, sample, "exit_reason");
> +	key->key = perf_evsel__intval(evsel, sample, KVM_EXIT_REASON);
>  }
>
>  static bool kvm_exit_event(struct perf_evsel *evsel)
>  {
> -	return !strcmp(evsel->name, "kvm:kvm_exit");
> +	return !strcmp(evsel->name, KVM_EXIT);
>  }
>
>  static bool exit_event_begin(struct perf_evsel *evsel,
> @@ -151,7 +149,7 @@ static bool exit_event_begin(struct perf_evsel *evsel,
>
>  static bool kvm_entry_event(struct perf_evsel *evsel)
>  {
> -	return !strcmp(evsel->name, "kvm:kvm_entry");
> +	return !strcmp(evsel->name, KVM_ENTRY);
>  }
>
>  static bool exit_event_end(struct perf_evsel *evsel,
> @@ -557,7 +555,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
>  			return NULL;
>  		}
>
> -		vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, "vcpu_id");
> +		vcpu_record->vcpu_id = perf_evsel__intval(evsel, sample, VCPU_ID);
>  		thread->priv = vcpu_record;
>  	}
>
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/11] perf kvm: allow for variable string sizes
  2014-05-05 10:27   ` Christian Borntraeger
@ 2014-05-05 15:29     ` David Ahern
  0 siblings, 0 replies; 20+ messages in thread
From: David Ahern @ 2014-05-05 15:29 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Paolo Bonzini, Jiri Olsa, KVM, linux-s390, Cornelia Huck,
	Arnaldo Carvalho de Melo, linux-kernel, Ingo Molnar,
	Alexander Yarygin

On 5/5/14, 4:27 AM, Christian Borntraeger wrote:
>> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
>> index 922706c..806c0e4 100644
>> --- a/tools/perf/builtin-kvm.c
>> +++ b/tools/perf/builtin-kvm.c
>> @@ -75,7 +75,7 @@ struct kvm_events_ops {
>>   	bool (*is_end_event)(struct perf_evsel *evsel,
>>   			     struct perf_sample *sample, struct event_key *key);
>>   	void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
>> -			   char decode[20]);
>> +			   char *decode);
>>   	const char *name;
>>   };
>>
>> @@ -84,6 +84,8 @@ struct exit_reasons_table {
>>   	const char *reason;
>>   };
>>
>> +#define DECODE_STR_LEN_MAX 80
>> +
>>   #define EVENTS_BITS		12
>>   #define EVENTS_CACHE_SIZE	(1UL << EVENTS_BITS)
>>
>> @@ -101,6 +103,8 @@ struct perf_kvm_stat {
>>   	struct exit_reasons_table *exit_reasons;
>>   	const char *exit_reasons_isa;
>>
>> +	int decode_str_len;
>> +

This should not be a part of the perf_kvm_stat struct. Just leave it as 
a macro and use DECODE_STR_LEN_MAX in place of 20. Which means 
DECODE_STR_LEN_MAX needs to be 20 in this patch, and arch specific in 
the follow up patch.

>>   	struct kvm_events_ops *events_ops;
>>   	key_cmp_fun compare;
>>   	struct list_head kvm_events_cache[EVENTS_CACHE_SIZE];
>> @@ -182,12 +186,12 @@ static const char *get_exit_reason(struct perf_kvm_stat *kvm,
>>
>>   static void exit_event_decode_key(struct perf_kvm_stat *kvm,
>>   				  struct event_key *key,
>> -				  char decode[20])
>> +				  char *decode)
>>   {
>>   	const char *exit_reason = get_exit_reason(kvm, kvm->exit_reasons,
>>   						  key->key);
>>
>> -	scnprintf(decode, 20, "%s", exit_reason);
>> +	scnprintf(decode, kvm->decode_str_len, "%s", exit_reason);
>>   }
>>
>>   static struct kvm_events_ops exit_events = {
>> @@ -249,10 +253,11 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
>>
>>   static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
>>   				  struct event_key *key,
>> -				  char decode[20])
>> +				  char *decode)
>>   {
>> -	scnprintf(decode, 20, "%#lx:%s", (unsigned long)key->key,
>> -				key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
>> +	scnprintf(decode, kvm->decode_str_len, "%#lx:%s",
>> +		  (unsigned long)key->key,
>> +		  key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R");
>>   }
>>
>>   static struct kvm_events_ops mmio_events = {
>> @@ -292,10 +297,11 @@ static bool ioport_event_end(struct perf_evsel *evsel,
>>
>>   static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
>>   				    struct event_key *key,
>> -				    char decode[20])
>> +				    char *decode)
>>   {
>> -	scnprintf(decode, 20, "%#llx:%s", (unsigned long long)key->key,
>> -				key->info ? "POUT" : "PIN");
>> +	scnprintf(decode, kvm->decode_str_len, "%#llx:%s",
>> +		  (unsigned long long)key->key,
>> +		  key->info ? "POUT" : "PIN");
>>   }
>>
>>   static struct kvm_events_ops ioport_events = {
>> @@ -523,13 +529,13 @@ static bool handle_end_event(struct perf_kvm_stat *kvm,
>>   	time_diff = sample->time - time_begin;
>>
>>   	if (kvm->duration && time_diff > kvm->duration) {
>> -		char decode[32];
>> +		char decode[DECODE_STR_LEN_MAX];
>>
>>   		kvm->events_ops->decode_key(kvm, &event->key, decode);
>>   		if (strcmp(decode, "HLT")) {
>> -			pr_info("%" PRIu64 " VM %d, vcpu %d: %s event took %" PRIu64 "usec\n",
>> +			pr_info("%" PRIu64 " VM %d, vcpu %d: %*s event took %" PRIu64 "usec\n",
>>   				 sample->time, sample->pid, vcpu_record->vcpu_id,
>> -				 decode, time_diff/1000);
>> +				 32, decode, time_diff/1000);

This pr_info does not need the length.

David

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-05-05 15:29 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25  9:12 [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Christian Borntraeger
2014-04-25  9:12 ` [PATCH 01/11] s390: add sie exit reasons tables Christian Borntraeger
2014-04-25  9:12 ` [PATCH 02/11] KVM: s390: Use trace tables from sie.h Christian Borntraeger
2014-04-25  9:12 ` [PATCH 03/11] KVM: s390: decoder of SIE intercepted instructions Christian Borntraeger
2014-04-25  9:12 ` [PATCH 04/11] KVM: s390: Use intercept_insn decoder in trace event Christian Borntraeger
2014-04-25  9:12 ` [PATCH 05/11] perf kvm: Intoduce HAVE_KVM_STAT_SUPPORT flag Christian Borntraeger
2014-04-25  9:12 ` [PATCH 06/11] perf kvm: simplify of exit reasons tables definitions Christian Borntraeger
2014-04-25  9:12 ` [PATCH 07/11] perf kvm: Refactoring of cpu_isa_config() Christian Borntraeger
2014-04-25  9:12 ` [PATCH 08/11] perf kvm: allow for variable string sizes Christian Borntraeger
2014-05-05 10:27   ` Christian Borntraeger
2014-05-05 15:29     ` David Ahern
2014-04-25  9:12 ` [PATCH 09/11] perf kvm: use defines of kvm events Christian Borntraeger
2014-05-05 13:33   ` Paolo Bonzini
2014-04-25  9:12 ` [PATCH 10/11] perf: allow to use cpuinfo on s390 Christian Borntraeger
2014-04-25  9:12 ` [PATCH 11/11] perf kvm: add stat support " Christian Borntraeger
2014-05-05 10:43   ` Christian Borntraeger
2014-05-05 10:43     ` Christian Borntraeger
2014-05-02  9:16 ` [PATCH/RFC 00/11] perf/s390/kvm: trace events, perf kvm stat Jiri Olsa
2014-05-02 18:14   ` David Ahern
2014-05-05 10:36     ` Christian Borntraeger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.