summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch206
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch130
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch35
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch34
-rw-r--r--meta/recipes-kernel/oprofile/oprofile_0.9.8.bb7
5 files changed, 374 insertions, 38 deletions
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..5eb8b8ff4f
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch
@@ -0,0 +1,206 @@
1From 36028035555297695f52e856f21920012fd64f79 Mon Sep 17 00:00:00 2001
2From: Maynard Johnson <maynardj@us.ibm.com>
3Date: Fri, 11 Jan 2013 13:29:57 -0600
4Subject: [PATCH] Allow ppc64 events to be specified with or without _GRP<n>
5 suffix
6
7All events for IBM PowerPC server processors (except CYCLES) have
8a _GRP<n> suffix. This is because the legacy opcontrol profiler
9can only profile events in the same group (i.e., having the same
10_GRP<n> suffix). But operf has no such restriction because it
11can multiplex events; thus, so we should allow the user to pass
12event names without the _GRP<n> suffix.
13
14Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
15---
16 doc/operf.1.in | 6 +++
17 doc/oprofile.xml | 12 +++++-
18 pe_profiling/operf.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++
19 utils/ophelp.c | 4 ++
20 4 files changed, 127 insertions(+), 2 deletions(-)
21
22diff --git a/doc/operf.1.in b/doc/operf.1.in
23index b109324..03027ca 100644
24--- a/doc/operf.1.in
25+++ b/doc/operf.1.in
26@@ -110,6 +110,12 @@ be specified using the symbolic name. If no unit mask is specified, 0x0 will be
27 used as the default.
28 .P
29 .RS
30+On IBM PowerPC systems, events may be specified with or without the
31+.I _GRP<n>
32+suffix. If no group number suffix is given, one will be automatically
33+assigned; thus, OProfile post-processing tools will always show real event
34+names that include the group number suffix.
35+.P
36 When no event specification is given, the default event for the running
37 processor type will be used for profiling.
38 Use
39diff --git a/doc/oprofile.xml b/doc/oprofile.xml
40index 0ae2b0b..0f74726 100644
41--- a/doc/oprofile.xml
42+++ b/doc/oprofile.xml
43@@ -1106,10 +1106,18 @@ shown by the output of <command>ophelp</command>. Unit masks with "extra:" para
44 specified using the symbolic name.
45 </para>
46 <note><para>
47-When using legacy mode <command>opcontrol</command> on PowerPC platforms, all events specified must be in the same group;
48+When using legacy mode <command>opcontrol</command> on IBM PowerPC platforms, all events specified must be in the same group;
49 i.e., the group number appended to the event name (e.g. <constant>&lt;<emphasis>some-event-name</emphasis>&gt;_GRP9
50 </constant>) must be the same.
51-</para></note>
52+</para>
53+<para>
54+When profiling with <command>operf</command> on IBM PowerPC platforms, the above restriction
55+regarding the same group number does not apply, and events may be
56+specified with or without the group number suffix. If no group number suffix is given, one will be automatically
57+assigned; thus, OProfile post-processing tools will always show real event
58+names that include the group number suffix.
59+</para>
60+</note>
61 <para>
62 If OProfile is using timer-interrupt mode, there is no event configuration possible.
63 </para>
64diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
65index 4416b29..a776e71 100644
66--- a/pe_profiling/operf.cpp
67+++ b/pe_profiling/operf.cpp
68@@ -1146,6 +1146,108 @@ static void _get_event_code(operf_event_t * event)
69 event->evt_code = config;
70 }
71
72+#if (defined(__powerpc__) || defined(__powerpc64__))
73+/* All ppc64 events (except CYCLES) have a _GRP<n> suffix. This is
74+ * because the legacy opcontrol profiler can only profile events in
75+ * the same group (i.e., having the same _GRP<n> suffix). But operf
76+ * can multiplex events, so we should allow the user to pass event
77+ * names without the _GRP<n> suffix.
78+ *
79+ * If event name is not CYCLES or does not have a _GRP<n> suffix,
80+ * we'll call ophelp and scan the list of events, searching for one
81+ * that matches up to the _GRP<n> suffix. If we don't find a match,
82+ * then we'll exit with the expected error message for invalid event name.
83+ */
84+static string _handle_powerpc_event_spec(string event_spec)
85+{
86+ FILE * fp;
87+ char line[MAX_INPUT];
88+ size_t grp_pos;
89+ string evt, retval, err_msg;
90+ size_t evt_name_len;
91+ bool first_non_cyc_evt_found = false;
92+ bool event_found = false;
93+ char event_name[OP_MAX_EVT_NAME_LEN], event_spec_str[OP_MAX_EVT_NAME_LEN + 20], * count_str;
94+ string cmd = OP_BINDIR;
95+ cmd += "/ophelp";
96+
97+ strncpy(event_spec_str, event_spec.c_str(), event_spec.length() + 1);
98+
99+ strncpy(event_name, strtok(event_spec_str, ":"), OP_MAX_EVT_NAME_LEN);
100+ count_str = strtok(NULL, ":");
101+ if (!count_str) {
102+ err_msg = "Invalid count for event ";
103+ goto out;
104+ }
105+
106+ if (!strcmp("CYCLES", event_name)) {
107+ event_found = true;
108+ goto out;
109+ }
110+
111+ evt = event_name;
112+ // Need to make sure the event name truly has a _GRP<n> suffix.
113+ grp_pos = evt.rfind("_GRP");
114+ if ((grp_pos != string::npos) && ((evt = evt.substr(grp_pos, string::npos))).length() > 4) {
115+ unsigned long value;
116+ char * end;
117+ value = strtoul(evt.substr(4, string::npos).c_str(), &end, 0);
118+ if (end && (*end == '\0')) {
119+ // Valid group number found after _GRP, so we can skip to the end.
120+ event_found = true;
121+ goto out;
122+ }
123+ }
124+
125+ // If we get here, it implies the user passed a non-CYCLES event without a GRP suffix.
126+ // Lets try to find a valid suffix for it.
127+ fp = popen(cmd.c_str(), "r");
128+ if (fp == NULL) {
129+ cerr << "Unable to execute ophelp to get info for event "
130+ << event_spec << endl;
131+ exit(EXIT_FAILURE);
132+ }
133+ evt_name_len = strlen(event_name);
134+ err_msg = "Cannot find event ";
135+ while (fgets(line, MAX_INPUT, fp)) {
136+ if (!first_non_cyc_evt_found) {
137+ if (!strncmp(line, "PM_", 3))
138+ first_non_cyc_evt_found = true;
139+ else
140+ continue;
141+ }
142+ if (line[0] == ' ' || line[0] == '\t')
143+ continue;
144+ if (!strncmp(line, event_name, evt_name_len)) {
145+ // Found a potential match. Check if it's a perfect match.
146+ string save_event_name = event_name;
147+ size_t full_evt_len = index(line, ':') - line;
148+ memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
149+ strncpy(event_name, line, full_evt_len);
150+ string candidate = event_name;
151+ if (candidate.rfind("_GRP") == evt_name_len) {
152+ event_found = true;
153+ break;
154+ } else {
155+ memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
156+ strncpy(event_name, save_event_name.c_str(), evt_name_len);
157+ }
158+ }
159+ }
160+ pclose(fp);
161+
162+out:
163+ if (!event_found) {
164+ cerr << err_msg << event_name << endl;
165+ cerr << "Error retrieving info for event "
166+ << event_spec << endl;
167+ exit(EXIT_FAILURE);
168+ }
169+ retval = event_name;
170+ return retval + ":" + count_str;
171+}
172+#endif
173+
174 static void _process_events_list(void)
175 {
176 string cmd = OP_BINDIR;
177@@ -1154,6 +1256,11 @@ static void _process_events_list(void)
178 FILE * fp;
179 string full_cmd = cmd;
180 string event_spec = operf_options::evts[i];
181+
182+#if (defined(__powerpc__) || defined(__powerpc64__))
183+ event_spec = _handle_powerpc_event_spec(event_spec);
184+#endif
185+
186 if (operf_options::callgraph) {
187 full_cmd += " --callgraph=1 ";
188 }
189diff --git a/utils/ophelp.c b/utils/ophelp.c
190index 53a5dde..63895c8 100644
191--- a/utils/ophelp.c
192+++ b/utils/ophelp.c
193@@ -652,6 +652,10 @@ int main(int argc, char const * argv[])
194 case CPU_PPC64_POWER7:
195 case CPU_PPC64_IBM_COMPAT_V1:
196 event_doc =
197+ "When using operf, events may be specified without a '_GRP<n>' suffix.\n"
198+ "If _GRP<n> (i.e., group number) is not specified, one will be automatically\n"
199+ "selected for use by the profiler. OProfile post-processing tools will\n"
200+ "always show real event names that include the group number suffix.\n\n"
201 "Documentation for IBM POWER7 can be obtained at:\n"
202 "http://www.power.org/events/Power7/\n"
203 "No public performance monitoring doc available for older processors.\n";
204--
2051.7.9.7
206
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
new file mode 100644
index 0000000000..ead6e256f1
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
@@ -0,0 +1,130 @@
1From 8e36ad01ceb1257d05773b684dbe9358aecd3f71 Mon Sep 17 00:00:00 2001
2From: Maynard Johnson <maynardj@us.ibm.com>
3Date: Tue, 26 Feb 2013 13:41:27 -0600
4Subject: [PATCH] Fix PPC64-specific libpfm usage so it doesn't break ppc32
5 architecture
6
7The configure check to determine whether we should use libpfm or not
8is intended only for the ppc64 architecture, but was incorrectly
9hitting on the ppc32 architecture, too. Not only that, but it was using
10'uname' which is not a good idea in cross-compile situtations.
11
12Then, aside from that, we had several instances in the source code
13of the following:
14 #if (defined(__powerpc__) || defined(__powerpc64__))
15which incorrectly included ppc32 architecutre also, when it was intended
16for use as PPC64 architecture.
17
18This patch fixes both errors.
19
20Signed-off-by: Maynard Johnson <maynardj@us.ibm.com
21---
22 configure.ac | 5 ++---
23 libperf_events/operf_utils.cpp | 4 ++--
24 libperf_events/operf_utils.h | 6 ++++++
25 pe_profiling/operf.cpp | 10 +++++-----
26 4 files changed, 15 insertions(+), 10 deletions(-)
27
28diff --git a/configure.ac b/configure.ac
29index a9b1ee4..a0da98c 100644
30--- a/configure.ac
31+++ b/configure.ac
32@@ -154,11 +154,10 @@ else
33 fi
34
35 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
36-
37+AC_CANONICAL_HOST
38 if test "$HAVE_PERF_EVENTS" = "1"; then
39 PFM_LIB=
40- arch="`uname -m`"
41- if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
42+ if test "$host_cpu" = "powerpc64"; then
43 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
44 AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
45 AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
46diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
47index da964fd..a17200b 100644
48--- a/libperf_events/operf_utils.cpp
49+++ b/libperf_events/operf_utils.cpp
50@@ -83,7 +83,7 @@ static event_t comm_event;
51 * the following method is to map the operf-record event value to a value that
52 * opreport can understand.
53 */
54-#if (defined(__powerpc__) || defined(__powerpc64__))
55+#if PPC64_ARCH
56 #define NIL_CODE ~0U
57
58 #if HAVE_LIBPFM3
59@@ -716,7 +716,7 @@ static void __handle_sample_event(event_t * event, u64 sample_type)
60 } else if (event->header.misc == PERF_RECORD_MISC_USER) {
61 in_kernel = false;
62 }
63-#if (defined(__powerpc__) || defined(__powerpc64__))
64+#if PPC64_ARCH
65 else if (event->header.misc == PERF_RECORD_MISC_HYPERVISOR) {
66 #define MAX_HYPERVISOR_ADDRESS 0xfffffffULL
67 if (data.ip > MAX_HYPERVISOR_ADDRESS) {
68diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h
69index 2df00b7..ddf05ed 100644
70--- a/libperf_events/operf_utils.h
71+++ b/libperf_events/operf_utils.h
72@@ -45,6 +45,12 @@ extern bool throttled;
73 #define MMAP_WINDOW_SZ (32 * 1024 * 1024ULL)
74 #endif
75
76+/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
77+ * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
78+ * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
79+ */
80+#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
81+
82 extern unsigned int op_nr_counters;
83
84 static inline size_t align_64bit(u64 x)
85diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
86index e7c2eab..e1190c2 100644
87--- a/pe_profiling/operf.cpp
88+++ b/pe_profiling/operf.cpp
89@@ -1177,7 +1177,7 @@ static void _get_event_code(operf_event_t * event)
90 event->evt_code = config;
91 }
92
93-#if (defined(__powerpc__) || defined(__powerpc64__))
94+#if PPC64_ARCH
95 /* All ppc64 events (except CYCLES) have a _GRP<n> suffix. This is
96 * because the legacy opcontrol profiler can only profile events in
97 * the same group (i.e., having the same _GRP<n> suffix). But operf
98@@ -1287,7 +1287,7 @@ static void _process_events_list(void)
99 string full_cmd = cmd;
100 string event_spec = operf_options::evts[i];
101
102-#if (defined(__powerpc__) || defined(__powerpc64__))
103+#if PPC64_ARCH
104 event_spec = _handle_powerpc_event_spec(event_spec);
105 #endif
106
107@@ -1357,9 +1357,9 @@ static void _process_events_list(void)
108 _get_event_code(&event);
109 events.push_back(event);
110 }
111-#if (defined(__powerpc__) || defined(__powerpc64__))
112+#if PPC64_ARCH
113 {
114- /* This section of code is for architectures such as ppc[64] for which
115+ /* This section of code is soley for the ppc64 architecture for which
116 * the oprofile event code needs to be converted to the appropriate event
117 * code to pass to the perf_event_open syscall.
118 */
119@@ -1404,7 +1404,7 @@ static void get_default_event(void)
120 _get_event_code(&dft_evt);
121 events.push_back(dft_evt);
122
123-#if (defined(__powerpc__) || defined(__powerpc64__))
124+#if PPC64_ARCH
125 {
126 /* This section of code is for architectures such as ppc[64] for which
127 * the oprofile event code needs to be converted to the appropriate event
128--
1291.7.9.7
130
diff --git a/meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch b/meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch
deleted file mode 100644
index d4dffb18d0..0000000000
--- a/meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1Upstream-Status: Submitted
2
3From cd8aafe5ca48e8d809188df6e42f20efd5cbefd1 Mon Sep 17 00:00:00 2001
4From: Matthew McClintock <msm@freescale.com>
5Date: Tue, 5 Feb 2013 11:05:00 -0600
6Subject: [PATCH] fix powerpc cross compiling
7
8You can't determine the target for running on by running uname
9on the build machine. Use a better method instead.
10
11Signed-off-by: Matthew McClintock <msm@freescale.com>
12---
13 configure.ac | 4 ++--
14 1 file changed, 2 insertions(+), 2 deletions(-)
15
16diff --git a/configure.ac b/configure.ac
17index a9b1ee4..4b73cdd 100644
18--- a/configure.ac
19+++ b/configure.ac
20@@ -155,10 +155,10 @@ fi
21
22 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
23
24+AC_CANONICAL_HOST
25 if test "$HAVE_PERF_EVENTS" = "1"; then
26 PFM_LIB=
27- arch="`uname -m`"
28- if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
29+ if test "$host_cpu" = "powerpc"; then
30 AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
31 AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
32 AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
33--
341.7.9.7
35
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..5a50b9031e
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch
@@ -0,0 +1,34 @@
1From 735d9eb0322b34b3d26302a1dac173100d718d35 Mon Sep 17 00:00:00 2001
2From: Maynard Johnson <maynardj@us.ibm.com>
3Date: Thu, 10 Jan 2013 14:24:26 -0600
4Subject: [PATCH] ophelp lists events: Fix doc URL for ppc64 arch
5
6When ophelp is used to list available events, it displays
7some help text before the event list to direct the user
8where to find more info. For the ppc64 architecture, a
9stale URL was listed. This patch fixes that URL.
10
11Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
12---
13 utils/ophelp.c | 5 +++--
14 1 file changed, 3 insertions(+), 2 deletions(-)
15
16diff --git a/utils/ophelp.c b/utils/ophelp.c
17index f48697b..827f2d0 100644
18--- a/utils/ophelp.c
19+++ b/utils/ophelp.c
20@@ -652,8 +652,9 @@ int main(int argc, char const * argv[])
21 case CPU_PPC64_POWER7:
22 case CPU_PPC64_IBM_COMPAT_V1:
23 event_doc =
24- "Obtain PowerPC64 processor documentation at:\n"
25- "http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC\n";
26+ "Documentation for IBM POWER7 can be obtained at:\n"
27+ "http://www.power.org/events/Power7/\n"
28+ "No public performance monitoring doc available for older processors.\n";
29 break;
30
31 case CPU_PPC64_CELL:
32--
331.7.9.7
34
diff --git a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
index 79363a6017..e8329cd79c 100644
--- a/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
+++ b/meta/recipes-kernel/oprofile/oprofile_0.9.8.bb
@@ -1,9 +1,8 @@
1require oprofile.inc 1require oprofile.inc
2 2
3PR = "${INC_PR}.2" 3PR = "${INC_PR}.3"
4 4
5DEPENDS += "virtual/kernel" 5DEPENDS += "virtual/kernel"
6DEPENDS_append_powerpc = " libpfm4"
7DEPENDS_append_powerpc64 = " libpfm4" 6DEPENDS_append_powerpc64 = " libpfm4"
8 7
9SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ 8SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
@@ -12,7 +11,9 @@ SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
12 file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \ 11 file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \
13 file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \ 12 file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \
14 file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch \ 13 file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch \
15 file://0001-fix-powerpc-cross-compiling.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"
16 17
17SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8" 18SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8"
18SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc" 19SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc"