changeset 3610:942bb29b20b0

7196298: Better fix for 7195789 Reviewed-by: jcoomes, brutisso
author jmasa
date Thu, 06 Sep 2012 07:28:30 -0700
parents fa6e618671d7
children aed758eda82a
files src/share/vm/memory/metaspace.cpp src/share/vm/memory/metaspace.hpp src/share/vm/memory/metaspaceCounters.cpp
diffstat 3 files changed, 6 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/memory/metaspace.cpp	Wed Sep 05 20:08:08 2012 -0400
+++ b/src/share/vm/memory/metaspace.cpp	Thu Sep 06 07:28:30 2012 -0700
@@ -2541,7 +2541,7 @@
 
 // MetaspaceAux
 
-size_t MetaspaceAux::used_in_bytes_unsafe(Metaspace::MetadataType mdtype) {
+size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) {
   size_t used = 0;
   ClassLoaderDataGraphMetaspaceIterator iter;
   while (iter.repeat()) {
@@ -2554,33 +2554,6 @@
   return used * BytesPerWord;
 }
 
-size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) {
-  assert(SafepointSynchronize::is_at_safepoint(),
-    "Consistency checks require being at a safepoint");
-  size_t used = 0;
-#ifdef ASSERT
-  size_t free = 0;
-  size_t capacity = 0;
-#endif
-  ClassLoaderDataGraphMetaspaceIterator iter;
-  while (iter.repeat()) {
-    Metaspace* msp = iter.get_next();
-    // Sum allocation_total for each metaspace
-    if (msp != NULL) {
-      used += msp->used_words(mdtype);
-#ifdef ASSERT
-      free += msp->free_words(mdtype);
-      capacity += msp->capacity_words(mdtype);
-      assert(used + free == capacity,
-        err_msg("Accounting is wrong used " SIZE_FORMAT
-                " free " SIZE_FORMAT " capacity " SIZE_FORMAT,
-                used, free, capacity));
-#endif
-    }
-  }
-  return used * BytesPerWord;
-}
-
 size_t MetaspaceAux::free_in_bytes(Metaspace::MetadataType mdtype) {
   size_t free = 0;
   ClassLoaderDataGraphMetaspaceIterator iter;
@@ -2661,15 +2634,15 @@
   out->print_cr(" Metaspace total "
                 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
                 " reserved " SIZE_FORMAT "K",
-                capacity_in_bytes()/K, used_in_bytes_unsafe()/K, reserved_in_bytes()/K);
+                capacity_in_bytes()/K, used_in_bytes()/K, reserved_in_bytes()/K);
   out->print_cr("  data space     "
                 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
                 " reserved " SIZE_FORMAT "K",
-                capacity_in_bytes(nct)/K, used_in_bytes_unsafe(nct)/K, reserved_in_bytes(nct)/K);
+                capacity_in_bytes(nct)/K, used_in_bytes(nct)/K, reserved_in_bytes(nct)/K);
   out->print_cr("  class space    "
                 SIZE_FORMAT "K, used " SIZE_FORMAT "K,"
                 " reserved " SIZE_FORMAT "K",
-                capacity_in_bytes(ct)/K, used_in_bytes_unsafe(ct)/K, reserved_in_bytes(ct)/K);
+                capacity_in_bytes(ct)/K, used_in_bytes(ct)/K, reserved_in_bytes(ct)/K);
 }
 
 // Print information for class space and data space separately.
--- a/src/share/vm/memory/metaspace.hpp	Wed Sep 05 20:08:08 2012 -0400
+++ b/src/share/vm/memory/metaspace.hpp	Thu Sep 06 07:28:30 2012 -0700
@@ -149,10 +149,6 @@
 
   // Statistics for class space and data space in metaspace.
   static size_t used_in_bytes(Metaspace::MetadataType mdtype);
-  // Same as used_in_bytes() without the consistency checking.
-  // Use this version if not at a safepoint (so consistency is
-  // not necessarily expected).
-  static size_t used_in_bytes_unsafe(Metaspace::MetadataType mdtype);
   static size_t free_in_bytes(Metaspace::MetadataType mdtype);
   static size_t capacity_in_bytes(Metaspace::MetadataType mdtype);
   static size_t reserved_in_bytes(Metaspace::MetadataType mdtype);
@@ -167,11 +163,6 @@
            used_in_bytes(Metaspace::NonClassType);
   }
 
-  static size_t used_in_bytes_unsafe() {
-    return used_in_bytes_unsafe(Metaspace::ClassType) +
-           used_in_bytes_unsafe(Metaspace::NonClassType);
-  }
-
   // Total of available space in all Metaspaces
   // Total of capacity allocated to all Metaspaces.  This includes
   // space in Metachunks not yet allocated and in the Metachunk
--- a/src/share/vm/memory/metaspaceCounters.cpp	Wed Sep 05 20:08:08 2012 -0400
+++ b/src/share/vm/memory/metaspaceCounters.cpp	Thu Sep 06 07:28:30 2012 -0700
@@ -35,7 +35,7 @@
     size_t min_capacity = MetaspaceAux::min_chunk_size();
     size_t max_capacity = MetaspaceAux::reserved_in_bytes();
     size_t curr_capacity = MetaspaceAux::capacity_in_bytes();
-    size_t used = MetaspaceAux::used_in_bytes_unsafe();
+    size_t used = MetaspaceAux::used_in_bytes();
 
     initialize(min_capacity, max_capacity, curr_capacity, used);
   }
@@ -131,7 +131,7 @@
 
 void MetaspaceCounters::update_used() {
   assert(UsePerfData, "Should not be called unless being used");
-  size_t used_in_bytes = MetaspaceAux::used_in_bytes_unsafe();
+  size_t used_in_bytes = MetaspaceAux::used_in_bytes();
   _used->set_value(used_in_bytes);
 }