Skip to contentSkip to conversation

kernel-arch.bbclass: don't pass extra args to KERNEL_{CC, LD, AR}

PATCH New Matthew McClintock 1 participant 4 messages Feb 26, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 kernel-arch.bbclass: don't pass extra args to KERNEL_{CC, LD, AR}

Commit a3ca06c3b45c791dd38dbf154ad0fc62b4063475 added extra args to KERNEL_CC, these revert that bit while maintaining machine additions in TARGET_??_KERNEL_ARCH

Producing incorrect instructions and generating the following errors:

CC arch/powerpc/kernel/init_task.o

| {standard input}: Assembler messages:
| {standard input}:384: Error: junk at end of line: `1'
| {standard input}:949: Error: junk at end of line: `1'
| {standard input}:1428: Error: junk at end of line: `1'
| {standard input}:1526: Error: junk at end of line: `1'
| {standard input}:1626: Error: junk at end of line: `1'
| {standard input}:1685: Error: junk at end of line: `1'
| {standard input}:1973: Error: junk at end of line: `1'
| {standard input}:2001: Error: junk at end of line: `1'
| {standard input}:2100: Error: junk at end of line: `1'
| {standard input}:2168: Error: junk at end of line: `1'
| {standard input}:2520: Error: junk at end of line: `1'
|   CC      arch/powerpc/lib/locks.o
---
 meta/classes/kernel-arch.bbclass |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta/classes/kernel-arch.bbclass +3 -3
index a51e82b..b3b71ba 100644
@@ -52,7 +52,7 @@ HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
 TARGET_AR_KERNEL_ARCH ?= ""
 HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
 
-KERNEL_CC = "${CC} ${HOST_CC_KERNEL_ARCH}"
-KERNEL_LD = "${LD} ${HOST_LD_KERNEL_ARCH}"
-KERNEL_AR = "${AR} ${HOST_AR_KERNEL_ARCH}"
+KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH}"
+KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld ${HOST_LD_KERNEL_ARCH}"
+KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
 
Signature · 1 line
1.7.9.7
#1 lore raw

PATCH 2/4 gcc-common.inc: handle case where tune is not defined

---
 meta/recipes-devtools/gcc/gcc-common.inc |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-common.inc +1 -1
index ad96989..6b61800 100644
@@ -38,7 +38,7 @@ def get_gcc_multiarch_setting(bb, d):
 def get_tune_parameters(tune, d):
     availtunes = d.getVar('AVAILTUNES', True)
     if tune not in availtunes.split():
-        bb.error('The tune: %s is not one of the available tunes: %s', tune, availtunes)
+        bb.error('The tune: %s is not one of the available tunes: %s', tune or None, availtunes)
 
     localdata = bb.data.createCopy(d)
     override = ':tune-' + tune
Signature · 1 line
1.7.9.7
#2 lore raw

PATCH 3/4 libpfm4_4.3.0.bb: use compatible host to limit arches

In reply to Matthew McClintock

This is only test with powerpc64 currently, even though it should work on other arches such as x86 and sparc. When thos are testing and working this COMPATIBLE_HOST should be updated

---
 meta/recipes-kernel/libpfm/libpfm4_4.3.0.bb |    3 +++
 1 file changed, 3 insertions(+)
meta/recipes-kernel/libpfm/libpfm4_4.3.0.bb +3 -0
index 460029f..98852f6 100644
@@ -10,6 +10,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0de488f3bd4424e308e2e399cb99c788"
 
 SECTION = "devel"
 
+PR = "r1"
+COMPATIBLE_HOST = "powerpc64"
+
 SRC_URI = "http://downloads.sourceforge.net/project/perfmon2/libpfm4/libpfm-4.3.0.tar.gz"
 
 SRC_URI[md5sum] = "0ab272dbdbb759b852ba8bd06db030ef"
Signature · 1 line
1.7.9.7
#3 lore raw

PATCH 4/4 oprofile: update patch for powerpc64

In reply to Matthew McClintock

This is a more appropriate follow up patch from upstream. Also, only powerpc64 requires libpfm4 currently for this specific version of oprofile (x86, sparc can make use of libpfm but don't make use of it here)

Additionally, this patch from upstream requires some more patches to be pulled into oprofile

---
 ...-events-to-be-specified-with-or-without-_.patch |  206 ++++++++++++++++++++
 ...pecific-libpfm-usage-so-it-doesn-t-break-.patch |  130 ++++++++++++
 .../0001-fix-powerpc-cross-compiling.patch         |   35 ----
 ...p-lists-events-Fix-doc-URL-for-ppc64-arch.patch |   34 ++++
 meta/recipes-kernel/oprofile/oprofile_0.9.8.bb     |    7 +-
 5 files changed, 374 insertions(+), 38 deletions(-)
 create mode 100644 meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch
 create mode 100644 meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch
 delete mode 100644 meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch
 create mode 100644 meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch
meta/recipes-kernel/oprofile/oprofile/0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch new file +206 -0
new file mode 100644
index 0000000..5eb8b8f
@@ -0,0 +1,206 @@
+From 36028035555297695f52e856f21920012fd64f79 Mon Sep 17 00:00:00 2001
+From: Maynard Johnson <[email protected]>
+Date: Fri, 11 Jan 2013 13:29:57 -0600
+Subject: [PATCH] Allow ppc64 events to be specified with or without _GRP<n>
+ suffix
+
+All events for IBM PowerPC server processors (except CYCLES) have
+a _GRP<n> suffix.  This is because the legacy opcontrol profiler
+can only profile events in the same group (i.e., having the same
+_GRP<n> suffix).  But operf has no such restriction because it
+can multiplex events; thus, so we should allow the user to pass
+event names without the _GRP<n> suffix.
+
+Signed-off-by: Maynard Johnson <[email protected]>
+---
+ doc/operf.1.in         |    6 +++
+ doc/oprofile.xml       |   12 +++++-
+ pe_profiling/operf.cpp |  107 ++++++++++++++++++++++++++++++++++++++++++++++++
+ utils/ophelp.c         |    4 ++
+ 4 files changed, 127 insertions(+), 2 deletions(-)
+
+diff --git a/doc/operf.1.in b/doc/operf.1.in
+index b109324..03027ca 100644
+--- a/doc/operf.1.in
++++ b/doc/operf.1.in
+@@ -110,6 +110,12 @@ be specified using the symbolic name.  If no unit mask is specified, 0x0 will be
+ used as the default.
+ .P
+ .RS
++On IBM PowerPC systems, events may be specified with or without the
++.I _GRP<n>
++suffix.  If no group number suffix is given, one will be automatically
++assigned; thus, OProfile post-processing tools will always show real event
++names that include the group number suffix.
++.P
+ When no event specification is given, the default event for the running
+ processor type will be used for profiling.
+ Use
+diff --git a/doc/oprofile.xml b/doc/oprofile.xml
+index 0ae2b0b..0f74726 100644
+--- a/doc/oprofile.xml
++++ b/doc/oprofile.xml
+@@ -1106,10 +1106,18 @@ shown by the output of <command>ophelp</command>.  Unit masks with "extra:" para
+ specified using the symbolic name.
+ </para>
+ <note><para>
+-When using legacy mode <command>opcontrol</command> on PowerPC platforms, all events specified must be in the same group;
++When using legacy mode <command>opcontrol</command> on IBM PowerPC platforms, all events specified must be in the same group;
+ i.e., the group number appended to the event name (e.g. <constant>&lt;<emphasis>some-event-name</emphasis>&gt;_GRP9
+ </constant>) must be the same.
+-</para></note>
++</para>
++<para>
++When profiling with <command>operf</command> on IBM PowerPC platforms, the above restriction
++regarding the same group number does not apply, and events may be
++specified with or without the group number suffix.   If no group number suffix is given, one will be automatically
++assigned; thus, OProfile post-processing tools will always show real event
++names that include the group number suffix.
++</para>
++</note>
+ <para>
+ If OProfile is using timer-interrupt mode, there is no event configuration possible.
+ </para>
+diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
+index 4416b29..a776e71 100644
+--- a/pe_profiling/operf.cpp
++++ b/pe_profiling/operf.cpp
+@@ -1146,6 +1146,108 @@ static void _get_event_code(operf_event_t * event)
+ 	event->evt_code = config;
+ }
+ 
++#if (defined(__powerpc__) || defined(__powerpc64__))
++/* All ppc64 events (except CYCLES) have a _GRP<n> suffix.  This is
++ * because the legacy opcontrol profiler can only profile events in
++ * the same group (i.e., having the same _GRP<n> suffix).  But operf
++ * can multiplex events, so we should allow the user to pass event
++ * names without the _GRP<n> suffix.
++ *
++ * If event name is not CYCLES or does not have a _GRP<n> suffix,
++ * we'll call ophelp and scan the list of events, searching for one
++ * that matches up to the _GRP<n> suffix.  If we don't find a match,
++ * then we'll exit with the expected error message for invalid event name.
++ */
++static string _handle_powerpc_event_spec(string event_spec)
++{
++	FILE * fp;
++	char line[MAX_INPUT];
++	size_t grp_pos;
++	string evt, retval, err_msg;
++	size_t evt_name_len;
++	bool first_non_cyc_evt_found = false;
++	bool event_found = false;
++	char event_name[OP_MAX_EVT_NAME_LEN], event_spec_str[OP_MAX_EVT_NAME_LEN + 20], * count_str;
++	string cmd = OP_BINDIR;
++	cmd += "/ophelp";
++
++	strncpy(event_spec_str, event_spec.c_str(), event_spec.length() + 1);
++
++	strncpy(event_name, strtok(event_spec_str, ":"), OP_MAX_EVT_NAME_LEN);
++	count_str = strtok(NULL, ":");
++	if (!count_str) {
++		err_msg = "Invalid count for event ";
++		goto out;
++	}
++
++	if (!strcmp("CYCLES", event_name)) {
++		event_found = true;
++		goto out;
++	}
++
++	evt = event_name;
++	// Need to make sure the event name truly has a _GRP<n> suffix.
++	grp_pos = evt.rfind("_GRP");
++	if ((grp_pos != string::npos) && ((evt = evt.substr(grp_pos, string::npos))).length() > 4) {
++		unsigned long value;
++		char * end;
++		value = strtoul(evt.substr(4, string::npos).c_str(), &end, 0);
++		if (end && (*end == '\0')) {
++		// Valid group number found after _GRP, so we can skip to the end.
++			event_found = true;
++			goto out;
++		}
++	}
++
++	// If we get here, it implies the user passed a non-CYCLES event without a GRP suffix.
++	// Lets try to find a valid suffix for it.
++	fp = popen(cmd.c_str(), "r");
++	if (fp == NULL) {
++		cerr << "Unable to execute ophelp to get info for event "
++		     << event_spec << endl;
++		exit(EXIT_FAILURE);
++	}
++	evt_name_len = strlen(event_name);
++	err_msg = "Cannot find event ";
++	while (fgets(line, MAX_INPUT, fp)) {
++		if (!first_non_cyc_evt_found) {
++			if (!strncmp(line, "PM_", 3))
++				first_non_cyc_evt_found = true;
++			else
++				continue;
++		}
++		if (line[0] == ' ' || line[0] == '\t')
++			continue;
++		if (!strncmp(line, event_name, evt_name_len)) {
++			// Found a potential match.  Check if it's a perfect match.
++			string save_event_name = event_name;
++			size_t full_evt_len = index(line, ':') - line;
++			memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
++			strncpy(event_name, line, full_evt_len);
++			string candidate = event_name;
++			if (candidate.rfind("_GRP") == evt_name_len) {
++				event_found = true;
++				break;
++			} else {
++				memset(event_name, '\0', OP_MAX_EVT_NAME_LEN);
++				strncpy(event_name, save_event_name.c_str(), evt_name_len);
++			}
++		}
++	}
++	pclose(fp);
++
++out:
++	if (!event_found) {
++		cerr << err_msg << event_name << endl;
++		cerr << "Error retrieving info for event "
++				<< event_spec << endl;
++		exit(EXIT_FAILURE);
++	}
++	retval = event_name;
++	return retval + ":" + count_str;
++}
++#endif
++
+ static void _process_events_list(void)
+ {
+ 	string cmd = OP_BINDIR;
+@@ -1154,6 +1256,11 @@ static void _process_events_list(void)
+ 		FILE * fp;
+ 		string full_cmd = cmd;
+ 		string event_spec = operf_options::evts[i];
++
++#if (defined(__powerpc__) || defined(__powerpc64__))
++		event_spec = _handle_powerpc_event_spec(event_spec);
++#endif
++
+ 		if (operf_options::callgraph) {
+ 			full_cmd += " --callgraph=1 ";
+ 		}
+diff --git a/utils/ophelp.c b/utils/ophelp.c
+index 53a5dde..63895c8 100644
+--- a/utils/ophelp.c
++++ b/utils/ophelp.c
+@@ -652,6 +652,10 @@ int main(int argc, char const * argv[])
+ 	case CPU_PPC64_POWER7:
+ 	case CPU_PPC64_IBM_COMPAT_V1:
+ 		event_doc =
++			"When using operf, events may be specified without a '_GRP<n>' suffix.\n"
++			"If _GRP<n> (i.e., group number) is not specified, one will be automatically\n"
++			"selected for use by the profiler.  OProfile post-processing tools will\n"
++			"always show real event names that include the group number suffix.\n\n"
+ 			"Documentation for IBM POWER7 can be obtained at:\n"
+ 			"http://www.power.org/events/Power7/\n"
+ 			"No public performance monitoring doc available for older processors.\n";
+-- 
+1.7.9.7
+
meta/recipes-kernel/oprofile/oprofile/0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch new file +130 -0

130 lines not on this page · raw message

meta/recipes-kernel/oprofile/oprofile/0001-fix-powerpc-cross-compiling.patch deleted +0 -35
deleted file mode 100644
index d4dffb1..0000000
@@ -1,35 +0,0 @@
-Upstream-Status: Submitted
-
-From cd8aafe5ca48e8d809188df6e42f20efd5cbefd1 Mon Sep 17 00:00:00 2001
-From: Matthew McClintock <[email protected]>
-Date: Tue, 5 Feb 2013 11:05:00 -0600
-Subject: [PATCH] fix powerpc cross compiling
-
-You can't determine the target for running on by running uname
-on the build machine. Use a better method instead.
-
-Signed-off-by: Matthew McClintock <[email protected]>
----
- configure.ac |    4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index a9b1ee4..4b73cdd 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -155,10 +155,10 @@ fi
- 
- AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])
- 
-+AC_CANONICAL_HOST
- if test "$HAVE_PERF_EVENTS" = "1"; then
- 	PFM_LIB=
--	arch="`uname -m`"
--	if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
-+	if test "$host_cpu" = "powerpc"; then
- 		AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
- 		AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1', [
- 			AC_CHECK_LIB(pfm, pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1',
--- 
-1.7.9.7
-
meta/recipes-kernel/oprofile/oprofile/0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch new file +34 -0
new file mode 100644
index 0000000..5a50b90
@@ -0,0 +1,34 @@
+From 735d9eb0322b34b3d26302a1dac173100d718d35 Mon Sep 17 00:00:00 2001
+From: Maynard Johnson <[email protected]>
+Date: Thu, 10 Jan 2013 14:24:26 -0600
+Subject: [PATCH] ophelp lists events: Fix doc URL for ppc64 arch
+
+When ophelp is used to list available events, it displays
+some help text before the event list to direct the user
+where to find more info.  For the ppc64 architecture, a
+stale URL was listed.  This patch fixes that URL.
+
+Signed-off-by: Maynard Johnson <[email protected]>
+---
+ utils/ophelp.c |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/utils/ophelp.c b/utils/ophelp.c
+index f48697b..827f2d0 100644
+--- a/utils/ophelp.c
++++ b/utils/ophelp.c
+@@ -652,8 +652,9 @@ int main(int argc, char const * argv[])
+ 	case CPU_PPC64_POWER7:
+ 	case CPU_PPC64_IBM_COMPAT_V1:
+ 		event_doc =
+-			"Obtain PowerPC64 processor documentation at:\n"
+-			"http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC\n";
++			"Documentation for IBM POWER7 can be obtained at:\n"
++			"http://www.power.org/events/Power7/\n"
++			"No public performance monitoring doc available for older processors.\n";
+ 		break;
+ 
+ 	case CPU_PPC64_CELL:
+-- 
+1.7.9.7
+
meta/recipes-kernel/oprofile/oprofile_0.9.8.bb +4 -3
index 79363a6..e8329cd 100644
@@ -1,9 +1,8 @@
 require oprofile.inc
 
-PR = "${INC_PR}.2"
+PR = "${INC_PR}.3"
 
 DEPENDS += "virtual/kernel"
-DEPENDS_append_powerpc = " libpfm4"
 DEPENDS_append_powerpc64 = " libpfm4"
 
 SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
@@ -12,7 +11,9 @@ SRC_URI += "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
             file://0001-Handle-early-perf_events-kernel-without-PERF_RECORD_.patch \
             file://0001-Fix-up-configure-to-handle-architectures-that-do-not.patch \
             file://0001-Change-configure-to-look-for-libpfm4-function-first-.patch \
-            file://0001-fix-powerpc-cross-compiling.patch "
+            file://0001-ophelp-lists-events-Fix-doc-URL-for-ppc64-arch.patch \
+            file://0001-Allow-ppc64-events-to-be-specified-with-or-without-_.patch \
+            file://0001-Fix-PPC64-specific-libpfm-usage-so-it-doesn-t-break-.patch"
 
 SRC_URI[md5sum] = "6d127023af1dd1cf24e15411229f3cc8"
 SRC_URI[sha256sum] = "ab45900fa1a23e5d5badf3c0a55f26c17efe6e184efcf00b371433751fa761bc"
Signature · 1 line
1.7.9.7