8077255: TracePageSizes output reports wrong page size on Windows with G1
authortschatzl
Thu, 09 Apr 2015 15:41:47 +0200
changeset 30166 a85188117643
parent 30165 c4ff729cb74a
child 30168 df0c5880c78e
8077255: TracePageSizes output reports wrong page size on Windows with G1 Summary: Print selected page size, not alignment size chosen by ReservedSpace (which is the vm_allocation_granularity that is different to page size on Windows) in the message presented by TracePageSizes. Reviewed-by: drwhite, jmasa
hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/runtime/virtualspace.cpp
hotspot/src/share/vm/runtime/virtualspace.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Apr 08 09:35:25 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Apr 09 15:41:47 2015 +0200
@@ -1805,8 +1805,9 @@
 G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* description,
                                                                  size_t size,
                                                                  size_t translation_factor) {
+  size_t preferred_page_size = os::page_size_for_region_unaligned(size, 1);
   // Allocate a new reserved space, preferring to use large pages.
-  ReservedSpace rs(size, true);
+  ReservedSpace rs(size, preferred_page_size);
   G1RegionToSpaceMapper* result  =
     G1RegionToSpaceMapper::create_mapper(rs,
                                          size,
@@ -1816,7 +1817,7 @@
                                          mtGC);
   if (TracePageSizes) {
     gclog_or_tty->print_cr("G1 '%s': pg_sz=" SIZE_FORMAT " base=" PTR_FORMAT " size=" SIZE_FORMAT " alignment=" SIZE_FORMAT " reqsize=" SIZE_FORMAT,
-                           description, rs.alignment(), p2i(rs.base()), rs.size(), rs.alignment(), size);
+                           description, preferred_page_size, p2i(rs.base()), rs.size(), rs.alignment(), size);
   }
   return result;
 }
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp	Wed Apr 08 09:35:25 2015 +0200
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp	Thu Apr 09 15:41:47 2015 +0200
@@ -37,12 +37,13 @@
     _alignment(0), _special(false), _executable(false) {
 }
 
-ReservedSpace::ReservedSpace(size_t size, bool prefer_large_pages) {
+ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) {
+  bool has_preferred_page_size = preferred_page_size != 0;
   // Want to use large pages where possible and pad with small pages.
-  size_t page_size = os::page_size_for_region_unaligned(size, 1);
+  size_t page_size = has_preferred_page_size ? preferred_page_size : os::page_size_for_region_unaligned(size, 1);
   bool large_pages = page_size != (size_t)os::vm_page_size();
   size_t alignment;
-  if (large_pages && prefer_large_pages) {
+  if (large_pages && has_preferred_page_size) {
     alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity());
     // ReservedSpace initialization requires size to be aligned to the given
     // alignment. Align the size up.
--- a/hotspot/src/share/vm/runtime/virtualspace.hpp	Wed Apr 08 09:35:25 2015 +0200
+++ b/hotspot/src/share/vm/runtime/virtualspace.hpp	Thu Apr 09 15:41:47 2015 +0200
@@ -51,12 +51,11 @@
  public:
   // Constructor
   ReservedSpace();
-  // Initialize the reserved space with the given size. If prefer_large_pages is
-  // set, if the given size warrants use of large pages, try to force them by
-  // passing an alignment restriction further down. This may waste some space
-  // if the given size is not aligned, as the reservation will be aligned up
-  // to large page alignment.
-  ReservedSpace(size_t size, bool prefer_large_pages = false);
+  // Initialize the reserved space with the given size. If preferred_page_size
+  // is set, use this as minimum page size/alignment. This may waste some space
+  // if the given size is not aligned to that value, as the reservation will be
+  // aligned up to the final alignment in this case.
+  ReservedSpace(size_t size, size_t preferred_page_size = 0);
   ReservedSpace(size_t size, size_t alignment, bool large,
                 char* requested_address = NULL);
   ReservedSpace(size_t size, size_t alignment, bool large, bool executable);