Blame SOURCES/jdk8215727-rh1889532-restore_jfr_thread_sampler_loop.patch

aef6f0
# HG changeset patch
aef6f0
# User mgronlun
aef6f0
# Date 1545407800 -3600
aef6f0
#      Fri Dec 21 16:56:40 2018 +0100
aef6f0
# Node ID 321a84a5e5b88cbb88f72aa98645affc57689fb0
aef6f0
# Parent  002b9c947f0f3d53aebccffb922460701555b456
aef6f0
8215727: Restore JFR thread sampler loop to old / previous behavior
aef6f0
Reviewed-by: egahlin, mgronlun
aef6f0
Contributed-by: milan.mimica@gmail.com
aef6f0
aef6f0
diff --git openjdk.orig/hotspot/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp openjdk/hotspot/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp
aef6f0
--- openjdk.orig/hotspot/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp
aef6f0
+++ openjdk/hotspot/src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp
aef6f0
@@ -285,13 +285,13 @@
aef6f0
 
aef6f0
 void JfrThreadSampleClosure::commit_events(JfrSampleType type) {
aef6f0
   if (JAVA_SAMPLE == type) {
aef6f0
-    assert(_added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
aef6f0
+    assert(_added_java > 0 && _added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
aef6f0
     for (uint i = 0; i < _added_java; ++i) {
aef6f0
       _events[i].commit();
aef6f0
     }
aef6f0
   } else {
aef6f0
     assert(NATIVE_SAMPLE == type, "invariant");
aef6f0
-    assert(_added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
aef6f0
+    assert(_added_native > 0 && _added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
aef6f0
     for (uint i = 0; i < _added_native; ++i) {
aef6f0
       _events_native[i].commit();
aef6f0
     }
aef6f0
@@ -537,7 +537,7 @@
aef6f0
   JfrThreadSampleClosure sample_task(samples, samples_native);
aef6f0
 
aef6f0
   const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES;
aef6f0
-  uint num_sample_attempts = 0;
aef6f0
+  uint num_samples = 0;
aef6f0
   JavaThread* start = NULL;
aef6f0
 
aef6f0
   {
aef6f0
@@ -555,7 +555,7 @@
aef6f0
       JavaThread* current = Threads::includes(*last_thread) ? *last_thread : NULL;
aef6f0
       JavaThread* start = NULL;
aef6f0
 
aef6f0
-      while (num_sample_attempts < sample_limit) {
aef6f0
+      while (num_samples < sample_limit) {
aef6f0
         current = next_thread(threads_list, index, start, current);
aef6f0
         if (current == NULL) {
aef6f0
           break;
aef6f0
@@ -566,8 +566,9 @@
aef6f0
         if (current->is_Compiler_thread()) {
aef6f0
           continue;
aef6f0
         }
aef6f0
-        sample_task.do_sample_thread(current, _frames, _max_frames, type);
aef6f0
-        num_sample_attempts++;
aef6f0
+        if (sample_task.do_sample_thread(current, _frames, _max_frames, type)) {
aef6f0
+          num_samples++;
aef6f0
+        }
aef6f0
       }
aef6f0
       *last_thread = current;  // remember the thread we last attempted to sample
aef6f0
       FREE_C_HEAP_ARRAY(JavaThread *, threads_list, mtInternal);
aef6f0
@@ -576,7 +577,7 @@
aef6f0
     if (LogJFR && Verbose) tty->print_cr("JFR thread sampling done in %3.7f secs with %d java %d native samples",
aef6f0
                    sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries());
aef6f0
   }
aef6f0
-  if (num_sample_attempts > 0) {
aef6f0
+  if (num_samples > 0) {
aef6f0
     sample_task.commit_events(type);
aef6f0
   }
aef6f0
 }