src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp
changeset 49982 9042ffe5b7fe
parent 49902 3661f31c6df4
child 50289 0195ee80e530
child 56532 a594484f54db
equal deleted inserted replaced
49981:bd0a95bec96b 49982:9042ffe5b7fe
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/shared/collectedHeap.hpp"
    26 #include "gc/shared/collectedHeap.hpp"
    27 #include "gc/shared/collectorPolicy.hpp"
    27 #include "gc/shared/collectorPolicy.hpp"
       
    28 #include "gc/shared/gcConfig.hpp"
    28 #include "gc/shared/jvmFlagConstraintsGC.hpp"
    29 #include "gc/shared/jvmFlagConstraintsGC.hpp"
    29 #include "gc/shared/plab.hpp"
    30 #include "gc/shared/plab.hpp"
    30 #include "gc/shared/threadLocalAllocBuffer.hpp"
    31 #include "gc/shared/threadLocalAllocBuffer.hpp"
    31 #include "runtime/arguments.hpp"
    32 #include "runtime/arguments.hpp"
    32 #include "runtime/flags/jvmFlagRangeList.hpp"
    33 #include "runtime/flags/jvmFlagRangeList.hpp"
    34 #include "runtime/globals_extension.hpp"
    35 #include "runtime/globals_extension.hpp"
    35 #include "runtime/thread.inline.hpp"
    36 #include "runtime/thread.inline.hpp"
    36 #include "utilities/align.hpp"
    37 #include "utilities/align.hpp"
    37 #include "utilities/defaultStream.hpp"
    38 #include "utilities/defaultStream.hpp"
    38 #include "utilities/macros.hpp"
    39 #include "utilities/macros.hpp"
    39 #if INCLUDE_ALL_GCS
    40 #if INCLUDE_CMSGC
    40 #include "gc/cms/jvmFlagConstraintsCMS.hpp"
    41 #include "gc/cms/jvmFlagConstraintsCMS.hpp"
       
    42 #endif
       
    43 #if INCLUDE_G1GC
    41 #include "gc/g1/jvmFlagConstraintsG1.hpp"
    44 #include "gc/g1/jvmFlagConstraintsG1.hpp"
       
    45 #endif
       
    46 #if INCLUDE_PARALLELGC
    42 #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
    47 #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
    43 #endif
    48 #endif
    44 #ifdef COMPILER1
    49 #ifdef COMPILER1
    45 #include "c1/c1_globals.hpp"
    50 #include "c1/c1_globals.hpp"
    46 #endif // COMPILER1
    51 #endif // COMPILER1
    58 
    63 
    59 // As ParallelGCThreads differs among GC modes, we need constraint function.
    64 // As ParallelGCThreads differs among GC modes, we need constraint function.
    60 JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
    65 JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
    61   JVMFlag::Error status = JVMFlag::SUCCESS;
    66   JVMFlag::Error status = JVMFlag::SUCCESS;
    62 
    67 
    63 #if INCLUDE_ALL_GCS
    68 #if INCLUDE_PARALLELGC
    64   status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
    69   status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
    65   if (status != JVMFlag::SUCCESS) {
    70   if (status != JVMFlag::SUCCESS) {
    66     return status;
    71     return status;
    67   }
    72   }
    68 
    73 #endif
       
    74 
       
    75 #if INCLUDE_CMSGC
    69   status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
    76   status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
    70   if (status != JVMFlag::SUCCESS) {
    77   if (status != JVMFlag::SUCCESS) {
    71     return status;
    78     return status;
    72   }
    79   }
    73 #endif
    80 #endif
    76 }
    83 }
    77 
    84 
    78 // As ConcGCThreads should be smaller than ParallelGCThreads,
    85 // As ConcGCThreads should be smaller than ParallelGCThreads,
    79 // we need constraint function.
    86 // we need constraint function.
    80 JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
    87 JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
    81 #if INCLUDE_ALL_GCS
       
    82   // CMS and G1 GCs use ConcGCThreads.
    88   // CMS and G1 GCs use ConcGCThreads.
    83   if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) {
    89   if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
       
    90        GCConfig::is_gc_selected(CollectedHeap::G1)) && (value > ParallelGCThreads)) {
    84     CommandLineError::print(verbose,
    91     CommandLineError::print(verbose,
    85                             "ConcGCThreads (" UINT32_FORMAT ") must be "
    92                             "ConcGCThreads (" UINT32_FORMAT ") must be "
    86                             "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
    93                             "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
    87                             value, ParallelGCThreads);
    94                             value, ParallelGCThreads);
    88     return JVMFlag::VIOLATES_CONSTRAINT;
    95     return JVMFlag::VIOLATES_CONSTRAINT;
    89   }
    96   }
    90 #endif
    97 
    91   return JVMFlag::SUCCESS;
    98   return JVMFlag::SUCCESS;
    92 }
    99 }
    93 
   100 
    94 static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
   101 static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
    95 #if INCLUDE_ALL_GCS
   102   if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
    96   if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
   103        GCConfig::is_gc_selected(CollectedHeap::G1)  ||
       
   104        GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value < PLAB::min_size())) {
    97     CommandLineError::print(verbose,
   105     CommandLineError::print(verbose,
    98                             "%s (" SIZE_FORMAT ") must be "
   106                             "%s (" SIZE_FORMAT ") must be "
    99                             "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
   107                             "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
   100                             name, value, PLAB::min_size());
   108                             name, value, PLAB::min_size());
   101     return JVMFlag::VIOLATES_CONSTRAINT;
   109     return JVMFlag::VIOLATES_CONSTRAINT;
   102   }
   110   }
   103 #endif // INCLUDE_ALL_GCS
   111 
   104   return JVMFlag::SUCCESS;
   112   return JVMFlag::SUCCESS;
   105 }
   113 }
   106 
   114 
   107 JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
   115 JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
   108 #if INCLUDE_ALL_GCS
   116   if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
   109   if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
   117        GCConfig::is_gc_selected(CollectedHeap::G1)  ||
       
   118        GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value > PLAB::max_size())) {
   110     CommandLineError::print(verbose,
   119     CommandLineError::print(verbose,
   111                             "%s (" SIZE_FORMAT ") must be "
   120                             "%s (" SIZE_FORMAT ") must be "
   112                             "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
   121                             "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
   113                             name, value, PLAB::max_size());
   122                             name, value, PLAB::max_size());
   114     return JVMFlag::VIOLATES_CONSTRAINT;
   123     return JVMFlag::VIOLATES_CONSTRAINT;
   115   }
   124   }
   116 #endif // INCLUDE_ALL_GCS
   125 
   117   return JVMFlag::SUCCESS;
   126   return JVMFlag::SUCCESS;
   118 }
   127 }
   119 
   128 
   120 static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
   129 static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
   121   JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
   130   JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
   131 }
   140 }
   132 
   141 
   133 JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
   142 JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
   134   JVMFlag::Error status = JVMFlag::SUCCESS;
   143   JVMFlag::Error status = JVMFlag::SUCCESS;
   135 
   144 
   136 #if INCLUDE_ALL_GCS
   145 #if INCLUDE_CMSGC
   137   if (UseConcMarkSweepGC) {
   146   if (UseConcMarkSweepGC) {
   138     return OldPLABSizeConstraintFuncCMS(value, verbose);
   147     return OldPLABSizeConstraintFuncCMS(value, verbose);
   139   } else {
   148   } else
       
   149 #endif
       
   150   {
   140     status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
   151     status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
   141   }
   152   }
   142 #endif
   153 
   143   return status;
   154   return status;
   144 }
   155 }
   145 
   156 
   146 JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
   157 JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
   147   if (value > MaxHeapFreeRatio) {
   158   if (value > MaxHeapFreeRatio) {
   219     return JVMFlag::SUCCESS;
   230     return JVMFlag::SUCCESS;
   220   }
   231   }
   221 }
   232 }
   222 
   233 
   223 JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
   234 JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
   224 #if INCLUDE_ALL_GCS
   235 #if INCLUDE_PARALLELGC
   225   JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
   236   JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
   226   if (status != JVMFlag::SUCCESS) {
   237   if (status != JVMFlag::SUCCESS) {
   227     return status;
   238     return status;
   228   }
   239   }
   229 #endif
   240 #endif
   230 
   241 
   231   return JVMFlag::SUCCESS;
   242   return JVMFlag::SUCCESS;
   232 }
   243 }
   233 
   244 
   234 JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
   245 JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
   235 #if INCLUDE_ALL_GCS
   246 #if INCLUDE_PARALLELGC
   236   JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
   247   JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
   237   if (status != JVMFlag::SUCCESS) {
   248   if (status != JVMFlag::SUCCESS) {
   238     return status;
   249     return status;
   239   }
   250   }
   240 #endif
   251 #endif
   251   }
   262   }
   252   return JVMFlag::SUCCESS;
   263   return JVMFlag::SUCCESS;
   253 }
   264 }
   254 
   265 
   255 JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
   266 JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
   256 #if INCLUDE_ALL_GCS
   267 #if INCLUDE_G1GC
   257   JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
   268   JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
   258   if (status != JVMFlag::SUCCESS) {
   269   if (status != JVMFlag::SUCCESS) {
   259     return status;
   270     return status;
   260   }
   271   }
   261 #endif
   272 #endif
   262 
   273 
   263   return JVMFlag::SUCCESS;
   274   return JVMFlag::SUCCESS;
   264 }
   275 }
   265 
   276 
   266 JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
   277 JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
   267 #if INCLUDE_ALL_GCS
   278 #if INCLUDE_G1GC
   268   JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
   279   JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
   269   if (status != JVMFlag::SUCCESS) {
   280   if (status != JVMFlag::SUCCESS) {
   270     return status;
   281     return status;
   271   }
   282   }
   272 #endif
   283 #endif
   300 }
   311 }
   301 
   312 
   302 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
   313 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
   303   size_t heap_alignment;
   314   size_t heap_alignment;
   304 
   315 
   305 #if INCLUDE_ALL_GCS
   316 #if INCLUDE_G1GC
   306   if (UseG1GC) {
   317   if (UseG1GC) {
   307     // For G1 GC, we don't know until G1CollectorPolicy is created.
   318     // For G1 GC, we don't know until G1CollectorPolicy is created.
   308     heap_alignment = MaxSizeForHeapAlignmentG1();
   319     heap_alignment = MaxSizeForHeapAlignmentG1();
   309   } else
   320   } else
   310 #endif
   321 #endif
   341 
   352 
   342   return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
   353   return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
   343 }
   354 }
   344 
   355 
   345 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
   356 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
   346 #if INCLUDE_ALL_GCS
   357 #if INCLUDE_G1GC
   347   JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
   358   JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
   348   if (status != JVMFlag::SUCCESS) {
   359   if (status != JVMFlag::SUCCESS) {
   349     return status;
   360     return status;
   350   }
   361   }
   351 #endif
   362 #endif