# HG changeset patch # User jmasa # Date 1429122636 25200 # Wed Apr 15 11:30:36 2015 -0700 # Node ID e29d04389fbbe05a544df379597e924930c001f1 # Parent c8c884c4313b539dd45f0d549d5ad2b794b43d5e 7012980: PSOldGen is increased if there is no space in Metaspace Reviewed-by: diff --git a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp @@ -130,8 +130,7 @@ // Update the pause time. _major_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || - UseAdaptiveSizePolicyWithSystemGC) { + if (should_update_promo_stats(gc_cause)) { double major_pause_in_seconds = _major_timer.seconds(); double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS; diff --git a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -272,8 +272,7 @@ // Don't check if the size_policy is ready here. Let // the size_policy check that internally. if (UseAdaptiveGenerationSizePolicyAtMajorCollection && - ((gc_cause != GCCause::_java_lang_system_gc) || - UseAdaptiveSizePolicyWithSystemGC)) { + AdaptiveSizePolicy::should_update_promo_stats(gc_cause)) { // Swap the survivor spaces if from_space is empty. The // resize_young_gen() called below is normally used after // a successful young GC and swapping of survivor spaces; diff --git a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2090,8 +2090,7 @@ // Don't check if the size_policy is ready here. Let // the size_policy check that internally. if (UseAdaptiveGenerationSizePolicyAtMajorCollection && - ((gc_cause != GCCause::_java_lang_system_gc) || - UseAdaptiveSizePolicyWithSystemGC)) { + AdaptiveSizePolicy::should_update_promo_stats(gc_cause)) { // Swap the survivor spaces if from_space is empty. The // resize_young_gen() called below is normally used after // a successful young GC and swapping of survivor spaces; diff --git a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -290,8 +290,7 @@ AdaptiveSizePolicyOutput(size_policy, heap->total_collections()); - if ((gc_cause != GCCause::_java_lang_system_gc) || - UseAdaptiveSizePolicyWithSystemGC) { + if (AdaptiveSizePolicy::should_update_promo_stats(gc_cause)) { // Gather the feedback data for eden occupancy. young_gen->eden_space()->accumulate_statistics(); } @@ -560,9 +559,7 @@ // Don't check if the size_policy is ready at this // level. Let the size_policy check that internally. if (UseAdaptiveGenerationSizePolicyAtMinorCollection && - ((gc_cause != GCCause::_java_lang_system_gc) || - UseAdaptiveSizePolicyWithSystemGC)) { - + (AdaptiveSizePolicy::should_update_promo_stats(gc_cause))) { // Calculate optimal free space amounts assert(young_gen->max_size() > young_gen->from_space()->capacity_in_bytes() + diff --git a/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp b/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp --- a/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp +++ b/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp @@ -487,6 +487,12 @@ GCCause::Cause gc_cause, CollectorPolicy* collector_policy); + static bool should_update_promo_stats(GCCause::Cause cause) { + return ((cause == GCCause::_java_lang_system_gc && + UseAdaptiveSizePolicyWithSystemGC) || + GCCause::is_tenured_allocation_failure_gc(cause)); + } + // Printing support virtual bool print_adaptive_size_policy_on(outputStream* st) const; bool print_adaptive_size_policy_on(outputStream* st, diff --git a/src/share/vm/gc_interface/gcCause.hpp b/src/share/vm/gc_interface/gcCause.hpp --- a/src/share/vm/gc_interface/gcCause.hpp +++ b/src/share/vm/gc_interface/gcCause.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2015, 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,6 +89,16 @@ cause == GCCause::_heap_dump); } + inline static bool is_tenured_allocation_failure_gc(GCCause::Cause cause) { + assert(cause != GCCause::_old_generation_too_full_to_scavenge && + cause != GCCause::_old_generation_expanded_on_last_scavenge, + err_msg("This GCCause may be correct but is not expected yet: %s", + to_string(cause))); + return (cause == GCCause::_tenured_generation_full || + cause == GCCause::_cms_generation_full || + cause == GCCause::_adaptive_size_policy); + } + // Return a string describing the GCCause. static const char* to_string(GCCause::Cause cause); };