Blame SOURCES/oprofile-ppc64-equivalent.patch

d5df0a
commit 4f5a0d9c4419f3b88586d665272eb35f270a0551
d5df0a
Author: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
Date:   Tue Dec 17 16:04:33 2013 -0600
d5df0a
d5df0a
    Allow all native events for IBM POWER8 in POWER7 compat mode
d5df0a
    
d5df0a
    Certain older Linux distributions will support the new IBM POWER8
d5df0a
    processor, but only in a limited mode, since much of the new
d5df0a
    kernel code needed to fully support the POWER8 was not backported
d5df0a
    to these older distros.  This limited mode is referred to as
d5df0a
    "POWER7 compat mode" since the kernel can support only the features
d5df0a
    that were also available on that earlier IBM processor.
d5df0a
    
d5df0a
    Changes I originally made to support POWER8 assumed that there
d5df0a
    would not be full POWER8 performance monitor unit capabilities when
d5df0a
    in POWER7 compat mode, and thus, the current oprofile code supports
d5df0a
    only a limited subset of POWER8 events (i.e., events which were also
d5df0a
    available on the POWER7). However, I've recently been made aware
d5df0a
    that these older distros actually do have complete backports of the
d5df0a
    POWER8 perf_events kernel subsystem code, making them fully aware of
d5df0a
    all POWER8 events. This patch allows operf and ocount to use all
d5df0a
    of the POWER8 events, regardless of what mode or distribution we
d5df0a
    are running on.
d5df0a
    
d5df0a
    Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
d5df0a
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
d5df0a
index 4bb34b7..cd75ad4 100644
d5df0a
--- a/libop/op_cpu_type.c
d5df0a
+++ b/libop/op_cpu_type.c
d5df0a
@@ -290,7 +290,16 @@ static op_cpu _try_ppc64_arch_generic_cpu(void)
d5df0a
 			}
d5df0a
 		}
d5df0a
 		if (!platforms_are_equivalent) {
d5df0a
-			if (strcmp(platform, "power7") == 0)
d5df0a
+			//  FIXME
d5df0a
+			/* For POWER8 running in POWER7 compat mode (RHEL 6.5 and SLES 11 SP4),
d5df0a
+			 * the kernel will have enough POWER8-specific PMU code so we can utilize
d5df0a
+			 * all of the POWER8 events. In general, this is not necessarily the case
d5df0a
+			 * when running in compat mode.  This code needs to be inspected for every
d5df0a
+			 * new IBM Power processor released, but for now, we'll assume that for the
d5df0a
+			 * next processor model (assuming there will be something like a POWER9?),
d5df0a
+			 * we should use just the architected events when running POWER8 compat mode.
d5df0a
+			 */
d5df0a
+			if (strcmp(platform, "power8") == 0)
d5df0a
 				cpu_type = CPU_PPC64_ARCH_V1;
d5df0a
 		}
d5df0a
 	}
d5df0a
commit 88ed74bade0096042d643a6d7e68c2cbc4b6e34d
d5df0a
Author: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
Date:   Thu Jan 9 15:07:21 2014 -0600
d5df0a
d5df0a
    Fix "Unable to open cpu_type file for reading" for IBM POWER7+
d5df0a
    
d5df0a
    Using operf to do profiling on an IBM POWER7+ may result in
d5df0a
    the following error message:
d5df0a
    
d5df0a
    	Unable to open cpu_type file for reading
d5df0a
    
d5df0a
    This patch fixes the problem.  There is also a simple workaround of
d5df0a
    running 'opcontrol --init'.
d5df0a
    
d5df0a
    Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
d5df0a
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
d5df0a
index cd75ad4..7d5262c 100644
d5df0a
--- a/libop/op_cpu_type.c
d5df0a
+++ b/libop/op_cpu_type.c
d5df0a
@@ -326,6 +326,8 @@ static op_cpu _get_ppc64_cpu_type(void)
d5df0a
 	for (i = 0; i < (int)len ; i++)
