summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch')
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch130
1 files changed, 130 insertions, 0 deletions
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
new file mode 100644
index 0000000000..ead6e256f1
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
@@ -0,0 +1,130 @@
1From 8e36ad01ceb1257d05773b684dbe9358aecd3f71 Mon Sep 17 00:00:00 2001
2From: Maynard Johnson <maynardj@us.ibm.com>
3Date: Tue, 26 Feb 2013 13:41:27 -0600
4Subject: [PATCH] Fix PPC64-specific libpfm usage so it doesn't break ppc32
5 architecture
6
7The configure check to determine whether we should use libpfm or not
8is intended only for the ppc64 architecture, but was incorrectly
9hitting on the ppc32 architecture, too. Not only that, but it was using
10'uname' which is not a good idea in cross-compile situtations.
11
12Then, aside from that, we had several instances in the source code
13of the following:
14 #if (defined(__powerpc__) || defined(__powerpc64__))
15which incorrectly included ppc32 architecutre also, when it was intended
16for use as PPC64 architecture.
17
18This patch fixes both errors.
19
20Signed-off-by: Maynard Johnson <maynardj@us.ibm.com
21---
22 configure.ac | 5 ++---
23 libperf_events/operf_utils.cpp | 4 ++--
24 libperf_events/operf_utils.h | 6 ++++++
25 pe_profiling/operf.cpp | 10 +++++-----
26 4 files changed, 15 insertions(+), 10 deletions(-)
27
28diff --git a/configure.ac b/configure.ac
29index a9b1ee4..a0da98c 100644
30--- a/configure.ac
31+++ b/configure.ac
32@@ -154,11 +154,10 @@ else
33 fi
34
35 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
36-
37+AC_CANONICAL_HOST
38 if test "$HAVE_PERF_EVENTS" = "1"; then
39 PFM_LIB=
40- arch="`uname -m`"
41- if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
42+ if test "$host_cpu" = "powerpc64"; then
43 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
44 AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
45 AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
46diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
47index da964fd..a17200b 100644
48--- a/libperf_events/operf_utils.cpp
49+++ b/libperf_events/operf_utils.cpp
50@@ -83,7 +83,7 @@ static event_t comm_event;
51 * the following method is to map the operf-record event value to a value that
52 * opreport can understand.
53 */
54-#if (defined(__powerpc__) || defined(__powerpc64__))
55+#if PPC64_ARCH
56 #define NIL_CODE ~0U
57
58 #if HAVE_LIBPFM3
59@@ -716,7 +716,7 @@ static void __handle_sample_event(event_t * event, u64 sample_type)
60 } else if (event->header.misc == PERF_RECORD_MISC_USER) {
61 in_kernel = false;
62 }
63-#if (defined(__powerpc__) || defined(__powerpc64__))
64+#if PPC64_ARCH
65 else if (event->header.misc == PERF_RECORD_MISC_HYPERVISOR) {
66 #define MAX_HYPERVISOR_ADDRESS 0xfffffffULL
67 if (data.ip > MAX_HYPERVISOR_ADDRESS) {
68diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h
69index 2df00b7..ddf05ed 100644
70--- a/libperf_events/operf_utils.h
71+++ b/libperf_events/operf_utils.h
72@@ -45,6 +45,12 @@ extern bool throttled;
73 #define MMAP_WINDOW_SZ (32 * 1024 * 1024ULL)
74 #endif
75
76+/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
77+ * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
78+ * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
79+ */
80+#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
81+
82 extern unsigned int op_nr_counters;
83
84 static inline size_t align_64bit(u64 x)
85diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
86index e7c2eab..e1190c2 100644
87--- a/pe_profiling/operf.cpp
88+++ b/pe_profiling/operf.cpp
89@@ -1177,7 +1177,7 @@ static void _get_event_code(operf_event_t * event)
90 event->evt_code = config;
91 }
92
93-#if (defined(__powerpc__) || defined(__powerpc64__))
94+#if PPC64_ARCH
95 /* All ppc64 events (except CYCLES) have a _GRP<n> suffix. This is
96 * because the legacy opcontrol profiler can only profile events in
97 * the same group (i.e., having the same _GRP<n> suffix). But operf
98@@ -1287,7 +1287,7 @@ static void _process_events_list(void)
99 string full_cmd = cmd;
100 string event_spec = operf_options::evts[i];
101
102-#if (defined(__powerpc__) || defined(__powerpc64__))
103+#if PPC64_ARCH
104 event_spec = _handle_powerpc_event_spec(event_spec);
105 #endif
106
107@@ -1357,9 +1357,9 @@ static void _process_events_list(void)
108 _get_event_code(&event);
109 events.push_back(event);
110 }
111-#if (defined(__powerpc__) || defined(__powerpc64__))
112+#if PPC64_ARCH
113 {
114- /* This section of code is for architectures such as ppc[64] for which
115+ /* This section of code is soley for the ppc64 architecture for which
116 * the oprofile event code needs to be converted to the appropriate event
117 * code to pass to the perf_event_open syscall.
118 */
119@@ -1404,7 +1404,7 @@ static void get_default_event(void)
120 _get_event_code(&dft_evt);
121 events.push_back(dft_evt);
122
123-#if (defined(__powerpc__) || defined(__powerpc64__))
124+#if PPC64_ARCH
125 {
126 /* This section of code is for architectures such as ppc[64] for which
127 * the oprofile event code needs to be converted to the appropriate event
128--
1291.7.9.7
130