8242040: Shenandoah: print allocation failure type

Reviewed-by: rkennke
This commit is contained in:
Aleksey Shipilev 2020-04-02 20:10:59 +02:00
parent 5532b27d22
commit 6570425dc4
4 changed files with 11 additions and 6 deletions

View file

@ -95,6 +95,10 @@ public:
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;

View file

@ -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);

View file

@ -115,7 +115,7 @@ public:
// 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.

View file

@ -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);
} }