diff options
author | Lokesh Gidra <lokeshgidra@google.com> | 2023-05-31 13:58:00 -0700 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2023-06-06 12:01:56 +0000 |
commit | 4bf96e3140e32b86d3613e254975f8385f3d344a (patch) | |
tree | 024667619db31380d761a0f686a5b9a6efe467f9 | |
parent | c42b0a973d43e161ca6773ef013325c5e86d709a (diff) | |
download | art-4bf96e3140e32b86d3613e254975f8385f3d344a.tar.gz |
Skip checkpoints in StartupCompletedTask when mutator-lock exclusively held
This could happen with semi-space GC.
Test: test.py
Bug: 282967538
Bug: 260557058
(cherry picked from https://android-review.googlesource.com/q/commit:b0e7f693312b6548ac1bf1edefe2dc4ef7810039)
Merged-In: Ib87c7ddb6b2ffa42e60a43a513f804fe0a6da24a
Change-Id: Ib87c7ddb6b2ffa42e60a43a513f804fe0a6da24a
-rw-r--r-- | runtime/startup_completed_task.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/startup_completed_task.cc b/runtime/startup_completed_task.cc index d29889af75..9709965e9a 100644 --- a/runtime/startup_completed_task.cc +++ b/runtime/startup_completed_task.cc @@ -85,6 +85,9 @@ void StartupCompletedTask::DeleteStartupDexCaches(Thread* self, bool called_by_g // Fetch the startup linear alloc so no other thread tries to allocate there. std::unique_ptr<LinearAlloc> startup_linear_alloc(runtime->ReleaseStartupLinearAlloc()); + // No thread could be allocating arrays or accessing dex caches when this + // thread has mutator-lock held exclusively. + bool run_checkpoints = !Locks::mutator_lock_->IsExclusiveHeld(self); // Request a checkpoint to make sure all threads see we have started up and // won't allocate in the startup linear alloc. Without this checkpoint what @@ -96,7 +99,9 @@ void StartupCompletedTask::DeleteStartupDexCaches(Thread* self, bool called_by_g // // With this checkpoint, 3) cannot happen as T0 waits for T1 to reach the // checkpoint. - runtime->GetThreadList()->RunCheckpoint(&closure); + if (run_checkpoints) { + runtime->GetThreadList()->RunCheckpoint(&closure); + } { UnlinkStartupDexCacheVisitor visitor; @@ -108,7 +113,9 @@ void StartupCompletedTask::DeleteStartupDexCaches(Thread* self, bool called_by_g // Request a checkpoint to make sure no threads are: // - accessing the image space metadata section when we madvise it // - accessing dex caches when we free them - runtime->GetThreadList()->RunCheckpoint(&closure); + if (run_checkpoints) { + runtime->GetThreadList()->RunCheckpoint(&closure); + } // If this isn't the GC calling `DeleteStartupDexCaches` and a GC may be // running, wait for it to be complete. We don't want it to see these dex |