summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2024-09-13 12:06:17 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2024-09-20 09:54:39 +0000
commita303efff1731e5b7e9574a4e54701515a4c16d41 (patch)
treebc1827c2f7e493b2f94ce6d4fd5d388bc03c4945
parent3d68eb62b67bc006c42aae6f4dd597cbaf0a99e6 (diff)
Do not unmap twice a mapping.
Put the mappings in mode 'reuse', as the mremaps following in the methods will have unmapped them. Test: m Bug: 363118250 Bug: 319203762 Change-Id: I1c4eae39df1d0b175a83bb4f0cc9af53b400a931
-rw-r--r--libartbase/base/mem_map.h26
-rw-r--r--runtime/jit/jit.cc9
2 files changed, 26 insertions, 9 deletions
diff --git a/libartbase/base/mem_map.h b/libartbase/base/mem_map.h
index a3af44fadb..4b4a56a23f 100644
--- a/libartbase/base/mem_map.h
+++ b/libartbase/base/mem_map.h
@@ -220,6 +220,28 @@ class MemMap {
error_msg);
}
+ static MemMap MapFile(size_t byte_count,
+ int prot,
+ int flags,
+ int fd,
+ off_t start,
+ bool low_4gb,
+ const char* filename,
+ bool reuse,
+ std::string* error_msg) {
+ return MapFileAtAddress(nullptr,
+ byte_count,
+ prot,
+ flags,
+ fd,
+ start,
+ /*low_4gb=*/ low_4gb,
+ filename,
+ reuse,
+ /*reservation=*/ nullptr,
+ error_msg);
+ }
+
// Map part of a file, taking care of non-page aligned offsets. The "start" offset is absolute,
// not relative. This version allows requesting a specific address for the base of the mapping.
//
@@ -425,8 +447,8 @@ class MemMap {
size_t base_size_ = 0u; // Length of mapping. May be changed by RemapAtEnd (ie Zygote).
int prot_ = 0; // Protection of the map.
- // When reuse_ is true, this is just a view of an existing mapping
- // and we do not take ownership and are not responsible for
+ // When reuse_ is true, this is a view of a mapping on which
+ // we do not take ownership and are not responsible for
// unmapping.
bool reuse_ = false;
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 567f07adf0..bdfb911003 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -568,6 +568,7 @@ void Jit::NotifyZygoteCompilationDone() {
/* start= */ 0,
/* low_4gb= */ false,
"boot-image-methods",
+ /* reuse= */ true, // The mapping will be reused by the mremaps below.
&error_str);
if (!child_mapping_methods.IsValid()) {
@@ -640,10 +641,6 @@ void Jit::NotifyZygoteCompilationDone() {
// Mark that compilation of boot classpath is done, and memory can now be
// shared. Other processes will pick up this information.
code_cache_->GetZygoteMap()->SetCompilationState(ZygoteCompilationState::kNotifiedOk);
-
- // The private mapping created for this process has been mremaped. We can
- // reset it.
- child_mapping_methods.Reset();
}
class JitCompileTask final : public Task {
@@ -975,6 +972,7 @@ void Jit::MapBootImageMethods() {
/* start= */ 0,
/* low_4gb= */ false,
"boot-image-methods",
+ /* reuse= */ true, // The mapping will be reused by the mremaps below.
&error_str);
// We don't need the fd anymore.
@@ -1071,9 +1069,6 @@ void Jit::MapBootImageMethods() {
offset += capacity;
}
- // The private mapping created for this process has been mremaped. We can
- // reset it.
- child_mapping_methods.Reset();
LOG(INFO) << "Successfully mapped boot image methods";
}