< prev index next >

src/hotspot/share/gc/z/zPhysicalMemory.cpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"

  25 #include "gc/z/zAddress.inline.hpp"
  26 #include "gc/z/zGlobals.hpp"
  27 #include "gc/z/zLargePages.inline.hpp"
  28 #include "gc/z/zNUMA.inline.hpp"
  29 #include "gc/z/zPhysicalMemory.inline.hpp"
  30 #include "logging/log.hpp"
  31 #include "runtime/globals.hpp"
  32 #include "runtime/globals_extension.hpp"
  33 #include "runtime/init.hpp"
  34 #include "runtime/os.hpp"
  35 #include "services/memTracker.hpp"
  36 #include "utilities/align.hpp"
  37 #include "utilities/debug.hpp"
  38 #include "utilities/globalDefinitions.hpp"
  39 #include "utilities/powerOfTwo.hpp"
  40 
  41 ZPhysicalMemory::ZPhysicalMemory() :
  42     _nsegments_max(0),
  43     _nsegments(0),
  44     _segments(NULL) {}


 279     _backing(max_capacity) {
 280   // Make the whole range free
 281   _manager.free(0, max_capacity);
 282 }
 283 
 284 bool ZPhysicalMemoryManager::is_initialized() const {
 285   return _backing.is_initialized();
 286 }
 287 
 288 void ZPhysicalMemoryManager::warn_commit_limits(size_t max_capacity) const {
 289   _backing.warn_commit_limits(max_capacity);
 290 }
 291 
 292 void ZPhysicalMemoryManager::try_enable_uncommit(size_t min_capacity, size_t max_capacity) {
 293   assert(!is_init_completed(), "Invalid state");
 294 
 295   // If uncommit is not explicitly disabled, max capacity is greater than
 296   // min capacity, and uncommit is supported by the platform, then uncommit
 297   // will be enabled.
 298   if (!ZUncommit) {
 299     log_info(gc, init)("Uncommit: Disabled");
 300     return;
 301   }
 302 
 303   if (max_capacity == min_capacity) {
 304     log_info(gc, init)("Uncommit: Implicitly Disabled (-Xms equals -Xmx)");
 305     FLAG_SET_ERGO(ZUncommit, false);
 306     return;
 307   }
 308 
 309   // Test if uncommit is supported by the operating system by committing
 310   // and then uncommitting a granule.
 311   ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZGranuleSize, false /* committed */));
 312   if (!commit(pmem) || !uncommit(pmem)) {
 313     log_info(gc, init)("Uncommit: Implicitly Disabled (Not supported by operating system)");
 314     FLAG_SET_ERGO(ZUncommit, false);
 315     return;
 316   }
 317 
 318   log_info(gc, init)("Uncommit: Enabled");
 319   log_info(gc, init)("Uncommit Delay: " UINTX_FORMAT "s", ZUncommitDelay);
 320 }
 321 
 322 void ZPhysicalMemoryManager::nmt_commit(uintptr_t offset, size_t size) const {
 323   // From an NMT point of view we treat the first heap view (marked0) as committed
 324   const uintptr_t addr = ZAddress::marked0(offset);
 325   MemTracker::record_virtual_memory_commit((void*)addr, size, CALLER_PC);
 326 }
 327 
 328 void ZPhysicalMemoryManager::nmt_uncommit(uintptr_t offset, size_t size) const {
 329   if (MemTracker::tracking_level() > NMT_minimal) {
 330     const uintptr_t addr = ZAddress::marked0(offset);
 331     Tracker tracker(Tracker::uncommit);
 332     tracker.record((address)addr, size);
 333   }
 334 }
 335 
 336 void ZPhysicalMemoryManager::alloc(ZPhysicalMemory& pmem, size_t size) {
 337   assert(is_aligned(size, ZGranuleSize), "Invalid size");
 338 
 339   // Allocate segments




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shared/gcLogPrecious.hpp"
  26 #include "gc/z/zAddress.inline.hpp"
  27 #include "gc/z/zGlobals.hpp"
  28 #include "gc/z/zLargePages.inline.hpp"
  29 #include "gc/z/zNUMA.inline.hpp"
  30 #include "gc/z/zPhysicalMemory.inline.hpp"
  31 #include "logging/log.hpp"
  32 #include "runtime/globals.hpp"
  33 #include "runtime/globals_extension.hpp"
  34 #include "runtime/init.hpp"
  35 #include "runtime/os.hpp"
  36 #include "services/memTracker.hpp"
  37 #include "utilities/align.hpp"
  38 #include "utilities/debug.hpp"
  39 #include "utilities/globalDefinitions.hpp"
  40 #include "utilities/powerOfTwo.hpp"
  41 
  42 ZPhysicalMemory::ZPhysicalMemory() :
  43     _nsegments_max(0),
  44     _nsegments(0),
  45     _segments(NULL) {}


 280     _backing(max_capacity) {
 281   // Make the whole range free
 282   _manager.free(0, max_capacity);
 283 }
 284 
 285 bool ZPhysicalMemoryManager::is_initialized() const {
 286   return _backing.is_initialized();
 287 }
 288 
 289 void ZPhysicalMemoryManager::warn_commit_limits(size_t max_capacity) const {
 290   _backing.warn_commit_limits(max_capacity);
 291 }
 292 
 293 void ZPhysicalMemoryManager::try_enable_uncommit(size_t min_capacity, size_t max_capacity) {
 294   assert(!is_init_completed(), "Invalid state");
 295 
 296   // If uncommit is not explicitly disabled, max capacity is greater than
 297   // min capacity, and uncommit is supported by the platform, then uncommit
 298   // will be enabled.
 299   if (!ZUncommit) {
 300     log_info_p(gc, init)("Uncommit: Disabled");
 301     return;
 302   }
 303 
 304   if (max_capacity == min_capacity) {
 305     log_info_p(gc, init)("Uncommit: Implicitly Disabled (-Xms equals -Xmx)");
 306     FLAG_SET_ERGO(ZUncommit, false);
 307     return;
 308   }
 309 
 310   // Test if uncommit is supported by the operating system by committing
 311   // and then uncommitting a granule.
 312   ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZGranuleSize, false /* committed */));
 313   if (!commit(pmem) || !uncommit(pmem)) {
 314     log_info_p(gc, init)("Uncommit: Implicitly Disabled (Not supported by operating system)");
 315     FLAG_SET_ERGO(ZUncommit, false);
 316     return;
 317   }
 318 
 319   log_info_p(gc, init)("Uncommit: Enabled");
 320   log_info_p(gc, init)("Uncommit Delay: " UINTX_FORMAT "s", ZUncommitDelay);
 321 }
 322 
 323 void ZPhysicalMemoryManager::nmt_commit(uintptr_t offset, size_t size) const {
 324   // From an NMT point of view we treat the first heap view (marked0) as committed
 325   const uintptr_t addr = ZAddress::marked0(offset);
 326   MemTracker::record_virtual_memory_commit((void*)addr, size, CALLER_PC);
 327 }
 328 
 329 void ZPhysicalMemoryManager::nmt_uncommit(uintptr_t offset, size_t size) const {
 330   if (MemTracker::tracking_level() > NMT_minimal) {
 331     const uintptr_t addr = ZAddress::marked0(offset);
 332     Tracker tracker(Tracker::uncommit);
 333     tracker.record((address)addr, size);
 334   }
 335 }
 336 
 337 void ZPhysicalMemoryManager::alloc(ZPhysicalMemory& pmem, size_t size) {
 338   assert(is_aligned(size, ZGranuleSize), "Invalid size");
 339 
 340   // Allocate segments


< prev index next >