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

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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class ShenandoahAllocRequest : StackObj {
return _alloc_type;
}

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

inline size_t min_size() {
assert (is_lab_alloc(), "Only access for LAB allocs");
return _min_size;
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
Original file line number Diff line number Diff line change
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();

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

if (try_set_alloc_failure_gc()) {
// Only report the first allocation failure
log_info(gc)("Failed to allocate " SIZE_FORMAT "%s",
byte_size_in_proper_unit(words * HeapWordSize), proper_unit_for_byte_size(words * HeapWordSize));
log_info(gc)("Failed to allocate %s, " SIZE_FORMAT "%s",
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
heap->cancel_gc(GCCause::_allocation_failure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ShenandoahControlThread: public ConcurrentGCThread {

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

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

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

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

Expand Down

0 comments on commit 6570425

Please sign in to comment.