Call madvise hints for image dex files
After opening image spaces, perform madvise hints for the
corresponding dex files.
Moved kMadviseDexFileAccesses to oat_file.cc to not have this enabled
yet.
Bug: 63178181
Test: make and flash
(cherry picked from commit 3efecdef520e80cd79f34549c4ba3a77042d0d92)
Change-Id: If91537e098b159d00354551ce6400a806549b2ca
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 0af0622..c79b5c9 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -74,6 +74,9 @@
// For debugging, Open will print DlOpen error message if set to true.
static constexpr bool kPrintDlOpenErrorMessage = false;
+// If true, we advise the kernel about dex file mem map accesses.
+static constexpr bool kMadviseDexFileAccesses = false;
+
// Note for OatFileBase and descendents:
//
// These are used in OatFile::Open to try all our loaders.
@@ -1495,6 +1498,9 @@
// Madvise the dex file based on the state we are moving to.
void OatDexFile::MadviseDexFile(const DexFile& dex_file, MadviseState state) {
+ if (!kMadviseDexFileAccesses) {
+ return;
+ }
if (state == MadviseState::kMadviseStateAtLoad) {
// Default every dex file to MADV_RANDOM when its loaded by default.
MadviseLargestPageAlignedRegion(dex_file.Begin(),