d5df0a
 		cpu_name_lowercase[i] = tolower(cpu_name[i]);
d5df0a
 
d5df0a
+	if (strncmp(cpu_name_lowercase, "power7+", 7) == 0)
d5df0a
+		cpu_name_lowercase[6] = '\0';
d5df0a
 	cpu_type_str[0] = '\0';
d5df0a
 	strcat(cpu_type_str, "ppc64/");
d5df0a
 	strncat(cpu_type_str, cpu_name_lowercase, len);
d5df0a
commit 65176cb1af0fb1f6c7d3ddba4ab5f5f23c5f7c62
d5df0a
Author: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
Date:   Tue Jan 21 14:43:02 2014 -0600
d5df0a
d5df0a
    Fix regression in IBM POWER8 running in POWER7 compat mode
d5df0a
    
d5df0a
    A commit made on Dec 17, 2013 ("Allow all native events for IBM POWER8
d5df0a
    in POWER7 compat mode) broke support for POWER8 in POWER7 compat mode.
d5df0a
    Instead, oprofile attempts to treat it as a normal POWER7 processor,
d5df0a
    which is not correct.  A user reported the following error when
d5df0a
    running operf with the default CYCLES event:
d5df0a
    
d5df0a
       terminate called after throwing an instance of 'std::runtime_error'
d5df0a
         what():  libpfm cannot find event code for CYCLES; cannot continue
d5df0a
       Aborted
d5df0a
    
d5df0a
    This patch fixes this problem.
d5df0a
    
d5df0a
    Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
d5df0a
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
d5df0a
index a3ad804..2907f36 100644
d5df0a
--- a/libop/op_cpu_type.c
d5df0a
+++ b/libop/op_cpu_type.c
d5df0a
@@ -300,7 +300,9 @@ static op_cpu _try_ppc64_arch_generic_cpu(void)
d5df0a
 			 * next processor model (assuming there will be something like a POWER9?),
d5df0a
 			 * we should use just the architected events when running POWER8 compat mode.
d5df0a
 			 */
d5df0a
-			if (strcmp(platform, "power8") == 0)
d5df0a
+			if ((strcmp(platform, "power7") == 0) && (strcmp(base_platform, "power8") == 0))
d5df0a
+				cpu_type = CPU_PPC64_POWER8;
d5df0a
+			else
d5df0a
 				cpu_type = CPU_PPC64_ARCH_V1;
d5df0a
 		}
d5df0a
 	}
d5df0a
commit 7243fa4ed8a25c6e59225a863fd263ce70989087
d5df0a
Author: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
Date:   Tue Feb 4 08:27:10 2014 -0600
d5df0a
d5df0a
    Make cpu type POWER8E equivalent to POWER8
d5df0a
    
d5df0a
    Recent mainline kernel changes resulted in a cpu type of
d5df0a
    "POWER8E" being displayed in /proc/cpuinfo for certain revisions
d5df0a
    of the IBM POWER8 processor model. But for profiling and
d5df0a
    counting of native events, we can ignore the differences between
d5df0a
    POWER8 and POWER8E.  This patch addresses that issue.
d5df0a
    
d5df0a
    Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
d5df0a
d5df0a
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
d5df0a
index 2907f36..1ae2913 100644
d5df0a
--- a/libop/op_cpu_type.c
d5df0a
+++ b/libop/op_cpu_type.c
d5df0a
@@ -331,6 +331,9 @@ static op_cpu _get_ppc64_cpu_type(void)
d5df0a
 
d5df0a
 	if (strncmp(cpu_name_lowercase, "power7+", 7) == 0)
d5df0a
 		cpu_name_lowercase[6] = '\0';
d5df0a
+	if (strncmp(cpu_name_lowercase, "power8e", 7) == 0)
d5df0a
+		cpu_name_lowercase[6] = '\0';
d5df0a
+
d5df0a
 	cpu_type_str[0] = '\0';
d5df0a
 	strcat(cpu_type_str, "ppc64/");
d5df0a
 	strncat(cpu_type_str, cpu_name_lowercase, len);