Blame SOURCES/jdk8215727-rh1889532-restore_jfr_thread_sampler_loop.patch

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