< prev index next >

share/gc/g1/g1CollectedHeap.cpp

Print this page
rev 1 : G1GC+POGC+NVDIMM Patch with latest comments incorporated from all.
rev 10 : Removed any AllocateOldGenAt handling in reservespace

@@ -1314,12 +1314,11 @@
   return NULL;
 }
 
 bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) {
   size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
-  aligned_expand_bytes = align_up(aligned_expand_bytes,
-                                       HeapRegion::GrainBytes);
+  aligned_expand_bytes = align_up(aligned_expand_bytes, HeapRegion::GrainBytes);
 
   log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: " SIZE_FORMAT "B expansion amount: " SIZE_FORMAT "B",
                             expand_bytes, aligned_expand_bytes);
 
   if (is_maximal_no_gc()) {

@@ -1561,11 +1560,11 @@
 
   // Create the hot card cache.
   _hot_card_cache = new G1HotCardCache(this);
 
   // Carve out the G1 part of the heap.
-  ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
+  ReservedSpace g1_rs = heap_rs.first_part(heap_rs.size());
   size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
   G1RegionToSpaceMapper* heap_storage =
     G1RegionToSpaceMapper::create_mapper(g1_rs,
                                          g1_rs.size(),
                                          page_size,

@@ -1644,16 +1643,40 @@
     vm_shutdown_during_initialization("Could not create/initialize G1ConcurrentMark");
     return JNI_ENOMEM;
   }
   _cm_thread = _cm->cm_thread();
 
+  // Expand NVDIMM to maximum old gen size.
+  if (AllocateOldGenAt != NULL) {
+    int fd_for_heap = -1;
+    fd_for_heap = os::create_file_for_heap(AllocateOldGenAt);
+    if (fd_for_heap== -1) {
+      vm_exit_during_initialization(
+        err_msg("Could not create file for Heap at location %s", AllocateOldGenAt));
+    }
+    // Allocate space on device.
+    os::allocate_file(fd_for_heap, MaxHeapSize);
+    os::set_nvdimm_fd(fd_for_heap);
+    os::set_nvdimm_present(true);
+    os::set_nvdimm_heapbase((address)(heap_rs.base()));
+  }
+  size_t aligned_expand_bytes = 0;
+  if (os::has_nvdimm()) {
+    aligned_expand_bytes = expand_old_gen_on_nvdimm(max_byte_size);
+  }
   // Now expand into the initial heap size.
   if (!expand(init_byte_size, _workers)) {
     vm_shutdown_during_initialization("Failed to allocate initial heap.");
     return JNI_ENOMEM;
   }
 
+  if (os::has_nvdimm()) {
+    // Show how much memory was committed on NVDIMM and DRAM.
+    log_info(gc, heap)("NVDIMM Reserved Bytes : %ld DRAM Reserved Bytes : %ld \n", aligned_expand_bytes, init_byte_size);
+    log_info(gc, heap)("When NVDIMM is present, we always reserve and commit Maximum OldGen Size on NVDIMM");
+    log_info(gc, heap)("JVM will have more size reserved and committed than specified by Xmn or Xms options (but never more than Xmx).");
+  }
   // Perform any initialization actions delegated to the policy.
   g1_policy()->init(this, &_collection_set);
 
   G1BarrierSet::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
                                                  SATB_Q_FL_lock,

@@ -1711,10 +1734,20 @@
   _collection_set.initialize(max_regions());
 
   return JNI_OK;
 }
 
+size_t G1CollectedHeap::expand_old_gen_on_nvdimm(size_t max_byte_size) {
+  size_t nvdimm_bytes = max_byte_size - (size_t)(max_byte_size * G1MaxNewSizePercent)/100;
+  size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(nvdimm_bytes);
+  aligned_expand_bytes = align_up(aligned_expand_bytes, HeapRegion::GrainBytes);
+  uint nvdimm_regions = (uint)(aligned_expand_bytes/HeapRegion::GrainBytes);
+  os::set_nvdimm_regionlength(nvdimm_regions);
+  expand(aligned_expand_bytes, _workers);
+  return aligned_expand_bytes;
+}
+
 void G1CollectedHeap::initialize_serviceability() {
   _eden_pool = new G1EdenPool(this);
   _survivor_pool = new G1SurvivorPool(this);
   _old_pool = new G1OldGenPool(this);
 
< prev index next >