diff options
Diffstat (limited to 'meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch')
-rw-r--r-- | meta/recipes-kernel/oprofile/oprofile/0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch | 107 |
1 files changed, 107 insertions, 0 deletions
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 @@ | |||
1 | Upstream-Status: Backport | ||
2 | |||
3 | From dbe24f5f0d98b1fe5517d2b137b4c59766e536ad Mon Sep 17 00:00:00 2001 | ||
4 | From: Maynard Johnson <maynardj@us.ibm.com> | ||
5 | Date: Mon, 19 Nov 2012 15:16:37 -0600 | ||
6 | Subject: [PATCH] Handle early perf_events kernel without | ||
7 | PERF_RECORD_MISC_GUEST* macros | ||
8 | |||
9 | In very early versions of perf_events kernel subsystem, the | ||
10 | PERF_RECORD_MISC_GUEST_KERNEL and PERF_RECORD_MISC_GUEST_USER | ||
11 | macros (in perf_event.h) were not yet defined. This patch adds | ||
12 | a configure check to determine when it's OK for source code to refer | ||
13 | to those macros. | ||
14 | |||
15 | This patch also does some minor cleanup of the configure script | ||
16 | help and warning messages relating to the --with-kernel option. | ||
17 | |||
18 | Signed-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 | |||
24 | diff --git a/configure.ac b/configure.ac | ||
25 | index 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 | |||
86 | diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp | ||
87 | index 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 | -- | ||
106 | 1.7.9.7 | ||
107 | |||