Blame SOURCES/jdk8215727-rh1889532-restore_jfr_thread_sampler_loop.patch

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