8203457: Add back missing full buffer notification
authormgronlun
Wed, 23 May 2018 15:21:54 +0200
changeset 50234 6ba3e32a9882
parent 50233 48d4abe945f1
child 50235 ff5d0ea58d9b
8203457: Add back missing full buffer notification Reviewed-by: redestad, sjohanss
src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp
src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp
--- a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp	Wed May 23 09:43:41 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp	Wed May 23 15:21:54 2018 +0200
@@ -332,6 +332,7 @@
   assert(age_node->acquired_by_self(), "invariant");
   assert(age_node != NULL, "invariant");
   age_node->set_retired_buffer(buffer);
+  control.increment_full();
   return insert_full_age_node(age_node, age_mspace, thread);
 }
 
@@ -631,6 +632,7 @@
 static void process_age_list(Processor& processor, JfrStorageAgeMspace* age_mspace, JfrAgeNode* head, size_t count) {
   assert(age_mspace != NULL, "invariant");
   assert(head != NULL, "invariant");
+  assert(count > 0, "invariant");
   JfrAgeNode* node = head;
   JfrAgeNode* last = NULL;
   while (node != NULL) {
@@ -669,7 +671,7 @@
     return 0;
   }
   size_t count;
-  JfrAgeNode* head;;
+  JfrAgeNode* head;
   {
     // fetch age list
     MutexLockerEx buffer_lock(JfrBuffer_lock, Mutex::_no_safepoint_check_flag);
@@ -678,6 +680,7 @@
     control.reset_full();
   }
   assert(head != NULL, "invariant");
+  assert(count > 0, "invariant");
   process_age_list(processor, age_mspace, head, count);
   return count;
 }
--- a/src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp	Wed May 23 09:43:41 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp	Wed May 23 15:21:54 2018 +0200
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "jfr/recorder/storage/jfrStorageControl.hpp"
 #include "runtime/atomic.hpp"
+#include "runtime/mutexLocker.hpp"
 #include "runtime/orderAccess.inline.hpp"
 
 // returns the updated value
@@ -69,22 +70,25 @@
   _to_disk = enable;
 }
 
-// concurrent with lax requirement
-
 size_t JfrStorageControl::full_count() const {
   return _full_count;
 }
 
+// mutexed access
 size_t JfrStorageControl::increment_full() {
-  return atomic_add(1, &_full_count);
+  assert(JfrBuffer_lock->owned_by_self(), "invariant");
+  return ++_full_count;
 }
 
 size_t JfrStorageControl::decrement_full() {
-  return atomic_dec(&_full_count);
+  assert(JfrBuffer_lock->owned_by_self(), "invariant");
+  assert(_full_count > 0, "invariant");
+  return --_full_count;
 }
 
 void JfrStorageControl::reset_full() {
-  Atomic::store((size_t)0, &_full_count);
+  assert(JfrBuffer_lock->owned_by_self(), "invariant");
+  _full_count = 0;
 }
 
 bool JfrStorageControl::should_post_buffer_full_message() const {