summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/oprofile
diff options
context:
space:
mode:
authorMatthew McClintock <msm@freescale.com>2013-01-17 20:23:23 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-21 10:22:08 +0000
commit4de6f9b17c6dd8d50ddb3050a091fae83e91bb71 (patch)
tree6bfb7741a75e8dd907a952b182a8bf57d4fbbc05 /meta/recipes-kernel/oprofile
parentf63f387b836312a1efb57651c37682381d139685 (diff)
downloadast2050-yocto-poky-4de6f9b17c6dd8d50ddb3050a091fae83e91bb71.zip
ast2050-yocto-poky-4de6f9b17c6dd8d50ddb3050a091fae83e91bb71.tar.gz
oprofile: backport patches to fix ppc build issues
Fixes: | operf_utils.cpp: In function 'bool _op_get_event_codes(std::vector*)': | operf_utils.cpp:151:21: error: 'pfm_initialize' was not declared in this scope | operf_utils.cpp:151:26: error: 'PFM_SUCCESS' was not declared in this scope | operf_utils.cpp:166:45: error: 'PFM_PLM3' was not declared in this scope | operf_utils.cpp:166:55: error: 'PFM_OS_NONE' was not declared in this scope | operf_utils.cpp:166:72: error: 'pfm_get_os_event_encoding' was not declared in this scope | operf_utils.cpp:167:14: error: 'PFM_SUCCESS' was not declared in this scope [YOCTO #3717] (From OE-Core rev: 121cb96964fe2f374d814bf39036119bd63b9589) Signed-off-by: Matthew McClintock <msm@freescale.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/oprofile')
-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 0000000..eeec755
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Change-configure-to-look-for-libpfm4-function-first-.patch
@@ -0,0 +1,49 @@
+Upstream-Status: Backport
+
+From 414f4dba2d77f3014755aa58937efb22a4789e9f Mon Sep 17 00:00:00 2001
+From: Maynard Johnson <maynardj@us.ibm.com>
+Date: Fri, 21 Dec 2012 08:27:37 -0600
+Subject: [PATCH] Change configure to look for libpfm4 function first; then
+ fallback to libpfm3
+
+This change only affects ppc64 architecture, since it's the only
+architecture that uses libpfm to obtain the event hex code to pass
+to perf_event_open.
+
+There were bugs in libpfm3 pertaining to POWER7 event definitions that
+have been fixed in libpfm4. So it's likely that some IBM POWER7 users
+may want to install libpfm4 and build oprofile to link with it. For
+example, if libpfm4 were installed in /usr/local, the user would invoke
+oprofile's configure thusly:
+
+LDFLAGS="-L/usr/local/lib64" CPPFLAGS="-I/usr/local/include" ./configure
+
+But if the user happens to also have libpfm3 already installed in /usr,
+then the current order of config tests would result in choosing the libpfm3
+library. This logic seems wrong. The configure checking should go from most
+recent to older library versions. This patch changes the order of checking
+so the libpfm4 library would be found first.
+
+Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3078393..a9b1ee4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -160,8 +160,8 @@ if test "$HAVE_PERF_EVENTS" = "1"; then
+ arch="`uname -m`"
+ if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
+ AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
+- AC_CHECK_LIB(pfm,pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', [
+- AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1',
++ AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
++ AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
+ [AC_MSG_ERROR([libpfm not found; usually provided in papi devel package])])])
+ PFM_LIB="-lpfm"
+ AC_DEFINE_UNQUOTED(HAVE_LIBPFM3, $HAVE_LIBPFM3, [Define to 1 if using libpfm3; 0 if using newer libpfm])
+--
+1.7.9.7
+
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 0000000..5e6d5de
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-up-configure-to-handle-architectures-that-do-not.patch
@@ -0,0 +1,163 @@
+Upstream-Status: Backport
+
+From ca6d916a6f8f0f8abbb4c9b6a97dd1a1615bb124 Mon Sep 17 00:00:00 2001
+From: Maynard Johnson <maynardj@us.ibm.com>
+Date: Wed, 5 Dec 2012 10:16:35 -0600
+Subject: [PATCH] Fix up configure to handle architectures that do not
+ implement perf_event_open
+
+This patch fixes the following problems:
+
+1) The configure script allows the user to pass a location to kernel
+headers (via --with-kernel option) such that, even if the running
+kernel does not have perf_events support, it may be possible to
+build operf (e.g., in cross-compile environments). But the message
+'This kernel does not have perf_events support; falling back to legacy
+oprofile' was being displayed inappropriately in such cases. This
+patch changes the configure script so that the "falling back to
+legacy oprofile" message will only be displayed if we're running
+on a kernel that does not have perf_events support AND the user
+did not pass specify the "--with-kernel" option.
+
+2) Some architectures don't even implement the perf_event_open syscall, so the
+configure script must do more than checking kernel version and whether or not
+perf_event.h is present in order to decide if perf_events is supported.
+This patch provides that extra capability.
+
+These problems were reported by Tony Jones <tonyj@suse.com>.
+
+Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
+---
+ configure.ac | 74 +++++++++++++++++++++++++++++-----------
+ utils/op_perf_events_checker.c | 6 ++--
+ 2 files changed, 58 insertions(+), 22 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 5c3d13d..89336ee 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -70,34 +70,66 @@ KERNELDIR=$withval)
+
+
+ dnl Check kernel version for perf_events supported
+-AC_MSG_CHECKING([kernel version supports perf_events])
+ if test "$KERNELDIR" != ""; then
+ KINC="$KERNELDIR/include"
+-fi
+-AX_KERNEL_VERSION(2, 6, 31, <=, kernel_has_perf_events_support="yes",
+-kernel_has_perf_events_support="no")
+-
+-if test "$kernel_has_perf_events_support" = "no"; then
+- AC_MSG_RESULT([This kernel does not have perf_events support; falling back to legacy oprofile])
++ PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
++ AC_SUBST(PERF_EVENT_FLAGS)
++ PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h"
+ else
+- AC_MSG_RESULT([This kernel has perf_events support])
++ PERF_EVENT_H="/usr/include/linux/perf_event.h"
+ fi
+
+-if test "$KERNELDIR" == ""; then
+- PERF_EVENT_H="/usr/include/linux/perf_event.h"
++PERF_EVENT_H_EXISTS="no"
++kernel_may_have_perf_events_support="no"
++AX_KERNEL_VERSION(2, 6, 31, <=, kernel_may_have_perf_events_support="yes",
++kernel_has_perf_events_support="no")
++
++dnl The AX_KERNEL_VERSION macro may return kernel_may_have_perf_events_support="yes",
++dnl indicating a partial answer. Some architectures do not implement the Performance
++dnl Events Kernel Subsystem even with kernel versions > 2.6.31 -- i.e., not even
++dnl implementing the perf_event_open syscall to return ENOSYS. So the check below
++dnl will identify and handle such situations.
++
++if test "$kernel_may_have_perf_events_support" = "yes"; then
++ AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
++ AC_MSG_CHECKING([kernel supports perf_events])
++ if test "$PERF_EVENT_H_EXISTS" = "yes"; then
++ rm -f test-for-PERF_EVENT_OPEN
++ AC_LANG_CONFTEST(
++ [AC_LANG_PROGRAM([[#include <linux/perf_event.h>
++ #include <asm/unistd.h>
++ #include <sys/types.h>
++ #include <string.h>
++ ]],
++ [[struct perf_event_attr attr;
++ pid_t pid;
++ memset(&attr, 0, sizeof(attr));
++ attr.size = sizeof(attr);
++ attr.sample_type = PERF_SAMPLE_IP;
++ pid = getpid();
++ syscall(__NR_perf_event_open, &attr, pid, 0, -1, 0);
++ ]])
++ ])
++ $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_EVENT_OPEN > /dev/null 2>&1
++ if test -f test-for-PERF_EVENT_OPEN; then
++ kernel_has_perf_events_support="yes"
++ AC_MSG_RESULT(yes)
++ else
++ AC_MSG_RESULT(no)
++ kernel_has_perf_events_support="no"
++ fi
++ else
++ AC_MSG_RESULT(unknown -- perf_event.h not found)
++ fi
+ else
+- PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h"
++ AC_MSG_RESULT(kernel supports perf_events... no)
++ kernel_has_perf_events_support="no"
+ fi
+-AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
+-AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
+-if test "$PERF_EVENT_H_EXISTS" = "yes"; then
+- HAVE_PERF_EVENTS='1'
+
+- if test "$KERNELDIR" != ""; then
+- PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
+- AC_SUBST(PERF_EVENT_FLAGS)
+- fi
++AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test "$kernel_has_perf_events_support" = "yes")
+
++if test "$kernel_has_perf_events_support" = "yes"; then
++ HAVE_PERF_EVENTS='1'
+ AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
+ rm -f test-for-PERF_GUEST
+ AC_LANG_CONFTEST(
+@@ -117,7 +149,9 @@ if test "$PERF_EVENT_H_EXISTS" = "yes"; then
+ rm -f test-for-PERF_GUEST*
+ else
+ HAVE_PERF_EVENTS='0'
++ AC_MSG_RESULT([No perf_events support available; falling back to legacy oprofile])
+ fi
++
+ AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
+
+ if test "$HAVE_PERF_EVENTS" = "1"; then
+@@ -433,7 +467,7 @@ elif test "`getent passwd oprofile 2>/dev/null`" == "" || \
+ fi
+ fi
+
+-if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_has_perf_events_support" = "yes"; then
++if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_may_have_perf_events_support" = "yes"; then
+ echo "Warning: perf_event.h not found. Either install the kernel headers package or"
+ echo "use the --with-kernel option if you want the non-root, single application"
+ echo "profiling support provided by operf."
+diff --git a/utils/op_perf_events_checker.c b/utils/op_perf_events_checker.c
+index 519cafa..74a410e 100644
+--- a/utils/op_perf_events_checker.c
++++ b/utils/op_perf_events_checker.c
+@@ -49,8 +49,10 @@ int main(int argc, char **argv)
+ }
+
+ #if HAVE_PERF_EVENTS
+- /* If perf_events syscall is not implemented, the syscall below will fail
+- * with ENOSYS (38). If implemented, but the processor type on which this
++ /* Even if the perf_event_open syscall is implemented, the architecture may still
++ * not provide a full implementation of the perf_events subsystem, in which case,
++ * the syscall below will fail with ENOSYS (38). If the perf_events subsystem is
++ * implemented for the architecture, but the processor type on which this
+ * program is running is not supported by perf_events, the syscall returns
+ * ENOENT (2).
+ */
+--
+1.7.9.7
+
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 0000000..894e99a
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch
@@ -0,0 +1,107 @@
+Upstream-Status: Backport
+
+From dbe24f5f0d98b1fe5517d2b137b4c59766e536ad Mon Sep 17 00:00:00 2001
+From: Maynard Johnson <maynardj@us.ibm.com>
+Date: Mon, 19 Nov 2012 15:16:37 -0600
+Subject: [PATCH] Handle early perf_events kernel without
+ PERF_RECORD_MISC_GUEST* macros
+
+In very early versions of perf_events kernel subsystem, the
+PERF_RECORD_MISC_GUEST_KERNEL and PERF_RECORD_MISC_GUEST_USER
+macros (in perf_event.h) were not yet defined. This patch adds
+a configure check to determine when it's OK for source code to refer
+to those macros.
+
+This patch also does some minor cleanup of the configure script
+help and warning messages relating to the --with-kernel option.
+
+Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
+---
+ configure.ac | 32 ++++++++++++++++++++++++++------
+ libperf_events/operf_utils.cpp | 2 ++
+ 2 files changed, 28 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 7449854..18d1169 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -60,12 +60,12 @@ test "$LD" || AC_ERROR(ld not found)
+
+ # --with-kernel for cross compilation
+ AC_ARG_WITH(kernel,
+-[AS_HELP_STRING([--with-kernel=dir], [Path to kernel include directory (...include/linux/perf_event.h) to use.
++[AS_HELP_STRING([--with-kernel=dir], [Path to kernel include directory (e.g. /tmp/linux-xyz) to use.
+ If this option is not specified, configure will look for kernel header files in the usual installation location
+-for a kernel-headers package -- /usr/include. Use this option in cross-compile enviroments
++for a kernel-headers package -- /usr. Use this option in cross-compile enviroments
+ or in situations where the host system does not support perf_events but you wish to build binaries
+-for a target system that does support perf_events. Because of OProfile's use of syscalls, be sure that the
+-kernel headers used match the architecture of the intended target system.])],
++for a target system that does support perf_events. Because of OProfile's use of syscalls,
++kernel headers used during build must match the architecture of the intended target system.])],
+ KERNELDIR=$withval)
+
+
+@@ -92,10 +92,29 @@ AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
+ AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
+ if test "$PERF_EVENT_H_EXISTS" = "yes"; then
+ HAVE_PERF_EVENTS='1'
++
+ if test "$KERNELDIR" != ""; then
+ PERF_EVENT_FLAGS=" -I$KERNELDIR/include"
+ AC_SUBST(PERF_EVENT_FLAGS)
+ fi
++
++ AC_MSG_CHECKING([whether PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
++ rm -f test-for-PERF_GUEST
++ AC_LANG_CONFTEST(
++ [AC_LANG_PROGRAM([[#include <linux/perf_event.h>]],
++ [[unsigned int pr_guest_kern = PERF_RECORD_MISC_GUEST_KERNEL;
++ unsigned int pr_guest_user = PERF_RECORD_MISC_GUEST_USER;]])
++ ])
++ $CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-PERF_GUEST > /dev/null 2>&1
++ if test -f test-for-PERF_GUEST; then
++ echo "yes"
++ HAVE_PERF_GUEST_MACROS='1'
++ else
++ echo "no"
++ HAVE_PERF_GUEST_MACROS='0'
++ fi
++ AC_DEFINE_UNQUOTED(HAVE_PERF_GUEST_MACROS, $HAVE_PERF_GUEST_MACROS, [PERF_RECORD_MISC_GUEST_KERNEL is defined in perf_event.h])
++ rm -f test-for-PERF_GUEST*
+ else
+ HAVE_PERF_EVENTS='0'
+ fi
+@@ -416,7 +435,8 @@ elif test "`getent passwd oprofile 2>/dev/null`" == "" || \
+ fi
+
+ if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_has_perf_events_support" = "yes"; then
+- echo "Warning: perf_event.h not found. Please install the kernel headers package if you"
+- echo " want non-root support built into OProfile."
++ echo "Warning: perf_event.h not found. Either install the kernel headers package or"
++ echo "use the --with-kernel option if you want the non-root, single application"
++ echo "profiling support provided by operf."
+ fi
+
+diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
+index 06cd566..470cfba 100644
+--- a/libperf_events/operf_utils.cpp
++++ b/libperf_events/operf_utils.cpp
+@@ -732,12 +732,14 @@ static void __handle_sample_event(event_t * event, u64 sample_type)
+ case PERF_RECORD_MISC_HYPERVISOR:
+ domain = "hypervisor";
+ break;
++#if HAVE_PERF_GUEST_MACROS
+ case PERF_RECORD_MISC_GUEST_KERNEL:
+ domain = "guest OS";
+ break;
+ case PERF_RECORD_MISC_GUEST_USER:
+ domain = "guest user";
+ break;
++#endif
+ default:
+ domain = "unknown";
+ break;
+--
+1.7.9.7
+
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 0000000..0f609df
--- /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 @@
+Upstream-Status: Backport
+
+From fa889ea74b6b931e241a8cd57e90edc23cd7ab03 Mon Sep 17 00:00:00 2001
+From: William Cohen <wcohen@redhat.com>
+Date: Mon, 15 Oct 2012 15:09:55 -0500
+Subject: [PATCH] OProfile doesn't build for 32-bit ppc; the operf_utils.cpp
+ compile fails. Need to be able to build the 32-bit ppc
+ version of oprofile to provide the 32-bit ppc java support
+ libraries. The configure only handles the case of ppc64
+ with perf support.
+
+Signed-off-by: William Cohen <wcohen@redhat.com>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index b739133..7449854 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -104,7 +104,7 @@ AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf
+ if test "$HAVE_PERF_EVENTS" = "1"; then
+ PFM_LIB=
+ arch="`uname -m`"
+- if test "$arch" = "ppc64"; then
++ if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
+ AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
+ AC_CHECK_LIB(pfm,pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', [
+ AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1',
+--
+1.7.9.7
+
diff --git a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
index d283b5c..4491e7d 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 @@
require oprofile.inc
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
- file://0001-Add-rmb-definition-for-AArch64-architecture.patch"
+ file://0001-Add-rmb-definition-for-AArch64-architecture.patch \
+ file://0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch \
+ file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \
+ file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \
+ file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch"
SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8"
SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc"
OpenPOWER on IntegriCloud