8328507: Move StackWatermark code from safepoint cleanup
Reviewed-by: aboldtch, coleenp
This commit is contained in:
parent
2af0312c95
commit
aa595dbda4
@ -347,11 +347,6 @@ protected:
|
|||||||
// collection or expansion activity.
|
// collection or expansion activity.
|
||||||
virtual size_t unsafe_max_tlab_alloc(Thread *thr) const = 0;
|
virtual size_t unsafe_max_tlab_alloc(Thread *thr) const = 0;
|
||||||
|
|
||||||
// If a GC uses a stack watermark barrier, the stack processing is lazy, concurrent,
|
|
||||||
// incremental and cooperative. In order for that to work well, mechanisms that stop
|
|
||||||
// another thread might want to ensure its roots are in a sane state.
|
|
||||||
virtual bool uses_stack_watermark_barrier() const { return false; }
|
|
||||||
|
|
||||||
// Perform a collection of the heap; intended for use in implementing
|
// Perform a collection of the heap; intended for use in implementing
|
||||||
// "System.gc". This probably implies as full a collection as the
|
// "System.gc". This probably implies as full a collection as the
|
||||||
// "CollectedHeap" supports.
|
// "CollectedHeap" supports.
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
#include "runtime/java.hpp"
|
#include "runtime/java.hpp"
|
||||||
#include "runtime/orderAccess.hpp"
|
#include "runtime/orderAccess.hpp"
|
||||||
#include "runtime/safepointMechanism.hpp"
|
#include "runtime/safepointMechanism.hpp"
|
||||||
|
#include "runtime/stackWatermarkSet.hpp"
|
||||||
#include "runtime/vmThread.hpp"
|
#include "runtime/vmThread.hpp"
|
||||||
#include "utilities/events.hpp"
|
#include "utilities/events.hpp"
|
||||||
#include "utilities/powerOfTwo.hpp"
|
#include "utilities/powerOfTwo.hpp"
|
||||||
@ -2302,6 +2303,7 @@ bool ShenandoahHeap::uncommit_bitmap_slice(ShenandoahHeapRegion *r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahHeap::safepoint_synchronize_begin() {
|
void ShenandoahHeap::safepoint_synchronize_begin() {
|
||||||
|
StackWatermarkSet::safepoint_synchronize_begin();
|
||||||
SuspendibleThreadSet::synchronize();
|
SuspendibleThreadSet::synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
|
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -539,11 +539,6 @@ public:
|
|||||||
void sync_pinned_region_status();
|
void sync_pinned_region_status();
|
||||||
void assert_pinned_region_status() NOT_DEBUG_RETURN;
|
void assert_pinned_region_status() NOT_DEBUG_RETURN;
|
||||||
|
|
||||||
// ---------- Concurrent Stack Processing support
|
|
||||||
//
|
|
||||||
public:
|
|
||||||
bool uses_stack_watermark_barrier() const override { return true; }
|
|
||||||
|
|
||||||
// ---------- Allocation support
|
// ---------- Allocation support
|
||||||
//
|
//
|
||||||
private:
|
private:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,7 @@
|
|||||||
#include "memory/universe.hpp"
|
#include "memory/universe.hpp"
|
||||||
#include "oops/stackChunkOop.hpp"
|
#include "oops/stackChunkOop.hpp"
|
||||||
#include "runtime/continuationJavaClasses.hpp"
|
#include "runtime/continuationJavaClasses.hpp"
|
||||||
|
#include "runtime/stackWatermarkSet.hpp"
|
||||||
#include "utilities/align.hpp"
|
#include "utilities/align.hpp"
|
||||||
|
|
||||||
XCollectedHeap* XCollectedHeap::heap() {
|
XCollectedHeap* XCollectedHeap::heap() {
|
||||||
@ -215,10 +216,6 @@ size_t XCollectedHeap::unsafe_max_tlab_alloc(Thread* ignored) const {
|
|||||||
return _heap.unsafe_max_tlab_alloc();
|
return _heap.unsafe_max_tlab_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XCollectedHeap::uses_stack_watermark_barrier() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryUsage XCollectedHeap::memory_usage() {
|
MemoryUsage XCollectedHeap::memory_usage() {
|
||||||
return _heap.serviceability_memory_pool()->get_memory_usage();
|
return _heap.serviceability_memory_pool()->get_memory_usage();
|
||||||
}
|
}
|
||||||
@ -277,6 +274,7 @@ VirtualSpaceSummary XCollectedHeap::create_heap_space_summary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XCollectedHeap::safepoint_synchronize_begin() {
|
void XCollectedHeap::safepoint_synchronize_begin() {
|
||||||
|
StackWatermarkSet::safepoint_synchronize_begin();
|
||||||
SuspendibleThreadSet::synchronize();
|
SuspendibleThreadSet::synchronize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -87,8 +87,6 @@ public:
|
|||||||
size_t max_tlab_size() const override;
|
size_t max_tlab_size() const override;
|
||||||
size_t unsafe_max_tlab_alloc(Thread* thr) const override;
|
size_t unsafe_max_tlab_alloc(Thread* thr) const override;
|
||||||
|
|
||||||
bool uses_stack_watermark_barrier() const override;
|
|
||||||
|
|
||||||
MemoryUsage memory_usage() override;
|
MemoryUsage memory_usage() override;
|
||||||
GrowableArray<GCMemoryManager*> memory_managers() override;
|
GrowableArray<GCMemoryManager*> memory_managers() override;
|
||||||
GrowableArray<MemoryPool*> memory_pools() override;
|
GrowableArray<MemoryPool*> memory_pools() override;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,6 +50,7 @@
|
|||||||
#include "oops/stackChunkOop.hpp"
|
#include "oops/stackChunkOop.hpp"
|
||||||
#include "runtime/continuationJavaClasses.hpp"
|
#include "runtime/continuationJavaClasses.hpp"
|
||||||
#include "runtime/jniHandles.inline.hpp"
|
#include "runtime/jniHandles.inline.hpp"
|
||||||
|
#include "runtime/stackWatermarkSet.hpp"
|
||||||
#include "services/memoryUsage.hpp"
|
#include "services/memoryUsage.hpp"
|
||||||
#include "utilities/align.hpp"
|
#include "utilities/align.hpp"
|
||||||
|
|
||||||
@ -240,10 +241,6 @@ size_t ZCollectedHeap::unsafe_max_tlab_alloc(Thread* ignored) const {
|
|||||||
return _heap.unsafe_max_tlab_alloc();
|
return _heap.unsafe_max_tlab_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZCollectedHeap::uses_stack_watermark_barrier() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryUsage ZCollectedHeap::memory_usage() {
|
MemoryUsage ZCollectedHeap::memory_usage() {
|
||||||
const size_t initial_size = ZHeap::heap()->initial_capacity();
|
const size_t initial_size = ZHeap::heap()->initial_capacity();
|
||||||
const size_t committed = ZHeap::heap()->capacity();
|
const size_t committed = ZHeap::heap()->capacity();
|
||||||
@ -338,6 +335,7 @@ bool ZCollectedHeap::contains_null(const oop* p) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ZCollectedHeap::safepoint_synchronize_begin() {
|
void ZCollectedHeap::safepoint_synchronize_begin() {
|
||||||
|
StackWatermarkSet::safepoint_synchronize_begin();
|
||||||
ZGeneration::young()->synchronize_relocation();
|
ZGeneration::young()->synchronize_relocation();
|
||||||
ZGeneration::old()->synchronize_relocation();
|
ZGeneration::old()->synchronize_relocation();
|
||||||
SuspendibleThreadSet::synchronize();
|
SuspendibleThreadSet::synchronize();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -88,8 +88,6 @@ public:
|
|||||||
size_t max_tlab_size() const override;
|
size_t max_tlab_size() const override;
|
||||||
size_t unsafe_max_tlab_alloc(Thread* thr) const override;
|
size_t unsafe_max_tlab_alloc(Thread* thr) const override;
|
||||||
|
|
||||||
bool uses_stack_watermark_barrier() const override;
|
|
||||||
|
|
||||||
MemoryUsage memory_usage() override;
|
MemoryUsage memory_usage() override;
|
||||||
GrowableArray<GCMemoryManager*> memory_managers() override;
|
GrowableArray<GCMemoryManager*> memory_managers() override;
|
||||||
GrowableArray<MemoryPool*> memory_pools() override;
|
GrowableArray<MemoryPool*> memory_pools() override;
|
||||||
|
@ -510,7 +510,6 @@ void SafepointSynchronize::end() {
|
|||||||
class ParallelCleanupTask : public WorkerTask {
|
class ParallelCleanupTask : public WorkerTask {
|
||||||
private:
|
private:
|
||||||
SubTasksDone _subtasks;
|
SubTasksDone _subtasks;
|
||||||
bool _do_lazy_roots;
|
|
||||||
|
|
||||||
class Tracer {
|
class Tracer {
|
||||||
private:
|
private:
|
||||||
@ -531,35 +530,15 @@ private:
|
|||||||
public:
|
public:
|
||||||
ParallelCleanupTask() :
|
ParallelCleanupTask() :
|
||||||
WorkerTask("Parallel Safepoint Cleanup"),
|
WorkerTask("Parallel Safepoint Cleanup"),
|
||||||
_subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS),
|
_subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS) {}
|
||||||
_do_lazy_roots(!VMThread::vm_operation()->skip_thread_oop_barriers() &&
|
|
||||||
Universe::heap()->uses_stack_watermark_barrier()) {}
|
|
||||||
|
|
||||||
uint expected_num_workers() const {
|
uint expected_num_workers() const {
|
||||||
uint workers = 0;
|
uint workers = 0;
|
||||||
|
|
||||||
if (_do_lazy_roots) {
|
|
||||||
workers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MAX2<uint>(1, workers);
|
return MAX2<uint>(1, workers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void work(uint worker_id) {
|
void work(uint worker_id) {
|
||||||
if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING)) {
|
|
||||||
if (_do_lazy_roots) {
|
|
||||||
Tracer t("lazy partial thread root processing");
|
|
||||||
class LazyRootClosure : public ThreadClosure {
|
|
||||||
public:
|
|
||||||
void do_thread(Thread* thread) {
|
|
||||||
StackWatermarkSet::start_processing(JavaThread::cast(thread), StackWatermarkKind::gc);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LazyRootClosure cl;
|
|
||||||
Threads::java_threads_do(&cl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP)) {
|
if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP)) {
|
||||||
// Don't bother reporting event or time for this very short operation.
|
// Don't bother reporting event or time for this very short operation.
|
||||||
// To have any utility we'd also want to report whether needed.
|
// To have any utility we'd also want to report whether needed.
|
||||||
|
@ -70,7 +70,6 @@ class SafepointSynchronize : AllStatic {
|
|||||||
|
|
||||||
// The enums are listed in the order of the tasks when done serially.
|
// The enums are listed in the order of the tasks when done serially.
|
||||||
enum SafepointCleanupTasks {
|
enum SafepointCleanupTasks {
|
||||||
SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING,
|
|
||||||
SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,
|
SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,
|
||||||
// Leave this one last.
|
// Leave this one last.
|
||||||
SAFEPOINT_CLEANUP_NUM_TASKS
|
SAFEPOINT_CLEANUP_NUM_TASKS
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,6 +31,9 @@
|
|||||||
#include "runtime/safepointMechanism.inline.hpp"
|
#include "runtime/safepointMechanism.inline.hpp"
|
||||||
#include "runtime/stackWatermark.inline.hpp"
|
#include "runtime/stackWatermark.inline.hpp"
|
||||||
#include "runtime/stackWatermarkSet.inline.hpp"
|
#include "runtime/stackWatermarkSet.inline.hpp"
|
||||||
|
#include "runtime/threadSMR.hpp"
|
||||||
|
#include "runtime/vmOperation.hpp"
|
||||||
|
#include "runtime/vmThread.hpp"
|
||||||
#include "utilities/debug.hpp"
|
#include "utilities/debug.hpp"
|
||||||
#include "utilities/globalDefinitions.hpp"
|
#include "utilities/globalDefinitions.hpp"
|
||||||
#include "utilities/preserveException.hpp"
|
#include "utilities/preserveException.hpp"
|
||||||
@ -118,7 +121,6 @@ void StackWatermarkSet::on_safepoint(JavaThread* jt) {
|
|||||||
|
|
||||||
void StackWatermarkSet::start_processing(JavaThread* jt, StackWatermarkKind kind) {
|
void StackWatermarkSet::start_processing(JavaThread* jt, StackWatermarkKind kind) {
|
||||||
verify_processing_context();
|
verify_processing_context();
|
||||||
assert(!jt->is_terminated(), "Poll after termination is a bug");
|
|
||||||
StackWatermark* watermark = get(jt, kind);
|
StackWatermark* watermark = get(jt, kind);
|
||||||
if (watermark != nullptr) {
|
if (watermark != nullptr) {
|
||||||
watermark->start_processing();
|
watermark->start_processing();
|
||||||
@ -158,3 +160,13 @@ uintptr_t StackWatermarkSet::lowest_watermark(JavaThread* jt) {
|
|||||||
return watermark;
|
return watermark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StackWatermarkSet::safepoint_synchronize_begin() {
|
||||||
|
if (VMThread::vm_operation()->skip_thread_oop_barriers()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) {
|
||||||
|
StackWatermarkSet::start_processing(thread, StackWatermarkKind::gc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -88,6 +88,10 @@ public:
|
|||||||
// The lowest watermark among the watermarks in the set (the first encountered
|
// The lowest watermark among the watermarks in the set (the first encountered
|
||||||
// watermark in the set as you unwind frames)
|
// watermark in the set as you unwind frames)
|
||||||
static uintptr_t lowest_watermark(JavaThread* jt);
|
static uintptr_t lowest_watermark(JavaThread* jt);
|
||||||
|
|
||||||
|
// We are synchronizing a safepoint, so we might want to ensure processing has at least
|
||||||
|
// started, as safepoint operations sometimes assume that is the case
|
||||||
|
static void safepoint_synchronize_begin();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARE_RUNTIME_STACKWATERMARKSET_HPP
|
#endif // SHARE_RUNTIME_STACKWATERMARKSET_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user