mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8152176: Big ParGCCardsPerStrideChunk values can cause overflow for CMS GC
Limit the max value of ParGCCardsPerStrideChunk based on card table size and other stride flags Reviewed-by: jmasa, tbenson
This commit is contained in:
parent
c3469071aa
commit
a868617af7
4 changed files with 44 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
|
@ -89,14 +89,6 @@ class CardTableModRefBS: public ModRefBarrierSet {
|
|||
MemRegion _guard_region;
|
||||
|
||||
protected:
|
||||
// Initialization utilities; covered_words is the size of the covered region
|
||||
// in, um, words.
|
||||
inline size_t cards_required(size_t covered_words) {
|
||||
// Add one for a guard card, used to detect errors.
|
||||
const size_t words = align_size_up(covered_words, card_size_in_words);
|
||||
return words / card_size_in_words + 1;
|
||||
}
|
||||
|
||||
inline size_t compute_byte_map_size();
|
||||
|
||||
// Finds and return the index of the region, if any, to which the given
|
||||
|
@ -172,6 +164,14 @@ public:
|
|||
|
||||
bool has_write_ref_pre_barrier() { return false; }
|
||||
|
||||
// Initialization utilities; covered_words is the size of the covered region
|
||||
// in, um, words.
|
||||
inline size_t cards_required(size_t covered_words) {
|
||||
// Add one for a guard card, used to detect errors.
|
||||
const size_t words = align_size_up(covered_words, card_size_in_words);
|
||||
return words / card_size_in_words + 1;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti);
|
||||
|
|
|
@ -382,6 +382,39 @@ Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
|
|||
return Flag::SUCCESS;
|
||||
}
|
||||
|
||||
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
|
||||
#if INCLUDE_ALL_GCS
|
||||
if (UseConcMarkSweepGC) {
|
||||
// ParGCCardsPerStrideChunk should be compared with card table size.
|
||||
size_t heap_size = Universe::heap()->reserved_region().word_size();
|
||||
CardTableModRefBS* bs = (CardTableModRefBS*)GenCollectedHeap::heap()->rem_set()->bs();
|
||||
size_t card_table_size = bs->cards_required(heap_size) - 1; // Valid card table size
|
||||
|
||||
if ((size_t)value > card_table_size) {
|
||||
CommandLineError::print(verbose,
|
||||
"ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
|
||||
"must be less than or equal to card table size (" SIZE_FORMAT ")\n",
|
||||
value, card_table_size);
|
||||
return Flag::VIOLATES_CONSTRAINT;
|
||||
}
|
||||
|
||||
// ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
|
||||
// from CardTableModRefBSForCTRS::process_stride(). Note that ParGCStridesPerThread is already checked
|
||||
// not to make an overflow with ParallelGCThreads from its constraint function.
|
||||
uintx n_strides = ParallelGCThreads * ParGCStridesPerThread;
|
||||
uintx ergo_max = max_uintx / n_strides;
|
||||
if ((uintx)value > ergo_max) {
|
||||
CommandLineError::print(verbose,
|
||||
"ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
|
||||
"less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
|
||||
value, ergo_max);
|
||||
return Flag::VIOLATES_CONSTRAINT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Flag::SUCCESS;
|
||||
}
|
||||
|
||||
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
|
||||
Flag::Error status = Flag::SUCCESS;
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose);
|
|||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose);
|
||||
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose);
|
||||
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose);
|
||||
Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose);
|
||||
Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose);
|
||||
|
|
|
@ -1629,6 +1629,7 @@ public:
|
|||
"The number of cards in each chunk of the parallel chunks used " \
|
||||
"during card table scanning") \
|
||||
range(1, max_intx) \
|
||||
constraint(ParGCCardsPerStrideChunkConstraintFunc,AfterMemoryInit)\
|
||||
\
|
||||
product(uintx, OldPLABWeight, 50, \
|
||||
"Percentage (0-100) used to weight the current sample when " \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue