summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPin-Chuan Liu <flash.liu@mediatek.com>2020-05-29 11:57:36 +0800
committerLokesh Gidra <lokeshgidra@google.com>2020-06-15 17:08:36 +0000
commitaa71ecffe5d1053234fdb5230c60499459da8ae3 (patch)
tree779e97d19f90bdd4992f90fc2b483ca592485edb
parentebbeb08a21495a623cc089cb4a7e7a48ff460846 (diff)
downloadart-aa71ecffe5d1053234fdb5230c60499459da8ae3.tar.gz
separate madvise calling from critical section
madvise at large space could spend more time, and let critical section takes longer separate it out to speed up. Bug: 158620760 Bug: 158861776 Test: art/test.py --host Change-Id: I6adfb0e1f962c2fbf6ee559c56755285761b4220 (cherry picked from commit ce0d0079e89e0238a334fdadba09c43940e3adcb)
-rw-r--r--runtime/gc/space/large_object_space.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index 9616ec1d9a..d1b4d7cf02 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -425,7 +425,6 @@ void FreeListSpace::RemoveFreePrev(AllocationInfo* info) {
}
size_t FreeListSpace::Free(Thread* self, mirror::Object* obj) {
- MutexLock mu(self, lock_);
DCHECK(Contains(obj)) << reinterpret_cast<void*>(Begin()) << " " << obj << " "
<< reinterpret_cast<void*>(End());
DCHECK_ALIGNED(obj, kAlignment);
@@ -434,6 +433,15 @@ size_t FreeListSpace::Free(Thread* self, mirror::Object* obj) {
const size_t allocation_size = info->ByteSize();
DCHECK_GT(allocation_size, 0U);
DCHECK_ALIGNED(allocation_size, kAlignment);
+
+ // madvise the pages without lock
+ madvise(obj, allocation_size, MADV_DONTNEED);
+ if (kIsDebugBuild) {
+ // Can't disallow reads since we use them to find next chunks during coalescing.
+ CheckedCall(mprotect, __FUNCTION__, obj, allocation_size, PROT_READ);
+ }
+
+ MutexLock mu(self, lock_);
info->SetByteSize(allocation_size, true); // Mark as free.
// Look at the next chunk.
AllocationInfo* next_info = info->GetNextInfo();
@@ -475,11 +483,6 @@ size_t FreeListSpace::Free(Thread* self, mirror::Object* obj) {
--num_objects_allocated_;
DCHECK_LE(allocation_size, num_bytes_allocated_);
num_bytes_allocated_ -= allocation_size;
- madvise(obj, allocation_size, MADV_DONTNEED);
- if (kIsDebugBuild) {
- // Can't disallow reads since we use them to find next chunks during coalescing.
- CheckedCall(mprotect, __FUNCTION__, obj, allocation_size, PROT_READ);
- }
return allocation_size;
}