summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Change-configure-to-look-for-libpfm4-function-first-.patch49
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Fix-up-configure-to-handle-architectures-that-do-not.patch163
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch107
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch32
-rw-r--r--meta/recipes-kernel/oprofile/oprofile_0.9.8.bb8
5 files changed, 357 insertions, 2 deletions
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Change-configure-to-look-for-libpfm4-function-first-.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Change-configure-to-look-for-libpfm4-function-first-.patch
new file mode 100644
index 0000000000..eeec755cb9
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Change-configure-to-look-for-libpfm4-function-first-.patch
@@ -0,0 +1,49 @@
1Upstream-Status: Backport
2
3From 414f4dba2d77f3014755aa58937efb22a4789e9f Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Fri, 21 Dec 2012 08:27:37 -0600
6Subject: [PATCH] Change configure to look for libpfm4 function first; then
7 fallback to libpfm3
8
9This change only affects ppc64 architecture, since it's the only
10architecture that uses libpfm to obtain the event hex code to pass
11to perf_event_open.
12
13There were bugs in libpfm3 pertaining to POWER7 event definitions that
14have been fixed in libpfm4. So it's likely that some IBM POWER7 users
15may want to install libpfm4 and build oprofile to link with it. For
16example, if libpfm4 were installed in /usr/local, the user would invoke
17oprofile's configure thusly:
18
19LDFLAGS="-L/usr/local/lib64" CPPFLAGS="-I/usr/local/include" ./configure
20
21But if the user happens to also have libpfm3 already installed in /usr,
22then the current order of config tests would result in choosing the libpfm3
23library. This logic seems wrong. The configure checking should go from most
24recent to older library versions. This patch changes the order of checking
25so the libpfm4 library would be found first.
26
27Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
28---
29 configure.ac | 4 ++--
30 1 file changed, 2 insertions(+), 2 deletions(-)
31
32diff --git a/configure.ac b/configure.ac
33index 3078393..a9b1ee4 100644
34--- a/configure.ac
35+++ b/configure.ac
36@@ -160,8 +160,8 @@ if test "$HAVE_PERF_EVENTS" = "1"; then
37 arch="`uname -m`"
38 if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
39 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
40- AC_CHECK_LIB(pfm,pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', [
41- AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1',
42+ AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
43+ AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
44 [AC_MSG_ERROR([libpfm not found; usually provided in papi devel package])])])
45 PFM_LIB="-lpfm"
46 AC_DEFINE_UNQUOTED(HAVE_LIBPFM3, $HAVE_LIBPFM3, [Define to 1 if using libpfm3; 0 if using newer libpfm])
47--
481.7.9.7
49
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Fix-up-configure-to-handle-architectures-that-do-not.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-up-configure-to-handle-architectures-that-do-not.patch
new file mode 100644
index 0000000000..5e6d5de355
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-up-configure-to-handle-architectures-that-do-not.patch
@@ -0,0 +1,163 @@
1Upstream-Status: Backport
2
3From ca6d916a6f8f0f8abbb4c9b6a97dd1a1615bb124 Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Wed, 5 Dec 2012 10:16:35 -0600
6Subject: [PATCH] Fix up configure to handle architectures that do not
7 implement perf_event_open
8
9This patch fixes the following problems:
10
111) The configure script allows the user to pass a location to kernel
12headers (via --with-kernel option) such that, even if the running
13kernel does not have perf_events support, it may be possible to
14build operf (e.g., in cross-compile environments). But the message
15'This kernel does not have perf_events support; falling back to legacy
16oprofile' was being displayed inappropriately in such cases. This
17patch changes the configure script so that the "falling back to
18legacy oprofile" message will only be displayed if we're running
19on a kernel that does not have perf_events support AND the user
20did not pass specify the "--with-kernel" option.
21
222) Some architectures don't even implement the perf_event_open syscall, so the
23configure script must do more than checking kernel version and whether or not
24perf_event.h is present in order to decide if perf_events is supported.
25This patch provides that extra capability.
26
27These problems were reported by Tony Jones <tonyj@suse.com>.
28
29Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
30---
31 configure.ac | 74 +++++++++++++++++++++++++++++-----------
32 utils/op_perf_events_checker.c | 6 ++--
33 2 files changed, 58 insertions(+), 22 deletions(-)
34
35diff --git a/configure.ac b/configure.ac
36index 5c3d13d..89336ee 100644
37--- a/configure.ac
38+++ b/configure.ac
39@@ -70,34 +70,66 @@ KERNELDIR=$withval)
40
41
42 dnl Check kernel version for perf_events supported
43-AC_MSG_CHECKING([kernel version supports perf_events])
44 if test "$KERNELDIR" != ""; then
45 KINC="$KERNELDIR/include"
46-fi
47-AX_KERNEL_VERSION(2, 6, 31, <=, kernel_has_perf_events_support="yes",
48-kernel_has_perf_events_support="no")
49-
50-if test "$kernel_has_perf_events_support" = "no"; then
51- AC_MSG_RESULT([This kernel does not have perf_events support; falling back to legacy oprofile])
52+ PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
53+ AC_SUBST(PERF_EVENT_FLAGS)
54+ PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h"
55 else
56- AC_MSG_RESULT([This kernel has perf_events support])
57+ PERF_EVENT_H="/usr/include/linux/perf_event.h"
58 fi
59
60-if test "$KERNELDIR" == ""; then
61- PERF_EVENT_H="/usr/include/linux/perf_event.h"
62+PERF_EVENT_H_EXISTS="no"
63+kernel_may_have_perf_events_support="no"
64+AX_KERNEL_VERSION(2, 6, 31, <=, kernel_may_have_perf_events_support="yes",
65+kernel_has_perf_events_support="no")
66+
67+dnl The AX_KERNEL_VERSION macro may return kernel_may_have_perf_events_support="yes",
68+dnl indicating a partial answer. Some architectures do not implement the Performance
69+dnl Events Kernel Subsystem even with kernel versions > 2.6.31 -- i.e., not even
70+dnl implementing the perf_event_open syscall to return ENOSYS. So the check below
71+dnl will identify and handle such situations.
72+
73+if test "$kernel_may_have_perf_events_support" = "yes"; then
74+ AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
75+ AC_MSG_CHECKING([kernel supports perf_events])
76+ if test "$PERF_EVENT_H_EXISTS" = "yes"; then
77+ rm -f test-for-PERF_EVENT_OPEN
78+ AC_LANG_CONFTEST(
79+ [AC_LANG_PROGRAM([[#include <linux/perf_event.h>
80+ #include <asm/unistd.h>
81+ #include <sys/types.h>
82+ #include <string.h>
83+ ]],
84+ [[struct perf_event_attr attr;
85+ pid_t pid;
86+ memset(&attr, 0, sizeof(attr));
87+ attr.size = sizeof(attr);
88+ attr.sample_type = PERF_SAMPLE_IP;
89+ pid = getpid();
90+ syscall(__NR_perf_event_open, &attr, pid, 0, -1, 0);
91+ ]])
92+ ])
93+ $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_EVENT_OPEN > /dev/null 2>&1
94+ if test -f test-for-PERF_EVENT_OPEN; then
95+ kernel_has_perf_events_support="yes"
96+ AC_MSG_RESULT(yes)
97+ else
98+ AC_MSG_RESULT(no)
99+ kernel_has_perf_events_support="no"
100+ fi
101+ else
102+ AC_MSG_RESULT(unknown -- perf_event.h not found)
103+ fi
104 else
105- PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h"
106+ AC_MSG_RESULT(kernel supports perf_events... no)
107+ kernel_has_perf_events_support="no"
108 fi
109-AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
110-AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
111-if test "$PERF_EVENT_H_EXISTS" = "yes"; then
112- HAVE_PERF_EVENTS='1'
113
114- if test "$KERNELDIR" != ""; then
115- PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
116- AC_SUBST(PERF_EVENT_FLAGS)
117- fi
118+AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test "$kernel_has_perf_events_support" = "yes")
119
120+if test "$kernel_has_perf_events_support" = "yes"; then
121+ HAVE_PERF_EVENTS='1'
122 AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
123 rm -f test-for-PERF_GUEST
124 AC_LANG_CONFTEST(
125@@ -117,7 +149,9 @@ if test "$PERF_EVENT_H_EXISTS" = "yes"; then
126 rm -f test-for-PERF_GUEST*
127 else
128 HAVE_PERF_EVENTS='0'
129+ AC_MSG_RESULT([No perf_events support available; falling back to legacy oprofile])
130 fi
131+
132 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
133
134 if test "$HAVE_PERF_EVENTS" = "1"; then
135@@ -433,7 +467,7 @@ elif test "`getent passwd oprofile 2>/dev/null`" == "" || \
136 fi
137 fi
138
139-if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_has_perf_events_support" = "yes"; then
140+if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_may_have_perf_events_support" = "yes"; then
141 echo "Warning: perf_event.h not found. Either install the kernel headers package or"
142 echo "use the --with-kernel option if you want the non-root, single application"
143 echo "profiling support provided by operf."
144diff --git a/utils/op_perf_events_checker.c b/utils/op_perf_events_checker.c
145index 519cafa..74a410e 100644
146--- a/utils/op_perf_events_checker.c
147+++ b/utils/op_perf_events_checker.c
148@@ -49,8 +49,10 @@ int main(int argc, char **argv)
149 }
150
151 #if HAVE_PERF_EVENTS
152- /* If perf_events syscall is not implemented, the syscall below will fail
153- * with ENOSYS (38). If implemented, but the processor type on which this
154+ /* Even if the perf_event_open syscall is implemented, the architecture may still
155+ * not provide a full implementation of the perf_events subsystem, in which case,
156+ * the syscall below will fail with ENOSYS (38). If the perf_events subsystem is
157+ * implemented for the architecture, but the processor type on which this
158 * program is running is not supported by perf_events, the syscall returns
159 * ENOENT (2).
160 */
161--
1621.7.9.7
163
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch
new file mode 100644
index 0000000000..894e99aec8
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch
@@ -0,0 +1,107 @@
1Upstream-Status: Backport
2
3From dbe24f5f0d98b1fe5517d2b137b4c59766e536ad Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Mon, 19 Nov 2012 15:16:37 -0600
6Subject: [PATCH] Handle early perf_events kernel without
7 PERF_RECORD_MISC_GUEST* macros
8
9In very early versions of perf_events kernel subsystem, the
10PERF_RECORD_MISC_GUEST_KERNEL and PERF_RECORD_MISC_GUEST_USER
11macros (in perf_event.h) were not yet defined. This patch adds
12a configure check to determine when it's OK for source code to refer
13to those macros.
14
15This patch also does some minor cleanup of the configure script
16help and warning messages relating to the --with-kernel option.
17
18Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
19---
20 configure.ac | 32 ++++++++++++++++++++++++++------
21 libperf_events/operf_utils.cpp | 2 ++
22 2 files changed, 28 insertions(+), 6 deletions(-)
23
24diff --git a/configure.ac b/configure.ac
25index 7449854..18d1169 100644
26--- a/configure.ac
27+++ b/configure.ac
28@@ -60,12 +60,12 @@ test "$LD" || AC_ERROR(ld not found)
29
30 # --with-kernel for cross compilation
31 AC_ARG_WITH(kernel,
32-[AS_HELP_STRING([--with-kernel=dir], [Path to kernel include directory (...include/linux/perf_event.h) to use.
33+[AS_HELP_STRING([--with-kernel=dir], [Path to kernel include directory (e.g. /tmp/linux-xyz) to use.
34 If this option is not specified, configure will look for kernel header files in the usual installation location
35-for a kernel-headers package -- /usr/include. Use this option in cross-compile enviroments
36+for a kernel-headers package -- /usr. Use this option in cross-compile enviroments
37 or in situations where the host system does not support perf_events but you wish to build binaries
38-for a target system that does support perf_events. Because of OProfile's use of syscalls, be sure that the
39-kernel headers used match the architecture of the intended target system.])],
40+for a target system that does support perf_events. Because of OProfile's use of syscalls,
41+kernel headers used during build must match the architecture of the intended target system.])],
42 KERNELDIR=$withval)
43
44
45@@ -92,10 +92,29 @@ AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
46 AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
47 if test "$PERF_EVENT_H_EXISTS" = "yes"; then
48 HAVE_PERF_EVENTS='1'
49+
50 if test "$KERNELDIR" != ""; then
51 PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
52 AC_SUBST(PERF_EVENT_FLAGS)
53 fi
54+
55+ AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
56+ rm -f test-for-PERF_GUEST
57+ AC_LANG_CONFTEST(
58+ [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]],
59+ [[unsigned int pr_guest_kern = PERF_RECORD_MISC_GUEST_KERNEL;
60+ unsigned int pr_guest_user = PERF_RECORD_MISC_GUEST_USER;]])
61+ ])
62+ $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_GUEST > /dev/null 2>&1
63+ if test -f test-for-PERF_GUEST; then
64+ echo "yes"
65+ HAVE_PERF_GUEST_MACROS='1'
66+ else
67+ echo "no"
68+ HAVE_PERF_GUEST_MACROS='0'
69+ fi
70+ AC_DEFINE_UNQUOTED(HAVE_PERF_GUEST_MACROS, $HAVE_PERF_GUEST_MACROS, [PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
71+ rm -f test-for-PERF_GUEST*
72 else
73 HAVE_PERF_EVENTS='0'
74 fi
75@@ -416,7 +435,8 @@ elif test "`getent passwd oprofile 2>/dev/null`" == "" || \
76 fi
77
78 if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_has_perf_events_support" = "yes"; then
79- echo "Warning: perf_event.h not found. Please install the kernel headers package if you"
80- echo " want non-root support built into OProfile."
81+ echo "Warning: perf_event.h not found. Either install the kernel headers package or"
82+ echo "use the --with-kernel option if you want the non-root, single application"
83+ echo "profiling support provided by operf."
84 fi
85
86diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
87index 06cd566..470cfba 100644
88--- a/libperf_events/operf_utils.cpp
89+++ b/libperf_events/operf_utils.cpp
90@@ -732,12 +732,14 @@ static void __handle_sample_event(event_t * event, u64 sample_type)
91 case PERF_RECORD_MISC_HYPERVISOR:
92 domain = "hypervisor";
93 break;
94+#if HAVE_PERF_GUEST_MACROS
95 case PERF_RECORD_MISC_GUEST_KERNEL:
96 domain = "guest OS";
97 break;
98 case PERF_RECORD_MISC_GUEST_USER:
99 domain = "guest user";
100 break;
101+#endif
102 default:
103 domain = "unknown";
104 break;
105--
1061.7.9.7
107
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch b/meta/recipes-kernel/oprofile/oprofile/0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch
new file mode 100644
index 0000000000..0f609df0e2
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch
@@ -0,0 +1,32 @@
1Upstream-Status: Backport
2
3From fa889ea74b6b931e241a8cd57e90edc23cd7ab03 Mon Sep 17 00:00:00 2001
4From: William Cohen <wcohen@redhat.com>
5Date: Mon, 15 Oct 2012 15:09:55 -0500
6Subject: [PATCH] OProfile doesn't build for 32-bit ppc; the operf_utils.cpp
7 compile fails. Need to be able to build the 32-bit ppc
8 version of oprofile to provide the 32-bit ppc java support
9 libraries. The configure only handles the case of ppc64
10 with perf support.
11
12Signed-off-by: William Cohen <wcohen@redhat.com>
13---
14 configure.ac | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/configure.ac b/configure.ac
18index b739133..7449854 100644
19--- a/configure.ac
20+++ b/configure.ac
21@@ -104,7 +104,7 @@ AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf
22 if test "$HAVE_PERF_EVENTS" = "1"; then
23 PFM_LIB=
24 arch="`uname -m`"
25- if test "$arch" = "ppc64"; then
26+ if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
27 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
28 AC_CHECK_LIB(pfm,pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', [
29 AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1',
30--
311.7.9.7
32
diff --git a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
index d283b5cd03..4491e7d7ce 100644
--- a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
+++ b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
@@ -1,9 +1,13 @@
1require oprofile.inc 1require oprofile.inc
2 2
3PR = "${INC_PR}.0" 3PR = "${INC_PR}.1"
4 4
5SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ 5SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
6 file://0001-Add-rmb-definition-for-AArch64-architecture.patch" 6 file://0001-Add-rmb-definition-for-AArch64-architecture.patch \
7 file://0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch \
8 file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \
9 file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \
10 file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch"
7 11
8SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8" 12SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8"
9SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc" 13SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc"