< prev index next >

src/share/vm/runtime/commandLineFlagConstraintsGC.cpp

Print this page
rev 9473 : [mq]: webrev.00


  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 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/collectorPolicy.hpp"
  28 #include "gc/shared/threadLocalAllocBuffer.hpp"
  29 #include "runtime/arguments.hpp"
  30 #include "runtime/commandLineFlagConstraintsGC.hpp"
  31 #include "runtime/commandLineFlagRangeList.hpp"
  32 #include "runtime/globals.hpp"
  33 #include "runtime/globals_extension.hpp"

  34 #include "utilities/defaultStream.hpp"
  35 
  36 #if INCLUDE_ALL_GCS
  37 #include "gc/g1/g1_globals.hpp"
  38 #include "gc/g1/heapRegionBounds.inline.hpp"
  39 #include "gc/shared/plab.hpp"
  40 #endif // INCLUDE_ALL_GCS
  41 #ifdef COMPILER1
  42 #include "c1/c1_globals.hpp"
  43 #endif // COMPILER1
  44 #ifdef COMPILER2
  45 #include "opto/c2_globals.hpp"
  46 #endif // COMPILER2
  47 
  48 // Some flags that have default values that indicate that the
  49 // JVM should automatically determine an appropriate value
  50 // for that flag.  In those cases it is only appropriate for the
  51 // constraint checking to be done if the user has specified the
  52 // value(s) of the flag(s) on the command line.  In the constraint
  53 // checking functions,  FLAG_IS_CMDLINE() is used to check if


 489         return Flag::VIOLATES_CONSTRAINT;
 490       }
 491     }
 492   }
 493 #endif
 494   return Flag::SUCCESS;
 495 }
 496 
 497 Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
 498   size_t aligned_max = (size_t)align_size_down(max_uintx/2, Metaspace::reserve_alignment_words());
 499   if (value > aligned_max) {
 500     CommandLineError::print(verbose,
 501                             "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
 502                             "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
 503                             value, aligned_max);
 504     return Flag::VIOLATES_CONSTRAINT;
 505   }
 506   return Flag::SUCCESS;
 507 }
 508 













 509 static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
 510   // For G1 GC, we don't know until G1CollectorPolicy is created.
 511   size_t heap_alignment;
 512 
 513 #if INCLUDE_ALL_GCS
 514   if (UseG1GC) {
 515     heap_alignment = HeapRegionBounds::max_size();
 516   } else
 517 #endif
 518   {
 519     heap_alignment = CollectorPolicy::compute_heap_alignment();
 520   }
 521 
 522   // Not to overflow 'align_size_up(value, _heap_alignment) used from CollectorPolicy::initialize_flags()'.
 523   size_t aligned_max = ((max_uintx - heap_alignment) & ~(heap_alignment-1));
 524   if (value > aligned_max) {
 525     CommandLineError::print(verbose,
 526                             "%s (" SIZE_FORMAT ") must be "
 527                             "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
 528                             name, value, aligned_max);
 529     return Flag::VIOLATES_CONSTRAINT;
 530   }
 531   return Flag::SUCCESS;
 532 }
 533 
 534 Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
 535   return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
 536 }
 537 
 538 Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
 539   Flag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
 540 
 541   if (status == Flag::SUCCESS) {
 542     status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
 543   }
 544   return status;
 545 }
 546 













 547 Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
 548 #ifdef _LP64
 549 #if INCLUDE_ALL_GCS
 550   // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length
 551   // when the value to be assigned exceeds uint range.
 552   // i.e. result of '(uint)(NewSize / region size(1~32MB))'
 553   // So maximum of NewSize should be 'max_juint * 1M'
 554   if (UseG1GC && (value > (max_juint * 1 * M))) {
 555     CommandLineError::print(verbose,
 556                             "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n",
 557                             value);
 558     return Flag::VIOLATES_CONSTRAINT;
 559   }
 560 #endif // INCLUDE_ALL_GCS
 561 #endif // _LP64
 562   return Flag::SUCCESS;
 563 }
 564 
 565 Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
 566   // At least, alignment reserve area is needed.


 573   } else {
 574     return Flag::SUCCESS;
 575   }
 576 }
 577 
 578 Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
 579   // Skip for default value of zero which means set ergonomically.
 580   if (FLAG_IS_CMDLINE(TLABSize)) {
 581     if (value < MinTLABSize) {
 582       CommandLineError::print(verbose,
 583                               "TLABSize (" SIZE_FORMAT ") must be "
 584                               "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
 585                               value, MinTLABSize);
 586       return Flag::VIOLATES_CONSTRAINT;
 587     }
 588     if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
 589       CommandLineError::print(verbose,
 590                               "TLABSize (" SIZE_FORMAT ") must be "
 591                               "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
 592                               value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));


















 593       return Flag::VIOLATES_CONSTRAINT;
 594     }
 595   }
 596   return Flag::SUCCESS;
 597 }
 598 
 599 Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
 600   if (FLAG_IS_CMDLINE(SurvivorRatio) &&
 601       (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
 602     CommandLineError::print(verbose,
 603                             "SurvivorRatio (" UINTX_FORMAT ") must be "
 604                             "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
 605                             value,
 606                             (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
 607     return Flag::VIOLATES_CONSTRAINT;
 608   } else {
 609     return Flag::SUCCESS;
 610   }
 611 }
 612 




  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 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/collectorPolicy.hpp"
  28 #include "gc/shared/threadLocalAllocBuffer.hpp"
  29 #include "runtime/arguments.hpp"
  30 #include "runtime/commandLineFlagConstraintsGC.hpp"
  31 #include "runtime/commandLineFlagRangeList.hpp"
  32 #include "runtime/globals.hpp"
  33 #include "runtime/globals_extension.hpp"
  34 #include "runtime/thread.inline.hpp"
  35 #include "utilities/defaultStream.hpp"
  36 
  37 #if INCLUDE_ALL_GCS
  38 #include "gc/g1/g1_globals.hpp"
  39 #include "gc/g1/heapRegionBounds.inline.hpp"
  40 #include "gc/shared/plab.hpp"
  41 #endif // INCLUDE_ALL_GCS
  42 #ifdef COMPILER1
  43 #include "c1/c1_globals.hpp"
  44 #endif // COMPILER1
  45 #ifdef COMPILER2
  46 #include "opto/c2_globals.hpp"
  47 #endif // COMPILER2
  48 
  49 // Some flags that have default values that indicate that the
  50 // JVM should automatically determine an appropriate value
  51 // for that flag.  In those cases it is only appropriate for the
  52 // constraint checking to be done if the user has specified the
  53 // value(s) of the flag(s) on the command line.  In the constraint
  54 // checking functions,  FLAG_IS_CMDLINE() is used to check if


 490         return Flag::VIOLATES_CONSTRAINT;
 491       }
 492     }
 493   }
 494 #endif
 495   return Flag::SUCCESS;
 496 }
 497 
 498 Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
 499   size_t aligned_max = (size_t)align_size_down(max_uintx/2, Metaspace::reserve_alignment_words());
 500   if (value > aligned_max) {
 501     CommandLineError::print(verbose,
 502                             "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
 503                             "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
 504                             value, aligned_max);
 505     return Flag::VIOLATES_CONSTRAINT;
 506   }
 507   return Flag::SUCCESS;
 508 }
 509 
 510 // To avoid an overflow by 'align_size_up(value, alignment).
 511 static Flag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
 512   size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
 513   if (value > aligned_max) {
 514     CommandLineError::print(verbose,
 515                             "%s (" SIZE_FORMAT ") must be "
 516                             "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
 517                             name, value, aligned_max);
 518     return Flag::VIOLATES_CONSTRAINT;
 519   }
 520   return Flag::SUCCESS;
 521 }
 522 
 523 static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
 524   // For G1 GC, we don't know until G1CollectorPolicy is created.
 525   size_t heap_alignment;
 526 
 527 #if INCLUDE_ALL_GCS
 528   if (UseG1GC) {
 529     heap_alignment = HeapRegionBounds::max_size();
 530   } else
 531 #endif
 532   {
 533     heap_alignment = CollectorPolicy::compute_heap_alignment();
 534   }
 535 
 536   return MaxSizeForAlignment(name, value, heap_alignment, verbose);









 537 }
 538 
 539 Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
 540   return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
 541 }
 542 
 543 Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
 544   Flag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
 545 
 546   if (status == Flag::SUCCESS) {
 547     status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
 548   }
 549   return status;
 550 }
 551 
 552 Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
 553   return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
 554 }
 555 
 556 Flag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbose) {
 557   if (UseNUMA && UseNUMAInterleaving) {
 558     size_t min_interleave_granularity = UseLargePages ? os::large_page_size() : os::vm_allocation_granularity();
 559     return MaxSizeForAlignment("NUMAInterleaveGranularity", value, min_interleave_granularity, verbose);
 560   } else {
 561     return Flag::SUCCESS;
 562   }
 563 }
 564 
 565 Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
 566 #ifdef _LP64
 567 #if INCLUDE_ALL_GCS
 568   // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length
 569   // when the value to be assigned exceeds uint range.
 570   // i.e. result of '(uint)(NewSize / region size(1~32MB))'
 571   // So maximum of NewSize should be 'max_juint * 1M'
 572   if (UseG1GC && (value > (max_juint * 1 * M))) {
 573     CommandLineError::print(verbose,
 574                             "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n",
 575                             value);
 576     return Flag::VIOLATES_CONSTRAINT;
 577   }
 578 #endif // INCLUDE_ALL_GCS
 579 #endif // _LP64
 580   return Flag::SUCCESS;
 581 }
 582 
 583 Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
 584   // At least, alignment reserve area is needed.


 591   } else {
 592     return Flag::SUCCESS;
 593   }
 594 }
 595 
 596 Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
 597   // Skip for default value of zero which means set ergonomically.
 598   if (FLAG_IS_CMDLINE(TLABSize)) {
 599     if (value < MinTLABSize) {
 600       CommandLineError::print(verbose,
 601                               "TLABSize (" SIZE_FORMAT ") must be "
 602                               "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
 603                               value, MinTLABSize);
 604       return Flag::VIOLATES_CONSTRAINT;
 605     }
 606     if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
 607       CommandLineError::print(verbose,
 608                               "TLABSize (" SIZE_FORMAT ") must be "
 609                               "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
 610                               value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
 611       return Flag::VIOLATES_CONSTRAINT;
 612     }
 613   }
 614   return Flag::SUCCESS;
 615 }
 616 
 617 // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
 618 // so AfterMemoryInit type is enough to check.
 619 Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
 620   if (UseTLAB) {
 621     size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
 622 
 623     // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
 624     if (refill_waste_limit > (max_uintx - value)) {
 625       CommandLineError::print(verbose,
 626                               "TLABWasteIncrement (" UINTX_FORMAT ") must be "
 627                               "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
 628                               value, (max_uintx - refill_waste_limit));
 629       return Flag::VIOLATES_CONSTRAINT;
 630     }
 631   }
 632   return Flag::SUCCESS;
 633 }
 634 
 635 Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
 636   if (FLAG_IS_CMDLINE(SurvivorRatio) &&
 637       (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
 638     CommandLineError::print(verbose,
 639                             "SurvivorRatio (" UINTX_FORMAT ") must be "
 640                             "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
 641                             value,
 642                             (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
 643     return Flag::VIOLATES_CONSTRAINT;
 644   } else {
 645     return Flag::SUCCESS;
 646   }
 647 }
 648 


< prev index next >