Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8242040: Shenandoah: print allocation failure type
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke
  • Loading branch information
shipilev committed Apr 2, 2020
1 parent 5532b27 commit 6570425
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahAllocRequest.hpp
Expand Up @@ -95,6 +95,10 @@ class ShenandoahAllocRequest : StackObj {
return _alloc_type; return _alloc_type;
} }


inline const char* type_string() {
return alloc_type_to_string(_alloc_type);
}

inline size_t min_size() { inline size_t min_size() {
assert (is_lab_alloc(), "Only access for LAB allocs"); assert (is_lab_alloc(), "Only access for LAB allocs");
return _min_size; return _min_size;
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
Expand Up @@ -506,15 +506,16 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) {
} }
} }


void ShenandoahControlThread::handle_alloc_failure(size_t words) { void ShenandoahControlThread::handle_alloc_failure(ShenandoahAllocRequest& req) {
ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahHeap* heap = ShenandoahHeap::heap();


assert(current()->is_Java_thread(), "expect Java thread here"); assert(current()->is_Java_thread(), "expect Java thread here");


if (try_set_alloc_failure_gc()) { if (try_set_alloc_failure_gc()) {
// Only report the first allocation failure // Only report the first allocation failure
log_info(gc)("Failed to allocate " SIZE_FORMAT "%s", log_info(gc)("Failed to allocate %s, " SIZE_FORMAT "%s",
byte_size_in_proper_unit(words * HeapWordSize), proper_unit_for_byte_size(words * HeapWordSize)); req.type_string(),
byte_size_in_proper_unit(req.size() * HeapWordSize), proper_unit_for_byte_size(req.size() * HeapWordSize));


// Now that alloc failure GC is scheduled, we can abort everything else // Now that alloc failure GC is scheduled, we can abort everything else
heap->cancel_gc(GCCause::_allocation_failure); heap->cancel_gc(GCCause::_allocation_failure);
Expand Down
Expand Up @@ -115,7 +115,7 @@ class ShenandoahControlThread: public ConcurrentGCThread {


// Handle allocation failure from normal allocation. // Handle allocation failure from normal allocation.
// Blocks until memory is available. // Blocks until memory is available.
void handle_alloc_failure(size_t words); void handle_alloc_failure(ShenandoahAllocRequest& req);


// Handle allocation failure from evacuation path. // Handle allocation failure from evacuation path.
// Optionally blocks while collector is handling the failure. // Optionally blocks while collector is handling the failure.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Expand Up @@ -821,13 +821,13 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) {


while (result == NULL && _progress_last_gc.is_set()) { while (result == NULL && _progress_last_gc.is_set()) {
tries++; tries++;
control_thread()->handle_alloc_failure(req.size()); control_thread()->handle_alloc_failure(req);
result = allocate_memory_under_lock(req, in_new_region); result = allocate_memory_under_lock(req, in_new_region);
} }


while (result == NULL && tries <= ShenandoahFullGCThreshold) { while (result == NULL && tries <= ShenandoahFullGCThreshold) {
tries++; tries++;
control_thread()->handle_alloc_failure(req.size()); control_thread()->handle_alloc_failure(req);
result = allocate_memory_under_lock(req, in_new_region); result = allocate_memory_under_lock(req, in_new_region);
} }


Expand Down

0 comments on commit 6570425

Please sign in to comment.