diff options
author | 2024-12-11 01:46:52 +0000 | |
---|---|---|
committer | 2025-01-30 12:45:17 -0800 | |
commit | d8261f0d75a338c4b74bac006ae7a884f88b1e02 (patch) | |
tree | d2da0efe264015c3cc591b59e1a58b36afd115ee | |
parent | 15faea56c802be4989ff39087ade1453f6101984 (diff) |
Revert "Force 4K ELF alignment on art/odex files."
This reverts commit fcb5c3a0cc8776cfedf8d289c5de19b605afe7ae.
Reason for revert: getting ready to reland, as fixes are in place:
- b/376814207#comment91
This is not a clean revert, only due to oat.h version requirement.
Test: TH, is revert
Bug: 376814207
Bug: 378792349
Change-Id: Ieb9672ba07149bfd2c4b20c3afa17eb19f663c6b
-rw-r--r-- | artd/artd.cc | 1 | ||||
-rw-r--r-- | libartbase/base/globals.h | 4 | ||||
-rw-r--r-- | runtime/gc/space/image_space.cc | 11 | ||||
-rw-r--r-- | runtime/oat/oat.h | 2 | ||||
-rw-r--r-- | runtime/oat/oat_file_assistant.cc | 14 | ||||
-rw-r--r-- | runtime/runtime.cc | 6 | ||||
-rw-r--r-- | runtime/runtime.h | 3 | ||||
-rw-r--r-- | runtime/runtime_image.cc | 5 |
8 files changed, 2 insertions, 44 deletions
diff --git a/artd/artd.cc b/artd/artd.cc index 56a410487e..b72dc114b6 100644 --- a/artd/artd.cc +++ b/artd/artd.cc @@ -1629,7 +1629,6 @@ ScopedAStatus Artd::checkPreRebootSystemRequirements(const std::string& in_chroo Result<void> Artd::Start() { OR_RETURN(SetLogVerbosity()); MemMap::Init(); - Runtime::AllowPageSizeAccess(); ScopedAStatus status = ScopedAStatus::fromStatus(AServiceManager_registerLazyService( this->asBinder().get(), options_.is_pre_reboot ? kPreRebootServiceName : kServiceName)); diff --git a/libartbase/base/globals.h b/libartbase/base/globals.h index 7348444e1c..cab7fab63d 100644 --- a/libartbase/base/globals.h +++ b/libartbase/base/globals.h @@ -53,9 +53,7 @@ static constexpr size_t kMaxPageSize = kMinPageSize; // to be able to generate OAT (ELF) and other image files with alignment other than the host page // size. kElfSegmentAlignment needs to be equal to the largest page size supported. Effectively, // this is the value to be used in images files for aligning contents to page size. -// However, it's temporarily set to 4096 now, to prevent dex2oat from creating sparse files. -// TODO(b/378794327): Fix this. -static constexpr size_t kElfSegmentAlignment = kMinPageSize; +static constexpr size_t kElfSegmentAlignment = kMaxPageSize; // Clion, clang analyzer, etc can falsely believe that "if (kIsDebugBuild)" always // returns the same value. By wrapping into a call to another constexpr function, we force it diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 18f4c4205a..d28a534440 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -65,7 +65,6 @@ #include "oat/oat_file.h" #include "profile/profile_compilation_info.h" #include "runtime.h" -#include "runtime_globals.h" #include "space-inl.h" namespace art HIDDEN { @@ -565,11 +564,6 @@ class ImageSpace::Loader { REQUIRES(!Locks::mutator_lock_) { TimingLogger logger(__PRETTY_FUNCTION__, /*precise=*/ true, VLOG_IS_ON(image)); - if (gPageSize != kMinPageSize) { - *error_msg = "Loading app image is only supported on devices with 4K page size"; - return nullptr; - } - std::unique_ptr<ImageSpace> space = Init(image_filename, image_location, &logger, @@ -3249,11 +3243,6 @@ bool ImageSpace::BootImageLoader::LoadFromSystem( /*out*/std::string* error_msg) { TimingLogger logger(__PRETTY_FUNCTION__, /*precise=*/ true, VLOG_IS_ON(image)); - if (gPageSize != kMinPageSize) { - *error_msg = "Loading boot image is only supported on devices with 4K page size"; - return false; - } - BootImageLayout layout(image_locations_, boot_class_path_, boot_class_path_locations_, diff --git a/runtime/oat/oat.h b/runtime/oat/oat.h index 2a8607844b..bfda96ec8e 100644 --- a/runtime/oat/oat.h +++ b/runtime/oat/oat.h @@ -44,7 +44,7 @@ std::ostream& operator<<(std::ostream& stream, StubType stub_type); class EXPORT PACKED(4) OatHeader { public: static constexpr std::array<uint8_t, 4> kOatMagic { { 'o', 'a', 't', '\n' } }; - // Last oat version changed reason: move dynamic sections to start of OAT file. + // Last oat version changed reason: Restore to 16 KB ELF alignment. static constexpr std::array<uint8_t, 4> kOatVersion{{'2', '5', '6', '\0'}}; static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline"; diff --git a/runtime/oat/oat_file_assistant.cc b/runtime/oat/oat_file_assistant.cc index 7ee65db1a5..151c3a6ca9 100644 --- a/runtime/oat/oat_file_assistant.cc +++ b/runtime/oat/oat_file_assistant.cc @@ -51,7 +51,6 @@ #include "oat.h" #include "oat_file_assistant_context.h" #include "runtime.h" -#include "runtime_globals.h" #include "scoped_thread_state_change-inl.h" #include "vdex_file.h" #include "zlib.h" @@ -1107,12 +1106,6 @@ const OatFile* OatFileAssistant::OatFileInfo::GetFile() { executable = LocationIsTrusted(filename_, /*trust_art_apex_data_files=*/true); } VLOG(oat) << "Loading " << filename_ << " with executable: " << executable; - - if (gPageSize != kMinPageSize) { - LOG(WARNING) << "Loading odex files is only supported on devices with 4K page size"; - return nullptr; - } - if (use_fd_) { if (oat_fd_ >= 0 && vdex_fd_ >= 0) { ArrayRef<const std::string> dex_locations(&oat_file_assistant_->dex_location_, @@ -1151,13 +1144,6 @@ bool OatFileAssistant::OatFileInfo::ShouldRecompileForFilter(CompilerFilter::Fil const OatFile* file = GetFile(); DCHECK(file != nullptr); - if (CompilerFilter::IsBetter(target, CompilerFilter::kVerify) && gPageSize != kMinPageSize) { - // Prevent infinite recompilations during background dexopt on 16K page devices. - VLOG(oat) << "Adjusting target filter to 'verify' because loading odex files is only supported " - "on devices with 4K page size"; - target = CompilerFilter::kVerify; - } - CompilerFilter::Filter current = file->GetCompilerFilter(); if (dexopt_trigger.targetFilterIsBetter && CompilerFilter::IsBetter(target, current)) { VLOG(oat) << ART_FORMAT("Should recompile: targetFilterIsBetter (current: {}, target: {})", diff --git a/runtime/runtime.cc b/runtime/runtime.cc index b43fa1ca5c..a16bde3469 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -3508,10 +3508,4 @@ void Runtime::DCheckNoTransactionCheckAllowed() { } } -NO_INLINE void Runtime::AllowPageSizeAccess() { -#ifdef ART_PAGE_SIZE_AGNOSTIC - gPageSize.AllowAccess(); -#endif -} - } // namespace art diff --git a/runtime/runtime.h b/runtime/runtime.h index 97eac64fa1..e43d1d3432 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -1134,9 +1134,6 @@ class Runtime { bool AreMetricsInitialized() const { return metrics_reporter_ != nullptr; } - // For `artd` only. - EXPORT static void AllowPageSizeAccess(); - private: static void InitPlatformSignalHandlers(); diff --git a/runtime/runtime_image.cc b/runtime/runtime_image.cc index 7bfefe5278..1d3007ad3a 100644 --- a/runtime/runtime_image.cc +++ b/runtime/runtime_image.cc @@ -1868,11 +1868,6 @@ static bool EnsureDirectoryExists(const std::string& directory, std::string* err } bool RuntimeImage::WriteImageToDisk(std::string* error_msg) { - if (gPageSize != kMinPageSize) { - *error_msg = "Writing runtime image is only supported on devices with 4K page size"; - return false; - } - gc::Heap* heap = Runtime::Current()->GetHeap(); if (!heap->HasBootImageSpace()) { *error_msg = "Cannot generate an app image without a boot image"; |