Blame SOURCES/oprofile-ppc64jvm.patch

c532ac
commit a41b4231ccfc83fb99271507a8e98f84a348e71d
c532ac
Author: Rei Odaira <rei.odaira@gmail.com>
c532ac
Date:   Fri May 22 15:34:50 2015 -0400
c532ac
c532ac
    Filter out zero-sized mapping to avoid opjitconv running indefinitely
c532ac
    
c532ac
    I found opjitconv ran indefinitely when profiling a Java application
c532ac
    running on OpenJDK/ppc64le.  This is because OpenJDK sometimes reports
c532ac
    generation of zero-size jitted code via JVMTI, but scan_overlaps() in
c532ac
    opjitconv does not assume the existence of jitted code with size zero.
c532ac
    
c532ac
    (1) scan_overlaps() finds overlap between a normal jitted code and a
c532ac
        zero-size jitted code.
c532ac
    (2) eliminate_overlaps() tries to split the zero-size jitted code but
c532ac
         cannot.
c532ac
    (3) resolve_overlaps() incorrectly thinks the split has happened and
c532ac
         invokes scan_overlaps() again.
c532ac
    (4) Back to (1)
c532ac
    
c532ac
    One solution is to remove all the zero-size entries before resolving
c532ac
    overlaps which is implemented by this patch.
c532ac
    
c532ac
    Signed-off-by: William Cohen <wcohen@redhat.com>
c532ac
c532ac
diff --git a/opjitconv/jitsymbol.c b/opjitconv/jitsymbol.c
c532ac
index e2b1e66..1b980af 100644
c532ac
--- a/opjitconv/jitsymbol.c
c532ac
+++ b/opjitconv/jitsymbol.c
c532ac
@@ -201,6 +201,26 @@ static void invalidate_earlybirds(unsigned long long start_time)
c532ac
 	}
c532ac
 }
c532ac
 
c532ac
+static void invalidate_zero_size_entries(void)
c532ac
+{
c532ac
+	u32 i;
c532ac
+	int flag;
c532ac
+	struct jitentry * a;
c532ac
+
c532ac
+	flag = 0;
c532ac
+	for (i = 0; i < entry_count; i++) {
c532ac
+		a = entries_address_ascending[i];
c532ac
+		if (a->code_size == 0) {
c532ac
+			invalidate_entry(a);
c532ac
+			flag = 1;
c532ac
+		}
c532ac
+	}
c532ac
+	if (flag) {
c532ac
+		resort_address();
c532ac
+		resort_symbol();
c532ac
+	}
c532ac
+}
c532ac
+
c532ac
 
c532ac
 /* select the symbol with the longest life time in the index range */
c532ac
 static int select_one(int start_idx, int end_idx)
c532ac
@@ -505,6 +525,7 @@ int resolve_overlaps(unsigned long long start_time)
c532ac
 	int cnt = 0;
c532ac
 
c532ac
 	invalidate_earlybirds(start_time);
c532ac
+	invalidate_zero_size_entries();
c532ac
 	while ((rc = scan_overlaps()) && rc != OP_JIT_CONV_FAIL) {
c532ac
 		resort_address();
c532ac
 		if (cnt == 0) {