[oprofile] -Resolves rhbz1178577 -Support hugepage use

William Eden Cohen wcohen at fedoraproject.org
Fri Jan 23 16:25:27 UTC 2015


commit 4d76ff7e957c64fda03a676d4ddf1449cfc45e46
Author: William Cohen <wcohen at redhat.com>
Date:   Fri Jan 23 11:24:21 2015 -0500

    -Resolves rhbz1178577
    -Support hugepage use

 oprofile-env.patch      |   94 +++++++++++++++++++++++++++++++++++++++++++++++
 oprofile-hugepage.patch |   34 +++++++++++++++++
 oprofile.spec           |   10 ++++-
 3 files changed, 137 insertions(+), 1 deletions(-)
---
diff --git a/oprofile-env.patch b/oprofile-env.patch
new file mode 100644
index 0000000..6ed23c0
--- /dev/null
+++ b/oprofile-env.patch
@@ -0,0 +1,94 @@
+From b869a61861e161c855379c4b5700fd352da01154 Mon Sep 17 00:00:00 2001
+From: William Cohen <wcohen at redhat.com>
+Date: Thu, 8 Jan 2015 16:37:57 -0500
+Subject: [PATCH] Avoid permanently setting POSIXLY_CORRECT environment
+ variable
+
+During testing on Fedora it was discovered that operf was setting the
+enviroment variable POSIXLY_CORRECT and this could potentially be
+observed in the children tasks that operf starts (Red Hat Bugzilla
+1178577). The operf, ocount, and opjitconv commands all ensure that
+POSIXLY_CORRECT environment variable is set when the options are
+processed with getopt_long, but they never unset the variable
+afterwards.  This patch ensures that POSIXLY_CORRECT is as it was
+before it was set.
+
+Signed-off-by: William Cohen <wcohen at redhat.com>
+---
+ opjitconv/opjitconv.c  | 5 +++++
+ pe_counting/ocount.cpp | 5 +++++
+ pe_profiling/operf.cpp | 5 +++++
+ 3 files changed, 15 insertions(+)
+
+diff --git a/opjitconv/opjitconv.c b/opjitconv/opjitconv.c
+index 0a6e738..e28bd29 100644
+--- a/opjitconv/opjitconv.c
++++ b/opjitconv/opjitconv.c
+@@ -819,6 +819,7 @@ static int _process_args(int argc, char * const argv[])
+ {
+ 	int keep_trying = 1;
+ 	int idx_of_non_options = 0;
++	char * prev_env = getenv("POSIXLY_CORRECT");
+ 	setenv("POSIXLY_CORRECT", "1", 0);
+ 	while (keep_trying) {
+ 		int option_idx = 0;
+@@ -853,6 +854,10 @@ static int _process_args(int argc, char * const argv[])
+ 			break;
+ 		}
+ 	}
++
++	if (prev_env == NULL)
++		unsetenv("POSIXLY_CORRECT");
++
+ 	return idx_of_non_options;
+ }
+ 
+diff --git a/pe_counting/ocount.cpp b/pe_counting/ocount.cpp
+index 07dfd0c..f7caede 100644
+--- a/pe_counting/ocount.cpp
++++ b/pe_counting/ocount.cpp
+@@ -579,6 +579,7 @@ static int _process_ocount_and_app_args(int argc, char * const argv[])
+ {
+ 	bool keep_trying = true;
+ 	int idx_of_non_options = 0;
++	char * prev_env = getenv("POSIXLY_CORRECT");
+ 	setenv("POSIXLY_CORRECT", "1", 0);
+ 	while (keep_trying) {
+ 		int option_idx = 0;
+@@ -663,6 +664,10 @@ static int _process_ocount_and_app_args(int argc, char * const argv[])
+ 			__print_usage_and_exit("ocount: unexpected end of arg parsing");
+ 		}
+ 	}
++
++	if (prev_env == NULL)
++		unsetenv("POSIXLY_CORRECT");
++
+ 	return idx_of_non_options;
+ }
+ 
+diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
+index 04a25d9..a186278 100644
+--- a/pe_profiling/operf.cpp
++++ b/pe_profiling/operf.cpp
+@@ -1258,6 +1258,7 @@ static int _process_operf_and_app_args(int argc, char * const argv[])
+ {
+ 	bool keep_trying = true;
+ 	int idx_of_non_options = 0;
++	char * prev_env = getenv("POSIXLY_CORRECT");
+ 	setenv("POSIXLY_CORRECT", "1", 0);
+ 	while (keep_trying) {
+ 		int option_idx = 0;
+@@ -1331,6 +1332,10 @@ static int _process_operf_and_app_args(int argc, char * const argv[])
+ 			__print_usage_and_exit("unexpected end of arg parsing");
+ 		}
+ 	}
++
++	if (prev_env == NULL)
++		unsetenv("POSIXLY_CORRECT");
++
+ 	return idx_of_non_options;
+ }
+ 
+-- 
+2.1.0
+
diff --git a/oprofile-hugepage.patch b/oprofile-hugepage.patch
new file mode 100644
index 0000000..111ba1d
--- /dev/null
+++ b/oprofile-hugepage.patch
@@ -0,0 +1,34 @@
+From 0246c6ba4a08378c46c17617d831d6baf0f44989 Mon Sep 17 00:00:00 2001
+From: William Cohen <wcohen at redhat.com>
+Date: Fri, 9 Jan 2015 16:44:09 -0500
+Subject: [PATCH] Allow operf to track anon_hugepage mmap entries
+
+The perf mmap information for anon_huge pages has a different filename
+("/anon_hugepage") than the mmap information for regions composed of
+normal sized pages ("//anon").  This results in opreport not being
+able to map samples collected by operf to Java methods when the Java
+VM uses statically allocated huge pages (rhbz1180512 and rhbz1180513).
+
+Signed-off-by: William Cohen <wcohen at redhat.com>
+---
+ libperf_events/operf_utils.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/libperf_events/operf_utils.cpp b/libperf_events/operf_utils.cpp
+index a87524b..90a0765 100644
+--- a/libperf_events/operf_utils.cpp
++++ b/libperf_events/operf_utils.cpp
+@@ -295,6 +295,10 @@ static void __handle_mmap_event(event_t * event)
+ 		                    strlen("//anon")) == 0)) {
+ 			mapping->is_anon_mapping = true;
+ 			strcpy(mapping->filename, "anon");
++		} else if ((strncmp(mapping->filename, "/anon_hugepage",
++		                    strlen("/anon_hugepage")) == 0)) {
++			mapping->is_anon_mapping = true;
++			strcpy(mapping->filename, "anon");
+ 		}
+ 		mapping->end_addr = (event->mmap.len == 0ULL)? 0ULL : mapping->start_addr + event->mmap.len - 1;
+ 		mapping->pgoff = event->mmap.pgoff;
+-- 
+2.1.0
+
diff --git a/oprofile.spec b/oprofile.spec
index 2df1705..dc9ff70 100644
--- a/oprofile.spec
+++ b/oprofile.spec
@@ -1,7 +1,7 @@
 Summary: System wide profiler
 Name: oprofile
 Version: 1.0.0
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2+ and LGPLv2+
 Group: Development/System
 #
@@ -10,6 +10,8 @@ Requires: binutils
 Requires: which
 Requires(pre): shadow-utils
 Requires(postun): shadow-utils
+Patch700: oprofile-hugepage.patch
+Patch701: oprofile-env.patch
 
 URL: http://oprofile.sf.net
 
@@ -64,6 +66,8 @@ agent library.
 
 %prep
 %setup -q -n %{name}-%{version}
+%patch700 -p1
+%patch701 -p1
 
 ./autogen.sh
 
@@ -145,6 +149,10 @@ exit 0
 %{_sysconfdir}/ld.so.conf.d/*
 
 %changelog
+* Fri Jan 23 2015 William Cohen <wcohen at redhat.com> - 1.0.0-3
+- Allow oprofile to track Java method on hugepages.
+- Avoid setting POSIXLY_CORRECT for the children tasks of operf and ocount.
+
 * Mon Sep 15 2014 William Cohen <wcohen at redhat.com> - 1.0.0-2
 - Fix java buildrequires.
 


More information about the scm-commits mailing list