summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/oprofile
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/oprofile')
-rw-r--r--meta/recipes-kernel/oprofile/oprofile.inc36
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Add-rmb-definition-for-AArch64-architecture.patch31
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch208
-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-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch132
-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/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch36
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/acinclude.m4581
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/oprofile-no-query-modules.patch29
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/oprofile-root.patch113
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/opstart.patch245
-rw-r--r--meta/recipes-kernel/oprofile/oprofile_0.9.8.bb22
-rw-r--r--meta/recipes-kernel/oprofile/oprofile_git.bb11
-rwxr-xr-xmeta/recipes-kernel/oprofile/oprofileui-server/init37
-rw-r--r--meta/recipes-kernel/oprofile/oprofileui-server/oprofileui-server.service6
-rw-r--r--meta/recipes-kernel/oprofile/oprofileui-server_git.bb32
-rw-r--r--meta/recipes-kernel/oprofile/oprofileui.inc16
-rw-r--r--meta/recipes-kernel/oprofile/oprofileui_git.bb17
20 files changed, 1903 insertions, 0 deletions
diff --git a/meta/recipes-kernel/oprofile/oprofile.inc b/meta/recipes-kernel/oprofile/oprofile.inc
new file mode 100644
index 0000000000..080219ed3d
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile.inc
@@ -0,0 +1,36 @@
1SUMMARY = "System-Wide Profiler"
2DESCRIPTION = "OProfile is a system-wide profiler for Linux systems, capable \
3of profiling all running code at low overhead."
4HOMEPAGE = "http://oprofile.sourceforge.net/news/"
5BUGTRACKER = "http://sourceforge.net/tracker/?group_id=16191&atid=116191"
6
7LICENSE = "LGPLv2.1+ & GPLv2"
8LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
9 file://libopagent/opagent.h;beginline=5;endline=26;md5=4f16f72c7a493d8a4704aa18d03d15c6 \
10 file://daemon/liblegacy/p_module.h;beginline=2;endline=20;md5=fc23a43455edf185307274a99730b6e4"
11
12SECTION = "devel"
13
14DEPENDS = "popt binutils"
15RDEPENDS_${PN} = "binutils-symlinks"
16RRECOMMENDS_${PN} = "kernel-vmlinux"
17
18FILES_${PN} = "${bindir} ${libdir}/${BPN}/lib*${SOLIBS} ${datadir}/${BPN}"
19FILES_${PN}-dev += "${libdir}/${BPN}/lib*${SOLIBSDEV} ${libdir}/${BPN}/lib*.la"
20FILES_${PN}-staticdev += "${libdir}/${BPN}/lib*.a"
21
22INC_PR = "r2"
23
24SRC_URI = "file://opstart.patch \
25 file://oprofile-no-query-modules.patch \
26 file://oprofile-root.patch \
27 file://acinclude.m4"
28
29inherit autotools-brokensep
30
31EXTRA_OECONF = "--with-kernel=${STAGING_KERNEL_DIR} --without-x"
32do_configure () {
33 find ${S} -wholename '${S}/.pc' -prune -o -type f -print | xargs sed -i 's#ROOTHOME#${ROOT_HOME}#'
34 cp ${WORKDIR}/acinclude.m4 ${S}/
35 autotools_do_configure
36}
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Add-rmb-definition-for-AArch64-architecture.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Add-rmb-definition-for-AArch64-architecture.patch
new file mode 100644
index 0000000000..a2385cd2b2
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Add-rmb-definition-for-AArch64-architecture.patch
@@ -0,0 +1,31 @@
1From 27edaef9c6d66dfc324630ef40cb27e78031eeeb Mon Sep 17 00:00:00 2001
2From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
3Date: Tue, 15 Jan 2013 07:37:33 +0100
4Subject: [PATCH] Add rmb() definition for AArch64 architecture
5
6Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
7
8Upstream-Status: backport
9---
10 libperf_events/operf_utils.h | 5 +++++
11 1 file changed, 5 insertions(+)
12
13diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h
14index 815d51d..2df00b7 100644
15--- a/libperf_events/operf_utils.h
16+++ b/libperf_events/operf_utils.h
17@@ -148,6 +148,11 @@ void op_release_resources(void);
18 #define cpu_relax() asm volatile("":::"memory")
19 #endif
20
21+#ifdef __aarch64__
22+#define rmb() asm volatile("dmb ld" ::: "memory")
23+#define cpu_relax() asm volatile("yield" ::: "memory")
24+#endif
25+
26 #ifdef __mips__
27 #include <asm/unistd.h>
28 #define rmb() asm volatile( \
29--
301.8.0
31
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch
new file mode 100644
index 0000000000..d19948a4f8
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch
@@ -0,0 +1,208 @@
1Upstream-Status: Accepted
2
3From 36028035555297695f52e856f21920012fd64f79 Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Fri, 11 Jan 2013 13:29:57 -0600
6Subject: [PATCH] Allow ppc64 events to be specified with or without _GRP<n>
7 suffix
8
9All events for IBM PowerPC server processors (except CYCLES) have
10a _GRP<n> suffix. This is because the legacy opcontrol profiler
11can only profile events in the same group (i.e., having the same
12_GRP<n> suffix). But operf has no such restriction because it
13can multiplex events; thus, so we should allow the user to pass
14event names without the _GRP<n> suffix.
15
16Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
17---
18 doc/operf.1.in | 6 +++
19 doc/oprofile.xml | 12 +++++-
20 pe_profiling/operf.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++
21 utils/ophelp.c | 4 ++
22 4 files changed, 127 insertions(+), 2 deletions(-)
23
24diff --git a/doc/operf.1.in b/doc/operf.1.in
25index b109324..03027ca 100644
26--- a/doc/operf.1.in
27+++ b/doc/operf.1.in
28@@ -110,6 +110,12 @@ be specified using the symbolic name. If no unit mask is specified, 0x0 will be
29 used as the default.
30 .P
31 .RS
32+On IBM PowerPC systems, events may be specified with or without the
33+.I _GRP<n>
34+suffix. If no group number suffix is given, one will be automatically
35+assigned; thus, OProfile post-processing tools will always show real event
36+names that include the group number suffix.
37+.P
38 When no event specification is given, the default event for the running
39 processor type will be used for profiling.
40 Use
41diff --git a/doc/oprofile.xml b/doc/oprofile.xml
42index 0ae2b0b..0f74726 100644
43--- a/doc/oprofile.xml
44+++ b/doc/oprofile.xml
45@@ -1106,10 +1106,18 @@ shown by the output of <command>ophelp</command>. Unit masks with "extra:" para
46 specified using the symbolic name.
47 </para>
48 <note><para>
49-When using legacy mode <command>opcontrol</command> on PowerPC platforms, all events specified must be in the same group;
50+When using legacy mode <command>opcontrol</command> on IBM PowerPC platforms, all events specified must be in the same group;
51 i.e., the group number appended to the event name (e.g. <constant>&lt;<emphasis>some-event-name</emphasis>&gt;_GRP9
52 </constant>) must be the same.
53-</para></note>
54+</para>
55+<para>
56+When profiling with <command>operf</command> on IBM PowerPC platforms, the above restriction
57+regarding the same group number does not apply, and events may be
58+specified with or without the group number suffix. If no group number suffix is given, one will be automatically
59+assigned; thus, OProfile post-processing tools will always show real event
60+names that include the group number suffix.
61+</para>
62+</note>
63 <para>
64 If OProfile is using timer-interrupt mode, there is no event configuration possible.
65 </para>
66diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
67index 4416b29..a776e71 100644
68--- a/pe_profiling/operf.cpp
69+++ b/pe_profiling/operf.cpp
70@@ -1146,6 +1146,108 @@ static void _get_event_code(operf_event_t * event)
71 event->evt_code = config;
72 }
73
74+#if (defined(__powerpc__) || defined(__powerpc64__))
75+/* All ppc64 events (except CYCLES) have a _GRP<n> suffix. This is
76+ * because the legacy opcontrol profiler can only profile events in
77+ * the same group (i.e., having the same _GRP<n> suffix). But operf
78+ * can multiplex events, so we should allow the user to pass event
79+ * names without the _GRP<n> suffix.
80+ *
81+ * If event name is not CYCLES or does not have a _GRP<n> suffix,
82+ * we'll call ophelp and scan the list of events, searching for one
83+ * that matches up to the _GRP<n> suffix. If we don't find a match,
84+ * then we'll exit with the expected error message for invalid event name.
85+ */
86+static string _handle_powerpc_event_spec(string event_spec)
87+{
88+ FILE * fp;
89+ char line[MAX_INPUT];
90+ size_t grp_pos;
91+ string evt, retval, err_msg;
92+ size_t evt_name_len;
93+ bool first_non_cyc_evt_found = false;
94+ bool event_found = false;
95+ char event_name[OP_MAX_EVT_NAME_LEN], event_spec_str[OP_MAX_EVT_NAME_LEN + 20], * count_str;
96+ string cmd = OP_BINDIR;
97+ cmd += "/ophelp";
98+
99+ strncpy(event_spec_str, event_spec.c_str(), event_spec.length() + 1);
100+
101+ strncpy(event_name, strtok(event_spec_str, ":"), OP_MAX_EVT_NAME_LEN);
102+ count_str = strtok(NULL, ":");
103+ if (!count_str) {
104+ err_msg = "Invalid count for event ";
105+ goto out;
106+ }
107+
108+ if (!strcmp("CYCLES", event_name)) {
109+ event_found = true;
110+ goto out;
111+ }
112+
113+ evt = event_name;
114+ // Need to make sure the event name truly has a _GRP<n> suffix.
115+ grp_pos = evt.rfind("_GRP");
116+ if ((grp_pos != string::npos) && ((evt = evt.substr(grp_pos, string::npos))).length() > 4) {
117+ unsigned long value;
118+ char * end;
119+ value = strtoul(evt.substr(4, string::npos).c_str(), &end, 0);
120+ if (end && (*end == '\0')) {
121+ // Valid group number found after _GRP, so we can skip to the end.
122+ event_found = true;
123+ goto out;
124+ }
125+ }
126+
127+ // If we get here, it implies the user passed a non-CYCLES event without a GRP suffix.
128+ // Lets try to find a valid suffix for it.
129+ fp = popen(cmd.c_str(), "r");
130+ if (fp == NULL) {
131+ cerr << "Unable to execute ophelp to get info for event "
132+ << event_spec << endl;
133+ exit(EXIT_FAILURE);
134+ }
135+ evt_name_len = strlen(event_name);
136+ err_msg = "Cannot find event ";
137+ while (fgets(line, MAX_INPUT, fp)) {
138+ if (!first_non_cyc_evt_found) {
139+ if (!strncmp(line, "PM_", 3))
140+ first_non_cyc_evt_found = true;
141+ else
142+ continue;
143+ }
144+ if (line[0] == ' ' || line[0] == '\t')
145+ continue;
146+ if (!strncmp(line, event_name, evt_name_len)) {
147+ // Found a potential match. Check if it's a perfect match.
148+ string save_event_name = event_name;
149+ size_t full_evt_len = index(line, ':') - line;
150+ memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
151+ strncpy(event_name, line, full_evt_len);
152+ string candidate = event_name;
153+ if (candidate.rfind("_GRP") == evt_name_len) {
154+ event_found = true;
155+ break;
156+ } else {
157+ memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
158+ strncpy(event_name, save_event_name.c_str(), evt_name_len);
159+ }
160+ }
161+ }
162+ pclose(fp);
163+
164+out:
165+ if (!event_found) {
166+ cerr << err_msg << event_name << endl;
167+ cerr << "Error retrieving info for event "
168+ << event_spec << endl;
169+ exit(EXIT_FAILURE);
170+ }
171+ retval = event_name;
172+ return retval + ":" + count_str;
173+}
174+#endif
175+
176 static void _process_events_list(void)
177 {
178 string cmd = OP_BINDIR;
179@@ -1154,6 +1256,11 @@ static void _process_events_list(void)
180 FILE * fp;
181 string full_cmd = cmd;
182 string event_spec = operf_options::evts[i];
183+
184+#if (defined(__powerpc__) || defined(__powerpc64__))
185+ event_spec = _handle_powerpc_event_spec(event_spec);
186+#endif
187+
188 if (operf_options::callgraph) {
189 full_cmd += " --callgraph=1 ";
190 }
191diff --git a/utils/ophelp.c b/utils/ophelp.c
192index 53a5dde..63895c8 100644
193--- a/utils/ophelp.c
194+++ b/utils/ophelp.c
195@@ -652,6 +652,10 @@ int main(int argc, char const * argv[])
196 case CPU_PPC64_POWER7:
197 case CPU_PPC64_IBM_COMPAT_V1:
198 event_doc =
199+ "When using operf, events may be specified without a '_GRP<n>' suffix.\n"
200+ "If _GRP<n> (i.e., group number) is not specified, one will be automatically\n"
201+ "selected for use by the profiler. OProfile post-processing tools will\n"
202+ "always show real event names that include the group number suffix.\n\n"
203 "Documentation for IBM POWER7 can be obtained at:\n"
204 "http://www.power.org/events/Power7/\n"
205 "No public performance monitoring doc available for older processors.\n";
206--
2071.7.9.7
208
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-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..6f5b1c00ee
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
@@ -0,0 +1,132 @@
1Upstream-Status: Accepted
2
3From 8e36ad01ceb1257d05773b684dbe9358aecd3f71 Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Tue, 26 Feb 2013 13:41:27 -0600
6Subject: [PATCH] Fix PPC64-specific libpfm usage so it doesn't break ppc32
7 architecture
8
9The configure check to determine whether we should use libpfm or not
10is intended only for the ppc64 architecture, but was incorrectly
11hitting on the ppc32 architecture, too. Not only that, but it was using
12'uname' which is not a good idea in cross-compile situtations.
13
14Then, aside from that, we had several instances in the source code
15of the following:
16 #if (defined(__powerpc__) || defined(__powerpc64__))
17which incorrectly included ppc32 architecutre also, when it was intended
18for use as PPC64 architecture.
19
20This patch fixes both errors.
21
22Signed-off-by: Maynard Johnson <maynardj@us.ibm.com
23---
24 configure.ac | 5 ++---
25 libperf_events/operf_utils.cpp | 4 ++--
26 libperf_events/operf_utils.h | 6 ++++++
27 pe_profiling/operf.cpp | 10 +++++-----
28 4 files changed, 15 insertions(+), 10 deletions(-)
29
30diff --git a/configure.ac b/configure.ac
31index a9b1ee4..a0da98c 100644
32--- a/configure.ac
33+++ b/configure.ac
34@@ -154,11 +154,10 @@ else
35 fi
36
37 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
38-
39+AC_CANONICAL_HOST
40 if test "$HAVE_PERF_EVENTS" = "1"; then
41 PFM_LIB=
42- arch="`uname -m`"
43- if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
44+ if test "$host_cpu" = "powerpc64"; then
45 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
46 AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
47 AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
48diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
49index da964fd..a17200b 100644
50--- a/libperf_events/operf_utils.cpp
51+++ b/libperf_events/operf_utils.cpp
52@@ -83,7 +83,7 @@ static event_t comm_event;
53 * the following method is to map the operf-record event value to a value that
54 * opreport can understand.
55 */
56-#if (defined(__powerpc__) || defined(__powerpc64__))
57+#if PPC64_ARCH
58 #define NIL_CODE ~0U
59
60 #if HAVE_LIBPFM3
61@@ -716,7 +716,7 @@ static void __handle_sample_event(event_t * event, u64 sample_type)
62 } else if (event->header.misc == PERF_RECORD_MISC_USER) {
63 in_kernel = false;
64 }
65-#if (defined(__powerpc__) || defined(__powerpc64__))
66+#if PPC64_ARCH
67 else if (event->header.misc == PERF_RECORD_MISC_HYPERVISOR) {
68 #define MAX_HYPERVISOR_ADDRESS 0xfffffffULL
69 if (data.ip > MAX_HYPERVISOR_ADDRESS) {
70diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h
71index 2df00b7..ddf05ed 100644
72--- a/libperf_events/operf_utils.h
73+++ b/libperf_events/operf_utils.h
74@@ -45,6 +45,12 @@ extern bool throttled;
75 #define MMAP_WINDOW_SZ (32 * 1024 * 1024ULL)
76 #endif
77
78+/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
79+ * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
80+ * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
81+ */
82+#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
83+
84 extern unsigned int op_nr_counters;
85
86 static inline size_t align_64bit(u64 x)
87diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
88index e7c2eab..e1190c2 100644
89--- a/pe_profiling/operf.cpp
90+++ b/pe_profiling/operf.cpp
91@@ -1177,7 +1177,7 @@ static void _get_event_code(operf_event_t * event)
92 event->evt_code = config;
93 }
94
95-#if (defined(__powerpc__) || defined(__powerpc64__))
96+#if PPC64_ARCH
97 /* All ppc64 events (except CYCLES) have a _GRP<n> suffix. This is
98 * because the legacy opcontrol profiler can only profile events in
99 * the same group (i.e., having the same _GRP<n> suffix). But operf
100@@ -1287,7 +1287,7 @@ static void _process_events_list(void)
101 string full_cmd = cmd;
102 string event_spec = operf_options::evts[i];
103
104-#if (defined(__powerpc__) || defined(__powerpc64__))
105+#if PPC64_ARCH
106 event_spec = _handle_powerpc_event_spec(event_spec);
107 #endif
108
109@@ -1357,9 +1357,9 @@ static void _process_events_list(void)
110 _get_event_code(&event);
111 events.push_back(event);
112 }
113-#if (defined(__powerpc__) || defined(__powerpc64__))
114+#if PPC64_ARCH
115 {
116- /* This section of code is for architectures such as ppc[64] for which
117+ /* This section of code is soley for the ppc64 architecture for which
118 * the oprofile event code needs to be converted to the appropriate event
119 * code to pass to the perf_event_open syscall.
120 */
121@@ -1404,7 +1404,7 @@ static void get_default_event(void)
122 _get_event_code(&dft_evt);
123 events.push_back(dft_evt);
124
125-#if (defined(__powerpc__) || defined(__powerpc64__))
126+#if PPC64_ARCH
127 {
128 /* This section of code is for architectures such as ppc[64] for which
129 * the oprofile event code needs to be converted to the appropriate event
130--
1311.7.9.7
132
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/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch b/meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch
new file mode 100644
index 0000000000..b155cacd4a
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch
@@ -0,0 +1,36 @@
1Upstream-Status: Accepted
2
3From 735d9eb0322b34b3d26302a1dac173100d718d35 Mon Sep 17 00:00:00 2001
4From: Maynard Johnson <maynardj@us.ibm.com>
5Date: Thu, 10 Jan 2013 14:24:26 -0600
6Subject: [PATCH] ophelp lists events: Fix doc URL for ppc64 arch
7
8When ophelp is used to list available events, it displays
9some help text before the event list to direct the user
10where to find more info. For the ppc64 architecture, a
11stale URL was listed. This patch fixes that URL.
12
13Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
14---
15 utils/ophelp.c | 5 +++--
16 1 file changed, 3 insertions(+), 2 deletions(-)
17
18diff --git a/utils/ophelp.c b/utils/ophelp.c
19index f48697b..827f2d0 100644
20--- a/utils/ophelp.c
21+++ b/utils/ophelp.c
22@@ -652,8 +652,9 @@ int main(int argc, char const * argv[])
23 case CPU_PPC64_POWER7:
24 case CPU_PPC64_IBM_COMPAT_V1:
25 event_doc =
26- "Obtain PowerPC64 processor documentation at:\n"
27- "http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC\n";
28+ "Documentation for IBM POWER7 can be obtained at:\n"
29+ "http://www.power.org/events/Power7/\n"
30+ "No public performance monitoring doc available for older processors.\n";
31 break;
32
33 case CPU_PPC64_CELL:
34--
351.7.9.7
36
diff --git a/meta/recipes-kernel/oprofile/oprofile/acinclude.m4 b/meta/recipes-kernel/oprofile/oprofile/acinclude.m4
new file mode 100644
index 0000000000..95ecd91b5e
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/acinclude.m4
@@ -0,0 +1,581 @@
1dnl AX_KERNEL_OPTION(option, action-if-found, action-if-not-found)
2dnl see if autoconf.h defines the option
3AC_DEFUN([AX_KERNEL_OPTION], [
4SAVE_CFLAGS=$CFLAGS
5CFLAGS="-I$KINC -O2 -D__KERNEL__"
6AC_TRY_COMPILE( [#include <linux/config.h>],
7[
8#ifndef $1
9break_me_hard(\\\);
10#endif
11],[$2],[$3],)
12CFLAGS=$SAVE_CFLAGS
13])
14
15dnl Handle the 2.4 module inside module/
16AC_DEFUN([AX_CONFIG_MODULE],
17[
18if test ! -f $KINC/linux/autoconf.h; then
19 AC_MSG_ERROR([no suitably configured kernel include tree found])
20fi
21
22dnl --- Get Linux kernel version and compile parameters ---
23
24AC_SUBST(KVERS)
25AC_MSG_CHECKING([for kernel version])
26dnl it's like this to handle mandrake's fubar version.h - bug #471448
27eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $[]3}'`
28AC_MSG_RESULT([$KVERS])
29case "$KVERS" in
302.2.*|2.4.*) ;;
31*) AC_MSG_ERROR([Unsupported kernel version])
32esac
33
34dnl Check for the minimal kernel version supported
35AC_MSG_CHECKING([kernel version])
36AX_KERNEL_VERSION(2, 2, 10, <=, AC_MSG_RESULT([ok]), AC_MSG_ERROR([check html documentation install section]))
37
38dnl linux/spinlock.h added at some point in past
39AC_MSG_CHECKING([for $KINC/linux/spinlock.h])
40if test -f $KINC/linux/spinlock.h; then
41 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER"
42 AC_MSG_RESULT([yes])
43else
44 AC_MSG_RESULT([no])
45fi
46
47AC_MSG_CHECKING([for rtc_lock])
48gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null
49if test "$?" -eq 0; then
50 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK"
51 AC_MSG_RESULT([yes])
52else
53 AC_MSG_RESULT([no])
54fi
55
56arch="unknown"
57AC_MSG_CHECKING(for x86-64 architecture)
58AX_KERNEL_OPTION(CONFIG_X86_64, x8664=1, x8664=0)
59AX_MSG_RESULT_YN($x8664)
60BUILD_HAMMER=no
61if test "$x8664" -eq 1; then
62 arch="x86"
63 BUILD_HAMMER=yes
64else
65 AC_MSG_CHECKING(for x86 architecture)
66 AX_KERNEL_OPTION(CONFIG_X86, x86=1, x86=0)
67 AX_KERNEL_OPTION(CONFIG_X86_WP_WORKS_OK, x86=1, x86=$x86)
68 AX_MSG_RESULT_YN($x86)
69 test "$x86" = 1 && arch="x86"
70
71 if test "$arch" = "unknown"; then
72 AC_MSG_CHECKING(for ia64 architecture)
73 AX_KERNEL_OPTION(CONFIG_IA64, ia64=1, ia64=0)
74 AX_MSG_RESULT_YN($ia64)
75 test "$ia64" = 1 && arch="ia64"
76 fi
77
78fi
79AC_SUBST(BUILD_HAMMER)
80
81test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture)
82
83dnl check to see if kernel verion appropriate for arch
84AC_MSG_CHECKING(arch/kernel version combination)
85case "$arch" in
86ia64)
87 AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]),
88 AC_MSG_ERROR([unsupported arch/kernel])) ;;
89*) AC_MSG_RESULT([ok])
90esac
91
92dnl for now we do not support PREEMPT patch
93AC_MSG_CHECKING([for preempt patch])
94AX_KERNEL_OPTION(CONFIG_PREEMPT,preempt=1,preempt=0)
95AX_MSG_RESULT_YN([$preempt])
96test "$preempt" = 0 || AC_MSG_ERROR([unsupported kernel configuration : CONFIG_PREEMPT])
97
98AC_SUBST(KINC)
99
100MODINSTALLDIR=/lib/modules/$KVERS
101
102OPROFILE_MODULE_ARCH=$arch
103AC_SUBST(OPROFILE_MODULE_ARCH)
104]
105)
106
107dnl AX_MSG_RESULT_YN(a)
108dnl results "yes" iff a==1, "no" else
109AC_DEFUN([AX_MSG_RESULT_YN], [x=no
110test "x$1" = "x1" && x=yes
111AC_MSG_RESULT($x)])
112
113dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc))
114AC_DEFUN([AX_MALLOC_ATTRIBUTE],
115[
116AC_MSG_CHECKING([whether malloc attribute is understood])
117SAVE_CFLAGS=$CFLAGS
118CFLAGS="-Werror $CFLAGS"
119AC_TRY_COMPILE(,[
120void monkey() __attribute__((malloc));
121],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no]))
122CFLAGS=$SAVE_CFLAGS
123]
124)
125
126dnl builtin_expect is used in module we can't add that in config.h
127AC_DEFUN([AX_BUILTIN_EXPECT],
128[
129AC_MSG_CHECKING([whether __builtin_expect is understood])
130SAVE_CFLAGS=$CFLAGS
131CFLAGS="-Werror $CFLAGS"
132AC_TRY_LINK(,[
133int i;
134if (__builtin_expect(i, 0)) { }
135],
136AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK",
137AC_MSG_RESULT([no]);)
138CFLAGS=$SAVE_CFLAGS
139]
140)
141
142dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs
143AC_DEFUN([AX_EXTRA_DIRS],
144[
145AC_ARG_WITH(extra-includes,
146[ --with-extra-includes=DIR add extra include paths],
147 use_extra_includes="$withval",
148 use_extra_includes=NO
149)
150if test -n "$use_extra_includes" && \
151 test "$use_extra_includes" != "NO"; then
152 ac_save_ifs=$IFS
153 IFS=':'
154 for dir in $use_extra_includes; do
155 extra_includes="$extra_includes -I$dir"
156 done
157 IFS=$ac_save_ifs
158 CPPFLAGS="$CPPFLAGS $extra_includes"
159fi
160
161AC_ARG_WITH(extra-libs,
162[ --with-extra-libs=DIR add extra library paths],
163 use_extra_libs=$withval,
164 use_extra_libs=NO
165)
166if test -n "$use_extra_libs" && \
167 test "$use_extra_libs" != "NO"; then
168 ac_save_ifs=$IFS
169 IFS=':'
170 for dir in $use_extra_libs; do
171 extra_libraries="$extra_libraries -L$dir"
172 done
173 IFS=$ac_save_ifs
174 LDFLAGS="$LDFLAGS $extra_libraries"
175fi
176]
177)
178
179dnl AX_POPT_CONST - check popt prototype
180AC_DEFUN([AX_POPT_CONST],
181[
182AC_MSG_CHECKING([popt prototype])
183SAVE_CXXFLAGS=$CXXFLAGS
184CXXFLAGS="-Werror $CXXFLAGS"
185AC_TRY_COMPILE([#include <popt.h>],
186[
187int c; char **v;
188poptGetContext(0, c, v, 0, 0);
189],
190AC_MSG_RESULT([takes char **]);,
191AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **]))
192CXXFLAGS="$SAVE_CXXFLAGS"
193]
194)
195
196dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK
197AC_DEFUN([AX_CHECK_SSTREAM],
198[
199AC_MSG_CHECKING([whether to use included sstream])
200AC_TRY_COMPILE([#include <sstream>], [],
201AC_MSG_RESULT([no]);,
202AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include")
203]
204)
205
206dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false)
207dnl exec action-if-true if typedef_name is a typedef to type else exec
208dnl action-if-false
209dnl currently work only with type typedef'ed in stddef.h
210AC_DEFUN([AX_CHECK_TYPEDEF], [
211dnl AC_LANG_PUSH(C) not in autoconf 2.13
212AC_LANG_SAVE
213AC_LANG_C
214SAVE_CFLAGS=$CFLAGS
215CFLAGS="-Werror $CFLAGS"
216
217AC_TRY_COMPILE(
218 [
219 #include <stddef.h>
220 ],
221 [
222 typedef void (*fct1)($1);
223 typedef void (*fct2)($2);
224 fct1 f1 = 0;
225 fct2 f2 = 0;
226 if (f1 == f2) {}
227 ],
228[$3],[$4])
229
230CFLAGS=$SAVE_CFLAGS
231AC_LANG_RESTORE
232])
233
234
235dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name)
236dnl set var_name to the typedef name of $1 which must be in canditate_list
237dnl else produce a fatal error
238AC_DEFUN([AX_TYPEDEFED_NAME], [
239 AC_MSG_CHECKING([type of $1])
240 for f in $2; do
241 AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="")
242 if test -n "${$3}"; then
243 break
244 fi
245 done
246 if test -n "${$3}"; then
247 AC_MSG_RESULT([${$3}])
248 else
249 AC_MSG_ERROR([not found])
250 fi
251])
252
253dnl find a binary in the path
254AC_DEFUN([QT_FIND_PATH],
255[
256 AC_MSG_CHECKING([for $1])
257 AC_CACHE_VAL(qt_cv_path_$1,
258 [
259 qt_cv_path_$1="NONE"
260 if test -n "$$2"; then
261 qt_cv_path_$1="$$2";
262 else
263 dirs="$3"
264 qt_save_IFS=$IFS
265 IFS=':'
266 for dir in $PATH; do
267 dirs="$dirs $dir"
268 done
269 IFS=$qt_save_IFS
270
271 for dir in $dirs; do
272 if test -x "$dir/$1"; then
273 if test -n "$5"; then
274 evalstr="$dir/$1 $5 2>&1 "
275 if eval $evalstr; then
276 qt_cv_path_$1="$dir/$1"
277 break
278 fi
279 else
280 qt_cv_path_$1="$dir/$1"
281 break
282 fi
283 fi
284 done
285 fi
286 ])
287
288 if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
289 AC_MSG_RESULT(not found)
290 $4
291 else
292 AC_MSG_RESULT($qt_cv_path_$1)
293 $2=$qt_cv_path_$1
294 fi
295])
296
297dnl Find the uic compiler on the path or in qt_cv_dir
298AC_DEFUN([QT_FIND_UIC],
299[
300 QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin)
301 if test -z "$ac_uic" -a "$FATAL" = 1; then
302 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !])
303 fi
304])
305
306dnl Find the right moc in path/qt_cv_dir
307AC_DEFUN([QT_FIND_MOC],
308[
309 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
310 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
311
312 if test -n "$ac_moc1" -a -n "$ac_moc2"; then
313 dnl found both. Prefer Qt3's if it exists else moc2
314 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
315 if test "$?" = 0; then
316 ac_moc=$ac_moc1;
317 else
318 ac_moc=$ac_moc2;
319 fi
320 else
321 if test -n "$ac_moc1"; then
322 ac_moc=$ac_moc1;
323 else
324 ac_moc=$ac_moc2;
325 fi
326 fi
327
328 if test -z "$ac_moc" -a "$FATAL" = 1; then
329 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
330 fi
331])
332
333dnl check a particular libname
334AC_DEFUN([QT_TRY_LINK],
335[
336 SAVE_LIBS="$LIBS"
337 LIBS="$LIBS $1"
338 AC_TRY_LINK([
339 #include <qglobal.h>
340 #include <qstring.h>
341 ],
342 [
343 QString s("mangle_failure");
344 #if (QT_VERSION < 221)
345 break_me_(\\\);
346 #endif
347 ],
348 qt_cv_libname=$1,
349 )
350 LIBS="$SAVE_LIBS"
351])
352
353dnl check we can do a compile
354AC_DEFUN([QT_CHECK_COMPILE],
355[
356 AC_MSG_CHECKING([for Qt library name])
357
358 AC_CACHE_VAL(qt_cv_libname,
359 [
360 AC_LANG_CPLUSPLUS
361 SAVE_CXXFLAGS=$CXXFLAGS
362 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
363
364 for libname in -lqt-mt -lqt3 -lqt2 -lqt;
365 do
366 QT_TRY_LINK($libname)
367 if test -n "$qt_cv_libname"; then
368 break;
369 fi
370 done
371
372 CXXFLAGS=$SAVE_CXXFLAGS
373 ])
374
375 if test -z "$qt_cv_libname"; then
376 AC_MSG_RESULT([failed])
377 if test "$FATAL" = 1 ; then
378 AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
379 fi
380 else
381 AC_MSG_RESULT([$qt_cv_libname])
382 fi
383])
384
385dnl get Qt version we're using
386AC_DEFUN([QT_GET_VERSION],
387[
388 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
389 [
390 AC_LANG_CPLUSPLUS
391 SAVE_CPPFLAGS=$CPPFLAGS
392 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
393
394 cat > conftest.$ac_ext <<EOF
395#line __oline__ "configure"
396#include "confdefs.h"
397#include <qglobal.h>
398"%%%"QT_VERSION_STR"%%%"
399EOF
400 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
401 grep '^"%%%"' 2>/dev/null | \
402 sed -e 's/"%%%"//g' -e 's/"//g'`
403 rm -f conftest.$ac_ext
404 CPPFLAGS=$SAVE_CPPFLAGS
405 ])
406
407 QT_VERSION=$lyx_cv_qtversion
408 AC_SUBST(QT_VERSION)
409])
410
411dnl start here
412AC_DEFUN([QT_DO_IT_ALL],
413[
414 dnl Please leave this alone. I use this file in
415 dnl oprofile.
416 FATAL=0
417
418 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ],
419 [ qt_cv_dir=`eval echo "$withval"/` ])
420
421 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ],
422 [ qt_cv_includes=`eval echo "$withval"` ])
423
424 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.],
425 [ qt_cv_libraries=`eval echo "$withval"` ])
426
427 dnl pay attention to $QTDIR unless overridden
428 if test -z "$qt_cv_dir"; then
429 qt_cv_dir=$QTDIR
430 fi
431
432 dnl derive inc/lib if needed
433 if test -n "$qt_cv_dir"; then
434 if test -z "$qt_cv_includes"; then
435 qt_cv_includes=$qt_cv_dir/include
436 fi
437 if test -z "$qt_cv_libraries"; then
438 qt_cv_libraries=$qt_cv_dir/lib
439 fi
440 fi
441
442 dnl flags for compilation
443 QT_INCLUDES=
444 QT_LDFLAGS=
445 if test -n "$qt_cv_includes"; then
446 QT_INCLUDES="-I$qt_cv_includes"
447 fi
448 if test -n "$qt_cv_libraries"; then
449 QT_LDFLAGS="-L$qt_cv_libraries"
450 fi
451 AC_SUBST(QT_INCLUDES)
452 AC_SUBST(QT_LDFLAGS)
453
454 QT_FIND_MOC
455 MOC=$ac_moc
456 AC_SUBST(MOC)
457 QT_FIND_UIC
458 UIC=$ac_uic
459 AC_SUBST(UIC)
460
461 QT_CHECK_COMPILE
462
463 QT_LIB=$qt_cv_libname;
464 AC_SUBST(QT_LIB)
465
466 if test -n "$qt_cv_libname"; then
467 QT_GET_VERSION
468 fi
469])
470
471dnl AX_CXXFLAGS_OPTIONS(var-name, option)
472dnl add option to var-name if $CXX support it.
473AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [
474AC_MSG_CHECKING([whether ${CXX} support precompiled header])
475AC_LANG_SAVE
476AC_LANG_CPLUSPLUS
477SAVE_CXXFLAGS=$CXXFLAGS
478dnl we consider than if -Winvalid-pch is accepted pch will works ...
479CXXFLAGS=-Winvalid-pch
480dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and
481dnl the fact than some pch will be invalid for the given compilation option
482AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no]))
483CXXFLAGS=$SAVE_CXXFLAGS
484AC_LANG_RESTORE
485])
486
487dnl AX_CHECK_DOCBOOK
488AC_DEFUN([AX_CHECK_DOCBOOK], [
489# It's just rude to go over the net to build
490XSLTPROC_FLAGS=--nonet
491DOCBOOK_ROOT=
492if test ! -f /etc/xml/catalog; then
493 for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/;
494 do
495 if test -d "$i"; then
496 DOCBOOK_ROOT=$i
497 fi
498 done
499
500 # Last resort - try net
501 if test -z "$DOCBOOK_ROOT"; then
502 XSLTPROC_FLAGS=
503 fi
504else
505 XML_CATALOG=/etc/xml/catalog
506 CAT_ENTRY_START='<!--'
507 CAT_ENTRY_END='-->'
508fi
509
510AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
511XSLTPROC_WORKS=no
512if test -n "$XSLTPROC"; then
513 AC_MSG_CHECKING([whether xsltproc works])
514
515 if test -n "$XML_CATALOG"; then
516 DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
517 else
518 DB_FILE="$DOCBOOK_ROOT/docbook.xsl"
519 fi
520
521 $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
522<?xml version="1.0" encoding='ISO-8859-1'?>
523<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
524<book id="test">
525</book>
526END
527 if test "$?" = 0; then
528 XSLTPROC_WORKS=yes
529 fi
530 AC_MSG_RESULT($XSLTPROC_WORKS)
531fi
532AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes")
533
534AC_SUBST(XML_CATALOG)
535AC_SUBST(XSLTPROC_FLAGS)
536AC_SUBST(DOCBOOK_ROOT)
537AC_SUBST(CAT_ENTRY_START)
538AC_SUBST(CAT_ENTRY_END)
539])
540
541dnl AX_CFLAGS_OPTIONS(var-name, option)
542dnl add option to var-name if $CC support it.
543AC_DEFUN([AX_CFLAGS_OPTION], [
544AC_MSG_CHECKING([whether ${CC} $2 is understood])
545AC_LANG_SAVE
546AC_LANG_C
547SAVE_CFLAGS=$CFLAGS
548CFLAGS=$2
549AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
550CFLAGS=$SAVE_CFLAGS
551AC_LANG_RESTORE
552])
553
554
555dnl AX_CXXFLAGS_OPTIONS(var-name, option)
556dnl add option to var-name if $CXX support it.
557AC_DEFUN([AX_CXXFLAGS_OPTION], [
558AC_MSG_CHECKING([whether ${CXX} $2 is understood])
559AC_LANG_SAVE
560AC_LANG_CPLUSPLUS
561SAVE_CXXFLAGS=$CXXFLAGS
562CXXFLAGS=$2
563AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
564CXXFLAGS=$SAVE_CXXFLAGS
565AC_LANG_RESTORE
566])
567
568dnl AX_COPY_IF_CHANGE(source, dest)
569dnl copy source to dest if they don't compare equally or if dest doesn't exist
570AC_DEFUN([AX_COPY_IF_CHANGE], [
571if test -r $2; then
572 if cmp $1 $2 > /dev/null; then
573 echo $2 is unchanged
574 else
575 cp -f $1 $2
576 fi
577else
578 cp -f $1 $2
579fi
580])
581
diff --git a/meta/recipes-kernel/oprofile/oprofile/oprofile-no-query-modules.patch b/meta/recipes-kernel/oprofile/oprofile/oprofile-no-query-modules.patch
new file mode 100644
index 0000000000..c9d7cd63e7
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/oprofile-no-query-modules.patch
@@ -0,0 +1,29 @@
1disable portions which use query_module on 2.6 kernel this is not available
2in OE we dont support 2.4 anyway
3
4
5Upstream-Status: Pending
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Index: oprofile-0.9.6/daemon/liblegacy/opd_kernel.c
9===================================================================
10--- oprofile-0.9.6.orig/daemon/liblegacy/opd_kernel.c 2009-11-24 07:25:17.000000000 -0800
11+++ oprofile-0.9.6/daemon/liblegacy/opd_kernel.c 2011-07-18 10:08:39.863798825 -0700
12@@ -270,6 +270,9 @@
13 */
14 static void opd_drop_module_sample(unsigned long eip)
15 {
16+ verbprintf(vmodule, "query_module not available on linux-2.6: %s\n", strerror(EPERM));
17+
18+#if 0
19 char * module_names;
20 char * name;
21 size_t size = 1024;
22@@ -307,6 +310,7 @@
23
24 if (module_names)
25 free(module_names);
26+#endif
27 }
28
29
diff --git a/meta/recipes-kernel/oprofile/oprofile/oprofile-root.patch b/meta/recipes-kernel/oprofile/oprofile/oprofile-root.patch
new file mode 100644
index 0000000000..f3fe4c9cb3
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/oprofile-root.patch
@@ -0,0 +1,113 @@
1Change hardcoded /root to /home/root
2
3Upstream-Status: inappropriate [OE specific]
4
5Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
6
7Replace "/home/root" with stub "ROOTHOME", then substitute it with
8real root home directory which is configured dymanically.
9
10Signed-off-by: Kang Kai <kai.kang@windriver.com>
11
12diff -ur oprofile-0.9.7.orig/doc/opcontrol.1.in oprofile-0.9.7/doc/opcontrol.1.in
13--- oprofile-0.9.7.orig/doc/opcontrol.1.in 2011-07-04 21:25:04.000000000 -0500
14+++ oprofile-0.9.7/doc/opcontrol.1.in 2012-07-02 14:02:16.358865420 -0500
15@@ -171,7 +171,7 @@
16
17 .SH FILES
18 .TP
19-.I /root/.oprofile/daemonrc
20+.I ROOTHOME/.oprofile/daemonrc
21 Configuration file for opcontrol
22 .TP
23 .I /var/lib/oprofile/samples/
24diff -ur oprofile-0.9.7.orig/doc/oprofile.1 oprofile-0.9.7/doc/oprofile.1
25--- oprofile-0.9.7.orig/doc/oprofile.1 2011-08-12 10:23:27.000000000 -0500
26+++ oprofile-0.9.7/doc/oprofile.1 2012-07-02 14:02:29.295862358 -0500
27@@ -150,7 +150,7 @@
28 .I $HOME/.oprofile/
29 Configuration files
30 .TP
31-.I /root/.oprofile/daemonrc
32+.I ROOTHOME/.oprofile/daemonrc
33 Configuration file for opcontrol
34 .TP
35 .I /opt/oprofile-0.9.7-rc3/share/oprofile/
36diff -ur oprofile-0.9.7.orig/doc/oprofile.1.in oprofile-0.9.7/doc/oprofile.1.in
37--- oprofile-0.9.7.orig/doc/oprofile.1.in 2011-07-04 21:25:04.000000000 -0500
38+++ oprofile-0.9.7/doc/oprofile.1.in 2012-07-02 14:01:35.812004623 -0500
39@@ -150,7 +150,7 @@
40 .I $HOME/.oprofile/
41 Configuration files
42 .TP
43-.I /root/.oprofile/daemonrc
44+.I ROOTHOME/.oprofile/daemonrc
45 Configuration file for opcontrol
46 .TP
47 .I @prefix@/share/oprofile/
48diff -ur oprofile-0.9.7.orig/doc/oprofile.html oprofile-0.9.7/doc/oprofile.html
49--- oprofile-0.9.7.orig/doc/oprofile.html 2011-07-04 21:32:35.000000000 -0500
50+++ oprofile-0.9.7/doc/oprofile.html 2012-07-02 14:04:59.804018961 -0500
51@@ -1394,7 +1394,7 @@
52 <dd>
53 <p>
54 Followed by list arguments for profiling set up. List of arguments
55- saved in <code class="filename">/root/.oprofile/daemonrc</code>.
56+ saved in <code class="filename">ROOTHOME/.oprofile/daemonrc</code>.
57 Giving this option is not necessary; you can just directly pass one
58 of the setup options, e.g. <span class="command"><strong>opcontrol --no-vmlinux</strong></span>.
59 </p>
60@@ -1430,7 +1430,7 @@
61 <dd>
62 <p>
63 Start data collection with either arguments provided by <code class="option">--setup</code>
64- or information saved in <code class="filename">/root/.oprofile/daemonrc</code>. Specifying
65+ or information saved in <code class="filename">ROOTHOME/.oprofile/daemonrc</code>. Specifying
66 the addition <code class="option">--verbose</code> makes the daemon generate lots of debug data
67 whilst it is running.
68 </p>
69diff -ur oprofile-0.9.7.orig/doc/oprofile.xml oprofile-0.9.7/doc/oprofile.xml
70--- oprofile-0.9.7.orig/doc/oprofile.xml 2011-07-04 21:25:04.000000000 -0500
71+++ oprofile-0.9.7/doc/oprofile.xml 2012-07-02 14:02:03.543019283 -0500
72@@ -568,7 +568,7 @@
73 <term><option>--setup</option></term>
74 <listitem><para>
75 Followed by list arguments for profiling set up. List of arguments
76- saved in <filename>/root/.oprofile/daemonrc</filename>.
77+ saved in <filename>ROOTHOME/.oprofile/daemonrc</filename>.
78 Giving this option is not necessary; you can just directly pass one
79 of the setup options, e.g. <command>opcontrol --no-vmlinux</command>.
80 </para></listitem>
81@@ -592,7 +592,7 @@
82 <term><option>--start</option></term>
83 <listitem><para>
84 Start data collection with either arguments provided by <option>--setup</option>
85- or information saved in <filename>/root/.oprofile/daemonrc</filename>. Specifying
86+ or information saved in <filename>ROOTHOME/.oprofile/daemonrc</filename>. Specifying
87 the addition <option>--verbose</option> makes the daemon generate lots of debug data
88 whilst it is running.
89 </para></listitem>
90diff -ur oprofile-0.9.7.orig/gui/oprof_start_util.cpp oprofile-0.9.7/gui/oprof_start_util.cpp
91--- oprofile-0.9.7.orig/gui/oprof_start_util.cpp 2011-07-04 21:25:04.000000000 -0500
92+++ oprofile-0.9.7/gui/oprof_start_util.cpp 2012-07-02 13:55:21.041876096 -0500
93@@ -39,7 +39,7 @@
94 // return the ~ expansion suffixed with a '/'
95 string const get_config_dir()
96 {
97- return "/root";
98+ return "ROOTHOME";
99 }
100
101 string daemon_pid;
102diff -ur oprofile-0.9.7.orig/utils/opcontrol oprofile-0.9.7/utils/opcontrol
103--- oprofile-0.9.7.orig/utils/opcontrol 2011-07-20 14:36:48.000000000 -0500
104+++ oprofile-0.9.7/utils/opcontrol 2012-07-02 13:55:06.232872688 -0500
105@@ -384,7 +384,7 @@
106 OPROFILED="$OPDIR/oprofiled"
107
108 # location for daemon setup information
109- SETUP_DIR="/root/.oprofile"
110+ SETUP_DIR="ROOTHOME/.oprofile"
111 SETUP_FILE="$SETUP_DIR/daemonrc"
112 SEC_SETUP_FILE="$SETUP_DIR/daemonrc_new"
113
diff --git a/meta/recipes-kernel/oprofile/oprofile/opstart.patch b/meta/recipes-kernel/oprofile/oprofile/opstart.patch
new file mode 100644
index 0000000000..8696f4ef4d
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/opstart.patch
@@ -0,0 +1,245 @@
1Upstream-Status: Pending
2
3The patch gives a low overhead way of starting/stopping oprofile which
4doesn't involve script exection.
5
6(written by RP in OpenedHand days)
7
8diff --git a/utils/Makefile.am b/utils/Makefile.am
9index d34b060..dff15f9 100644
10--- oprofile.orig/utils/Makefile.am
11+++ oprofile/utils/Makefile.am
12@@ -7,7 +7,7 @@ AM_LDFLAGS = @OP_LDFLAGS@
13
14 LIBS=@POPT_LIBS@ @LIBERTY_LIBS@
15
16-bin_PROGRAMS = ophelp op-check-perfevents
17+bin_PROGRAMS = ophelp op-check-perfevents opstart
18 dist_bin_SCRIPTS = opcontrol
19
20 op_check_perfevents_SOURCES = op_perf_events_checker.c
21@@ -15,3 +15,10 @@ op_check_perfevents_CPPFLAGS = ${AM_CFLAGS} @PERF_EVENT_FLAGS@
22
23 ophelp_SOURCES = ophelp.c
24 ophelp_LDADD = ../libop/libop.a ../libutil/libutil.a
25+
26+opstart_SOURCES = opstart.c
27+
28+install-exec-local:
29+ cd $(DESTDIR)/$(bindir) && \
30+ rm -f opstop && \
31+ $(LN_S) opstart opstop
32Index: oprofile/utils/opstart.c
33===================================================================
34--- /dev/null 1970-01-01 00:00:00.000000000 +0000
35+++ oprofile/utils/opstart.c 2008-07-02 15:14:07.000000000 +0100
36@@ -0,0 +1,110 @@
37+/**
38+ * @file opstart.c
39+ * Start/Stop oprofile
40+ *
41+ * @remark Copyright 2007 Openedhand Ltd.
42+ * @remark Read the file COPYING
43+ *
44+ * @author Richard Purdie
45+ */
46+
47+#include <signal.h>
48+#include <stdio.h>
49+#include <stdlib.h>
50+#include <string.h>
51+#include <unistd.h>
52+#include <sys/types.h>
53+#include <sys/stat.h>
54+
55+int main(const int argc, const char* argv[])
56+{
57+ const char *enable = "/dev/oprofile/enable";
58+ const char *lockfile;
59+ unsigned long dpid;
60+ struct stat sbuf;
61+ FILE *lfile, *efile;
62+ int sig, enb, err;
63+
64+ if (argc >= 2) {
65+ printf("Error: Invalid options.\n");
66+ return 1;
67+ }
68+
69+ lockfile = getenv("LOCK_FILE");
70+ if (!lockfile)
71+ lockfile = "/var/lib/oprofile/lock";
72+
73+ /* Add SESSION_DIR support? */
74+
75+ if (geteuid()) {
76+ printf("Error: This program must be run as root.\n");
77+ return 1;
78+ }
79+
80+ if (stat(enable, &sbuf)) {
81+ printf("Error: Could not find /dev/oprofile/enable, the"
82+ " kernel module probably isn't loaded.\n");
83+ printf("This binary only works with 2.6 kernels and oprofile"
84+ " must have been initialised with 'opcontrol --start-daemon'.\n");
85+ return 1;
86+ }
87+
88+ if (stat(lockfile, &sbuf)) {
89+ printf("Error: Could not find lockfile %s.\n", lockfile);
90+ printf("The oprofile daemon must be running (oprofile must"
91+ " have been initialised with 'opcontrol --start-daemon').\n");
92+ return 1;
93+ }
94+
95+ lfile = fopen(lockfile, "r");
96+ if (!lfile) {
97+ printf("Error opening lockfile %s.\n", lockfile);
98+ return 1;
99+ }
100+
101+ err = fscanf(lfile, "%lud", (unsigned long *) &dpid);
102+ if (err != 1) {
103+ printf("Error reading pid from lockfile %s.\n", lockfile);
104+ return 1;
105+ }
106+ fclose(lfile);
107+
108+ efile = fopen(enable, "r");
109+ if (!efile) {
110+ printf("Error opening %s.\n", enable);
111+ return 1;
112+ }
113+
114+ if (strstr(argv[0], "opstart")) {
115+ printf("Starting Profiler\n");
116+ sig = SIGUSR1;
117+ enb = 1;
118+ } else if (strstr(argv[0], "opstop")) {
119+ printf("Stopping Oprofile.\n");
120+ printf("You need to run 'opcontrol --dump' when the session"
121+ " is finished.\n");
122+ sig = SIGUSR2;
123+ enb = 0;
124+ } else {
125+ printf("Error: Please call as 'opstart' or 'opstop'\n");
126+ return 1;
127+ }
128+
129+ err = kill(dpid, 0);
130+ if (err) {
131+ printf("Error sending signal to oprofiled. Stale lockfile"
132+ " (%s) ?\n", lockfile);
133+ return 1;
134+ }
135+
136+ fprintf(efile, "%d\n", enb);
137+ err = kill(dpid, sig);
138+ if (err) {
139+ printf("Error sending signal to oprofiled. Stale lockfile"
140+ " (%s) ?\n", lockfile);
141+ return 1;
142+ }
143+
144+ return 0;
145+}
146+
147Index: oprofile/configure.ac
148===================================================================
149--- oprofile.orig/configure.ac 2008-07-02 15:13:58.000000000 +0100
150+++ oprofile/configure.ac 2008-07-02 15:17:37.000000000 +0100
151@@ -16,6 +16,7 @@
152 AM_CONFIG_HEADER(config.h)
153
154 AC_PROG_RANLIB
155+AC_PROG_LN_S
156 AC_PROG_LIBTOOL
157
158 dnl for the man page
159@@ -241,6 +242,8 @@
160 doc/xsl/catalog-1.xml \
161 doc/oprofile.1 \
162 doc/opcontrol.1 \
163+ doc/opstart.1 \
164+ doc/opstop.1 \
165 doc/ophelp.1 \
166 doc/opreport.1 \
167 doc/opannotate.1 \
168Index: oprofile/doc/Makefile.am
169===================================================================
170--- oprofile.orig/doc/Makefile.am 2008-07-02 15:13:59.000000000 +0100
171+++ oprofile/doc/Makefile.am 2008-07-02 15:14:07.000000000 +0100
172@@ -11,6 +11,8 @@
173 man_MANS = \
174 oprofile.1 \
175 opcontrol.1 \
176+ opstart.1 \
177+ opstop.1 \
178 opreport.1 \
179 opannotate.1 \
180 opgprof.1 \
181Index: oprofile/doc/opstart.1.in
182===================================================================
183--- /dev/null 1970-01-01 00:00:00.000000000 +0000
184+++ oprofile/doc/opstart.1.in 2008-07-02 15:14:07.000000000 +0100
185@@ -0,0 +1,27 @@
186+.TH OPSTART 1 "@DATE@" "oprofile @VERSION@"
187+.UC 4
188+.SH NAME
189+opstart \- start OProfile profiling
190+.SH SYNOPSIS
191+.br
192+.B opstart
193+.SH DESCRIPTION
194+.B opstart
195+is a simple optimised command to start profiling with 2.6 Linux kernels.
196+OProfile should have already been initialised by calling "opcontrol --start-daemon".
197+
198+.SH ENVIRONMENT
199+No special environment variables are recognised by opstart.
200+
201+.SH FILES
202+.TP
203+.I /var/lib/oprofile/samples/
204+The location of the generated sample files.
205+
206+.SH VERSION
207+.TP
208+This man page is current for @PACKAGE@-@VERSION@.
209+
210+.SH SEE ALSO
211+.BR @OP_DOCDIR@,
212+.BR oprofile(1)
213Index: oprofile/doc/opstop.1.in
214===================================================================
215--- /dev/null 1970-01-01 00:00:00.000000000 +0000
216+++ oprofile/doc/opstop.1.in 2008-07-02 15:14:07.000000000 +0100
217@@ -0,0 +1,28 @@
218+.TH OPSTOP 1 "@DATE@" "oprofile @VERSION@"
219+.UC 4
220+.SH NAME
221+opstop \- stop OProfile profiling
222+.SH SYNOPSIS
223+.br
224+.B opstop
225+.SH DESCRIPTION
226+.B opstop
227+is a simple optimsed command to stop profiling with 2.6 Linux kernels.
228+You need to run "opcontrol --dump" before being able to view a profile
229+with opreport.
230+
231+.SH ENVIRONMENT
232+No special environment variables are recognised by opstop.
233+
234+.SH FILES
235+.TP
236+.I /var/lib/oprofile/samples/
237+The location of the generated sample files.
238+
239+.SH VERSION
240+.TP
241+This man page is current for @PACKAGE@-@VERSION@.
242+
243+.SH SEE ALSO
244+.BR @OP_DOCDIR@,
245+.BR oprofile(1)
diff --git a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
new file mode 100644
index 0000000000..e8329cd79c
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
@@ -0,0 +1,22 @@
1require oprofile.inc
2
3PR = "${INC_PR}.3"
4
5DEPENDS += "virtual/kernel"
6DEPENDS_append_powerpc64 = " libpfm4"
7
8SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
9 file://0001-Add-rmb-definition-for-AArch64-architecture.patch \
10 file://0001-OProfile-doesn-t-build-for-32-bit-ppc-the-operf_util.patch \
11 file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \
12 file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \
13 file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch \
14 file://0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch \
15 file://0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch \
16 file://0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch"
17
18SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8"
19SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc"
20
21S = "${WORKDIR}/oprofile-${PV}"
22
diff --git a/meta/recipes-kernel/oprofile/oprofile_git.bb b/meta/recipes-kernel/oprofile/oprofile_git.bb
new file mode 100644
index 0000000000..ca562db121
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile_git.bb
@@ -0,0 +1,11 @@
1require oprofile.inc
2
3SRCREV = "88f43190d412d28ebf5c75a76ba20343d0fe4c41"
4PV = "0.9.7+git${SRCPV}"
5PR = "${INC_PR}.0"
6
7SRC_URI += "git://oprofile.git.sourceforge.net/gitroot/${BPN}/${BPN}"
8
9S = "${WORKDIR}/git"
10
11DEFAULT_PREFERENCE = "-1"
diff --git a/meta/recipes-kernel/oprofile/oprofileui-server/init b/meta/recipes-kernel/oprofile/oprofileui-server/init
new file mode 100755
index 0000000000..2544ea4ac0
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofileui-server/init
@@ -0,0 +1,37 @@
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: oprofile-server
4# Required-Start: $network
5# Required-Stop: $network
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: OProfileUI server
9# Description:
10### END INIT INFO
11
12. /etc/init.d/functions
13
14case "$1" in
15 start)
16 echo "Starting OProfileUI server"
17 . /etc/profile
18 /usr/bin/oprofile-server &
19 ;;
20
21 stop)
22 echo "Stopping OProfileUI server"
23 killproc oprofile-server
24 ;;
25
26 restart)
27 $0 stop
28 sleep 1
29 $0 start
30 ;;
31
32 *)
33 echo "usage: $0 { start | stop | restart }"
34 ;;
35esac
36
37exit 0
diff --git a/meta/recipes-kernel/oprofile/oprofileui-server/oprofileui-server.service b/meta/recipes-kernel/oprofile/oprofileui-server/oprofileui-server.service
new file mode 100644
index 0000000000..1a2cbe62ea
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofileui-server/oprofileui-server.service
@@ -0,0 +1,6 @@
1[Unit]
2Description=OProfileUI Server
3After=network.target
4
5[Service]
6ExecStart=/bin/sh -c ". @SYSCONFDIR@/profile; @BINDIR@/oprofile-server"
diff --git a/meta/recipes-kernel/oprofile/oprofileui-server_git.bb b/meta/recipes-kernel/oprofile/oprofileui-server_git.bb
new file mode 100644
index 0000000000..dbb559965a
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofileui-server_git.bb
@@ -0,0 +1,32 @@
1require oprofileui.inc
2
3SRCREV = "f168b8bfdc63660033de1739c6ddad1abd97c379"
4PV = "0.0+git${SRCPV}"
5
6S = "${WORKDIR}/git"
7
8SRC_URI = "git://git.yoctoproject.org/oprofileui \
9 file://init \
10 file://oprofileui-server.service "
11
12EXTRA_OECONF += "--disable-client --enable-server"
13
14RDEPENDS_${PN} = "oprofile"
15
16do_install_append() {
17 install -d ${D}${sysconfdir}/init.d
18 install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/oprofileui-server
19
20 install -d ${D}${systemd_unitdir}/system
21 install -m 0644 ${WORKDIR}/oprofileui-server.service ${D}${systemd_unitdir}/system/
22 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
23 -e 's,@BINDIR@,${bindir},g' ${D}${systemd_unitdir}/system/oprofileui-server.service
24}
25
26inherit update-rc.d systemd
27
28INITSCRIPT_NAME = "oprofileui-server"
29INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ."
30
31SYSTEMD_SERVICE_${PN} = "oprofileui-server.service"
32SYSTEMD_AUTO_ENABLE = "disable"
diff --git a/meta/recipes-kernel/oprofile/oprofileui.inc b/meta/recipes-kernel/oprofile/oprofileui.inc
new file mode 100644
index 0000000000..6d59e47213
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofileui.inc
@@ -0,0 +1,16 @@
1SUMMARY = "User Interface for the System-Wide Profiler"
2DESCRIPTION = "User interface for the OProfile tool"
3HOMEPAGE = "http://labs.o-hand.com/oprofileui/"
4BUGTRACKER = "http://bugzilla.yoctoproject.org/"
5
6SECTION = "x11"
7
8LICENSE = "GPLv2"
9LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
10
11DEPENDS = "glib-2.0 avahi"
12
13inherit autotools pkgconfig
14
15EXTRA_OECONF = "--with-avahi"
16
diff --git a/meta/recipes-kernel/oprofile/oprofileui_git.bb b/meta/recipes-kernel/oprofile/oprofileui_git.bb
new file mode 100644
index 0000000000..316c61a696
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofileui_git.bb
@@ -0,0 +1,17 @@
1require oprofileui.inc
2
3DEPENDS += "gtk+ libglade libxml2 avahi-ui gconf"
4
5SRCREV = "f168b8bfdc63660033de1739c6ddad1abd97c379"
6PV = "0.0+git${SRCPV}"
7
8S = "${WORKDIR}/git"
9
10SRC_URI = "git://git.yoctoproject.org/oprofileui"
11
12EXTRA_OECONF += "--enable-client --disable-server"
13
14PACKAGES =+ "oprofileui-viewer"
15
16FILES_oprofileui-viewer = "${bindir}/oparchconv ${bindir}/oprofile-viewer ${datadir}/applications/ ${datadir}/oprofileui/ ${datadir}/icons"
17RDEPENDS_oprofileui-viewer = "oprofile"