Blame SOURCES/oprofile-ppc64jvm.patch

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