7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently

Tue, 18 Sep 2012 14:15:06 -0700

author
jmasa
date
Tue, 18 Sep 2012 14:15:06 -0700
changeset 4064
8da5e203b993
parent 4063
9646b7ff4d14
child 4065
8fbf05030e24

7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
Reviewed-by: johnc, ysr

src/share/vm/gc_implementation/shared/vmGCOperations.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/collectorPolicy.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/metaspace.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/metaspace.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Mon Sep 17 10:33:13 2012 +0200
     1.2 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Tue Sep 18 14:15:06 2012 -0700
     1.3 @@ -230,15 +230,9 @@
     1.4        // amount of the expansion.
     1.5        // This should work unless there really is no more space
     1.6        // or a MaxMetaspaceSize has been specified on the command line.
     1.7 -      MetaspaceGC::set_expand_after_GC(true);
     1.8 -      size_t before_inc = MetaspaceGC::capacity_until_GC();
     1.9 -      size_t delta_words = MetaspaceGC::delta_capacity_until_GC(_size);
    1.10 -      MetaspaceGC::inc_capacity_until_GC(delta_words);
    1.11 -      if (PrintGCDetails && Verbose) {
    1.12 -        gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
    1.13 -          " to " SIZE_FORMAT, before_inc, MetaspaceGC::capacity_until_GC());
    1.14 -  }
    1.15 -      _result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype);
    1.16 +      _result =
    1.17 +        _loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype);
    1.18 +
    1.19        if (do_cms_concurrent && _result == NULL) {
    1.20          // Rather than fail with a metaspace out-of-memory, do a full
    1.21          // GC for CMS.
     2.1 --- a/src/share/vm/memory/collectorPolicy.cpp	Mon Sep 17 10:33:13 2012 +0200
     2.2 +++ b/src/share/vm/memory/collectorPolicy.cpp	Tue Sep 18 14:15:06 2012 -0700
     2.3 @@ -743,6 +743,36 @@
     2.4    uint full_gc_count = 0;
     2.5  
     2.6    do {
     2.7 +    MetaWord* result = NULL;
     2.8 +    if (GC_locker::is_active_and_needs_gc()) {
     2.9 +      // If the GC_locker is active, just expand and allocate.
    2.10 +      // If that does not succeed, wait if this thread is not
    2.11 +      // in a critical section itself.
    2.12 +      result =
    2.13 +        loader_data->metaspace_non_null()->expand_and_allocate(word_size,
    2.14 +                                                               mdtype);
    2.15 +      if (result != NULL) {
    2.16 +        return result;
    2.17 +      }
    2.18 +      JavaThread* jthr = JavaThread::current();
    2.19 +      if (!jthr->in_critical()) {
    2.20 +        MutexUnlocker mul(Heap_lock);
    2.21 +        // Wait for JNI critical section to be exited
    2.22 +        GC_locker::stall_until_clear();
    2.23 +        // The GC invoked by the last thread leaving the critical
    2.24 +        // section will be a young collection and a full collection
    2.25 +        // is (currently) needed for unloading classes so continue
    2.26 +        // to the next iteration to get a full GC.
    2.27 +        continue;
    2.28 +      } else {
    2.29 +        if (CheckJNICalls) {
    2.30 +          fatal("Possible deadlock due to allocating while"
    2.31 +                " in jni critical section");
    2.32 +        }
    2.33 +        return NULL;
    2.34 +      }
    2.35 +    }
    2.36 +
    2.37      {  // Need lock to get self consistent gc_count's
    2.38        MutexLocker ml(Heap_lock);
    2.39        gc_count      = Universe::heap()->total_collections();
     3.1 --- a/src/share/vm/memory/metaspace.cpp	Mon Sep 17 10:33:13 2012 +0200
     3.2 +++ b/src/share/vm/memory/metaspace.cpp	Tue Sep 18 14:15:06 2012 -0700
     3.3 @@ -2843,6 +2843,21 @@
     3.4    }
     3.5  }
     3.6  
     3.7 +MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) {
     3.8 +  MetaWord* result;
     3.9 +  MetaspaceGC::set_expand_after_GC(true);
    3.10 +  size_t before_inc = MetaspaceGC::capacity_until_GC();
    3.11 +  size_t delta_words = MetaspaceGC::delta_capacity_until_GC(word_size);
    3.12 +  MetaspaceGC::inc_capacity_until_GC(delta_words);
    3.13 +  if (PrintGCDetails && Verbose) {
    3.14 +    gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
    3.15 +      " to " SIZE_FORMAT, before_inc, MetaspaceGC::capacity_until_GC());
    3.16 +  }
    3.17 +  result = allocate(word_size, mdtype);
    3.18 +
    3.19 +  return result;
    3.20 +}
    3.21 +
    3.22  // Space allocated in the Metaspace.  This may
    3.23  // be across several metadata virtual spaces.
    3.24  char* Metaspace::bottom() const {
     4.1 --- a/src/share/vm/memory/metaspace.hpp	Mon Sep 17 10:33:13 2012 +0200
     4.2 +++ b/src/share/vm/memory/metaspace.hpp	Tue Sep 18 14:15:06 2012 -0700
     4.3 @@ -130,8 +130,10 @@
     4.4  
     4.5    static MetaWord* allocate(ClassLoaderData* loader_data, size_t size,
     4.6                              bool read_only, MetadataType mdtype, TRAPS);
     4.7 +  void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
     4.8  
     4.9 -  void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
    4.10 +  MetaWord* expand_and_allocate(size_t size,
    4.11 +                                MetadataType mdtype);
    4.12  
    4.13  #ifndef PRODUCT
    4.14    bool contains(const void *ptr) const;

mercurial