File oprofile-support-for-power9.patch of Package oprofile

From: Will Schmidt <will_schmidt@vnet.ibm.com>
Date: Tue, 6 Jun 2017 10:52:00 -0500
Subject: 1/2 Oprofile support for Power9
Git-repo: git://git.code.sf.net/p/oprofile/oprofile
Git-commit: ce5842f112d155a7148a44a7863cf4355c1385e0
References: FATE#321458

[adjust for context:
  doc/oprofile.xml no 0c142c3a0
  libop/op_cpu_type.[ch] no 966ef44b8 (s390/z13) or 8b82ba96b (arm/armv7-ca)
  events/Makefile.am no 0c142c3a0
  libop/op_events.c no 0c142c3a0
  utils/ophelp.c no 0c142c3a0
]

Hi,

Add initial support for PPC64/Power9 to oprofile.
This includes the documentation updates to indicate "power9",
the PVR values, and all the other updates that will be necessary.
(This is based on a review of changes made when Power8 support
was initially added).
The long-ish event list follows as a subsequent patch.

Signed-off-by:  Will Schmidt <will_schmidt@vnet.ibm.com>

--

Signed-off-by: Tony Jones <tonyj@suse.de>
---
 doc/oprofile.xml               |    2 +-
 events/Makefile.am             |    1 +
 events/ppc64/power9/events     |    8 ++++++++
 events/ppc64/power9/unit_masks |    9 +++++++++
 libop/op_cpu_type.c            |    1 +
 libop/op_cpu_type.h            |    1 +
 libop/op_events.c              |    1 +
 utils/ophelp.c                 |    6 ++++++
 8 files changed, 28 insertions(+), 1 deletion(-)

--- a/doc/oprofile.xml
+++ b/doc/oprofile.xml
@@ -645,7 +645,7 @@ can be used for <command>ocount</command
 <row><entry>Itanium</entry><entry>ia64/itanium</entry><entry>CPU_CYCLES:100000:0:1:1</entry></row>
 <row><entry>Itanium 2</entry><entry>ia64/itanium2</entry><entry>CPU_CYCLES:100000:0:1:1</entry></row>
 <row><entry>TIMER_INT</entry><entry>timer</entry><entry>None selectable</entry></row>
-<row><entry>IBM pseries</entry><entry>PowerPC 4/5/6/7/8/970/Cell</entry><entry>CYCLES:100000:0:1:1</entry></row>
+<row><entry>IBM pseries</entry><entry>PowerPC 4/5/6/7/8/9/970/Cell</entry><entry>CYCLES:100000:0:1:1</entry></row>
 <row><entry>IBM s390</entry><entry>timer</entry><entry>None selectable</entry></row>
 <row><entry>IBM s390x</entry><entry>timer</entry><entry>None selectable</entry></row>
 </tbody>
--- a/events/Makefile.am
+++ b/events/Makefile.am
@@ -37,6 +37,7 @@ event_files = \
 	ppc64/power6/events ppc64/power6/event_mappings ppc64/power6/unit_masks \
 	ppc64/power7/events ppc64/power7/event_mappings ppc64/power7/unit_masks \
 	ppc64/power8/events ppc64/power8/unit_masks \
+	ppc64/power9/events ppc64/power9/unit_masks \
 	ppc64/970/events ppc64/970/event_mappings ppc64/970/unit_masks \
 	ppc64/970MP/events ppc64/970MP/event_mappings ppc64/970MP/unit_masks \
 	ppc64/ibm-compat-v1/events ppc64/ibm-compat-v1/event_mappings ppc64/ibm-compat-v1/unit_masks \
--- /dev/null
+++ b/events/ppc64/power9/events
@@ -0,0 +1,8 @@
+
+#  Copyright OProfile authors
+#  Copyright (c) International Business Machines, 2017.
+#  Contributed by Will Schmidt <will_schmidt@vnet.ibm.com>.
+#
+#  IBM POWER9 Events
+
+include:ppc64/architected_events_v1
--- /dev/null
+++ b/events/ppc64/power9/unit_masks
@@ -0,0 +1,9 @@
+#
+# Copyright OProfile authors
+# Copyright (c) International Business Machines, 2017.
+# Contributed by Will Schmidt <will_schmidt@vnet.ibm.com>
+#
+# ppc64 POWER9 possible unit masks
+#
+name:zero type:mandatory default:0x0
+	0x0 No unit mask
--- a/libop/op_cpu_type.c
+++ b/libop/op_cpu_type.c
@@ -122,6 +122,7 @@ static struct cpu_descr const cpu_descrs
 	{ "Intel Broadwell microarchitecture", "i386/broadwell", CPU_BROADWELL, 4 },
 	{ "Intel Skylake microarchitecture", "i386/skylake", CPU_SKYLAKE, 4 },
 	{ "Intel Goldmont microarchitecture", "i386/goldmont", CPU_GOLDMONT, 4 },
+	{ "ppc64 POWER9", "ppc64/power9", CPU_PPC64_POWER9, 6 },
 	{ "Intel Knights Landing", "i386/knightslanding", CPU_KNIGHTSLANDING, 4 },
 };
  
--- a/libop/op_cpu_type.h
+++ b/libop/op_cpu_type.h
@@ -109,6 +109,7 @@ typedef enum {
 	CPU_BROADWELL, /** < Intel Broadwell (Core-M) microarchitecture */
 	CPU_SKYLAKE, /** < Intel Skylake microarchitecture */
 	CPU_GOLDMONT, /** < Intel Goldmont microarchitecture */
+	CPU_PPC64_POWER9, /**< ppc64 POWER8 family */
 	CPU_KNIGHTSLANDING, /** Intel Knights Landing microarchitecture */
 	MAX_CPU_TYPE
 } op_cpu;
--- a/libop/op_events.c
+++ b/libop/op_events.c
@@ -1311,6 +1311,7 @@ void op_default_event(op_cpu cpu_type, s
 		case CPU_PPC64_IBM_COMPAT_V1:
 		case CPU_PPC64_ARCH_V1:
 		case CPU_PPC64_POWER8:
+		case CPU_PPC64_POWER9:
 			descr->name = "CYCLES";
 			break;
 
--- a/utils/ophelp.c
+++ b/utils/ophelp.c
@@ -687,6 +687,12 @@ int main(int argc, char const * argv[])
 			"See Power ISA 2.07 at https://www.power.org/\n\n";
 		break;
 
+	case CPU_PPC64_POWER9:
+		event_doc =
+			"This processor type is fully supported with operf.\n"
+			"See Power ISA 3.0 at https://www.power.org/\n\n";
+		break;
+
 	case CPU_PPC64_CELL:
 		event_doc =
 			"Obtain Cell Broadband Engine documentation at:\n"
openSUSE Build Service is sponsored by