--- old/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-07 23:53:13.682596697 -0800 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp 2016-03-07 23:53:13.590596700 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectorPolicy.hpp" +#include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/threadLocalAllocBuffer.hpp" #include "runtime/arguments.hpp" #include "runtime/commandLineFlagConstraintsGC.hpp" @@ -446,6 +447,22 @@ } #endif return Flag::SUCCESS; +} + +Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) { +#if INCLUDE_ALL_GCS + if (UseConcMarkSweepGC) { + size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity(); + if (value > max_uintx - max_capacity) { + CommandLineError::print(verbose, + "CMSSamplingGrain (" UINTX_FORMAT ") must be " + "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n", + value, max_uintx - max_capacity); + return Flag::VIOLATES_CONSTRAINT; + } + } +#endif + return Flag::SUCCESS; } Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) { --- old/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp 2016-03-07 23:53:14.094596682 -0800 +++ new/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp 2016-03-07 23:53:13.994596686 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,6 +61,7 @@ Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose); Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose); Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose); +Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose); Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose); Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose); Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose); --- old/src/share/vm/runtime/globals.hpp 2016-03-07 23:53:14.518596667 -0800 +++ new/src/share/vm/runtime/globals.hpp 2016-03-07 23:53:14.378596672 -0800 @@ -1904,7 +1904,8 @@ \ product(uintx, CMSSamplingGrain, 16*K, \ "The minimum distance between eden samples for CMS (see above)") \ - range(1, max_uintx) \ + range(ObjectAlignmentInBytes, max_uintx) \ + constraint(CMSSamplingGrainConstraintFunc,AfterMemoryInit) \ \ product(bool, CMSScavengeBeforeRemark, false, \ "Attempt scavenge before the CMS remark step") \ --- old/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2016-03-07 23:53:15.030596650 -0800 +++ new/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2016-03-07 23:53:14.934596653 -0800 @@ -121,6 +121,7 @@ * and would affect other tests that run in parallel. */ excludeTestMaxRange("ConcGCThreads"); + excludeTestMaxRange("CMSSamplingGrain"); excludeTestMaxRange("G1ConcRefinementThreads"); excludeTestMaxRange("G1RSetRegionEntries"); excludeTestMaxRange("G1RSetSparseRegionEntries");